VNF scaling: TOSCA definitions and sample template

implements blueprint: #vnf-scaling

Change-Id: I315e5d4df9217b499c537ae31ca80cfe212a55b5
This commit is contained in:
Kanagaraj Manickam 2016-06-17 13:35:47 +05:30
parent e575760d3c
commit a5eb10b2f2
3 changed files with 170 additions and 3 deletions

View File

@ -0,0 +1,63 @@
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
description: sample-tosca-vnfd-scaling
metadata:
template_name: sample-tosca-vnfd-scaling
topology_template:
node_templates:
VDU1:
type: tosca.nodes.nfv.VDU.Tacker
properties:
image: cirros-0.3.4-x86_64-uec
mgmt_driver: noop
availability_zone: nova
flavor: m1.tiny
CP1:
type: tosca.nodes.nfv.CP.Tacker
properties:
management: true
anti_spoofing_protection: false
requirements:
- virtualLink:
node: VL1
- virtualBinding:
node: VDU1
VDU2:
type: tosca.nodes.nfv.VDU.Tacker
properties:
image: cirros-0.3.4-x86_64-uec
mgmt_driver: noop
availability_zone: nova
flavor: m1.tiny
CP2:
type: tosca.nodes.nfv.CP.Tacker
properties:
management: true
anti_spoofing_protection: false
requirements:
- virtualLink:
node: VL1
- virtualBinding:
node: VDU2
VL1:
type: tosca.nodes.nfv.VL
properties:
network_name: private
vendor: Tacker
policies:
- SP1:
type: tosca.policy.tacker.Scaling
properties:
increment: 1
cooldown: 120
min_instances: 1
max_instances: 3
default_instances: 2
targets: [VDU1, VDU2]

View File

@ -0,0 +1,76 @@
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import os
import testtools
from toscaparser import tosca_template
from toscaparser.utils import yamlparser
from tacker.vm.tosca import utils
from translator.hot import tosca_translator
# TODO(kanagaraj-manickam) Update it for including other samples also
def get_list_of_samples():
base_path = (os.path.dirname(os.path.abspath(__file__)) +
'/../../../../samples/tosca-templates/vnfd/')
return [base_path + 'tosca-vnfd-scale.yaml']
class TestSamples(testtools.TestCase):
"""Sample tosca validation.
Helps to validate the tosca templates provided in the samples folder
to make sure whether its valid YAML, valid TOSCA and
possible to translate into HOT template.
"""
def test_samples(self):
for f in get_list_of_samples():
with open(f, 'r') as _f:
yaml_dict = None
try:
yaml_dict = yamlparser.simple_ordered_parse(_f.read())
except: # noqa
pass
self.assertIsNotNone(
yaml_dict,
"Yaml parser failed to parse %s" % f)
utils.updateimports(yaml_dict)
tosca = None
try:
tosca = tosca_template.ToscaTemplate(
a_file=False,
yaml_dict_tpl=yaml_dict)
except: # noqa
pass
self.assertIsNotNone(
tosca,
"Tosca parser failed to parse %s" % f)
hot = None
try:
hot = tosca_translator.TOSCATranslator(tosca,
{}).translate()
except: # noqa
pass
self.assertIsNotNone(
hot,
"Heat-translator failed to translate %s" % f)

View File

@ -125,6 +125,34 @@ policy_types:
properties:
name: http-ping
group_types:
tosca.groups.tacker.VDU:
derived_from: tosca.groups.Root
tosca.policies.tacker.Scaling:
derived_from: tosca.policies.Scaling
description: Defines policy for scaling the given targets.
properties:
increment:
type: integer
required: true
description: Number of nodes to add or remove during the scale out/in.
targets:
type: list
entry_schema:
type: string
required: true
description: List of Scaling nodes.
min_instances:
type: integer
required: true
description: Minimum number of instances to scale in.
max_instances:
type: integer
required: true
description: Maximum number of instances to scale out.
default_instances:
type: integer
required: true
description: Initial number of instances.
cooldown:
type: integer
required: false
default: 120
description: Wait time (in seconds) between consecutive scaling operations. During the cooldown period, scaling action will be ignored