diff options
author | Zhaoxing <meng.zhaoxing1@zte.com.cn> | 2017-07-19 07:24:51 +0800 |
---|---|---|
committer | Zhaoxing <meng.zhaoxing1@zte.com.cn> | 2017-07-19 07:45:28 +0800 |
commit | db87c4f77a730e571338c2bf7bfcc9fdc5272185 (patch) | |
tree | 54504cabbb5d319403edc8d123e39f437d2f331a /nfvparser/src/main/python/toscaparser/extensions | |
parent | 1a112663a18408161787f78f01d354a33f070957 (diff) |
init nfvparser code
Change-Id: I8e264c87777e36c4a42f0aa42ab4ae66a1d59a0b
Signed-off-by: Zhaoxing <meng.zhaoxing1@zte.com.cn>
Diffstat (limited to 'nfvparser/src/main/python/toscaparser/extensions')
13 files changed, 1220 insertions, 0 deletions
diff --git a/nfvparser/src/main/python/toscaparser/extensions/__init__.py b/nfvparser/src/main/python/toscaparser/extensions/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/nfvparser/src/main/python/toscaparser/extensions/__init__.py diff --git a/nfvparser/src/main/python/toscaparser/extensions/exttools.py b/nfvparser/src/main/python/toscaparser/extensions/exttools.py new file mode 100644 index 0000000..5310422 --- /dev/null +++ b/nfvparser/src/main/python/toscaparser/extensions/exttools.py @@ -0,0 +1,88 @@ +# +# 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 importlib +import logging +import os + +from toscaparser.common.exception import ToscaExtAttributeError +from toscaparser.common.exception import ToscaExtImportError + +log = logging.getLogger("tosca.model") + +REQUIRED_ATTRIBUTES = ['VERSION', 'DEFS_FILE'] + + +class ExtTools(object): + def __init__(self): + self.EXTENSION_INFO = self._load_extensions() + + def _load_extensions(self): + '''Dynamically load all the extensions .''' + extensions = {} + + # Use the absolute path of the class path + abs_path = os.path.dirname(os.path.abspath(__file__)) + + extdirs = [e for e in os.listdir(abs_path) if + not e.startswith('tests') and + os.path.isdir(os.path.join(abs_path, e))] + + for e in extdirs: + log.info(e) + extpath = abs_path + '/' + e + # Grab all the extension files in the given path + ext_files = [f for f in os.listdir(extpath) if f.endswith('.py') + and not f.startswith('__init__')] + + # For each module, pick out the target translation class + for f in ext_files: + log.info(f) + ext_name = 'toscaparser/extensions/' + e + '/' + f.strip('.py') + ext_name = ext_name.replace('/', '.') + try: + extinfo = importlib.import_module(ext_name) + version = getattr(extinfo, 'VERSION') + defs_file = extpath + '/' + getattr(extinfo, 'DEFS_FILE') + + # Sections is an optional attribute + sections = getattr(extinfo, 'SECTIONS', ()) + + extensions[version] = {'sections': sections, + 'defs_file': defs_file} + except ImportError: + raise ToscaExtImportError(ext_name=ext_name) + except AttributeError: + attrs = ', '.join(REQUIRED_ATTRIBUTES) + raise ToscaExtAttributeError(ext_name=ext_name, + attrs=attrs) + + return extensions + + def get_versions(self): + return self.EXTENSION_INFO.keys() + + def get_sections(self): + sections = {} + for version in self.EXTENSION_INFO.keys(): + sections[version] = self.EXTENSION_INFO[version]['sections'] + + return sections + + def get_defs_file(self, version): + versiondata = self.EXTENSION_INFO.get(version) + + if versiondata: + return versiondata.get('defs_file') + else: + return None diff --git a/nfvparser/src/main/python/toscaparser/extensions/nfv/TOSCA_nfv_definition_1_0_0.yaml b/nfvparser/src/main/python/toscaparser/extensions/nfv/TOSCA_nfv_definition_1_0_0.yaml new file mode 100644 index 0000000..365d70e --- /dev/null +++ b/nfvparser/src/main/python/toscaparser/extensions/nfv/TOSCA_nfv_definition_1_0_0.yaml @@ -0,0 +1,240 @@ +# 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. + +########################################################################## +# The content of this file reflects TOSCA NFV Profile in YAML version +# 1.0.0. It describes the definition for TOSCA NFV types including Node Type, +# Relationship Type, Capability Type and Interfaces. +########################################################################## +tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0 + +########################################################################## +# Node Type. +# A Node Type is a reusable entity that defines the type of one or more +# Node Templates. +########################################################################## +node_types: + tosca.nodes.nfv.VNF: + derived_from: tosca.nodes.Root # Or should this be its own top - level type? + properties: + id: + type: string + description: ID of this VNF + vendor: + type: string + description: name of the vendor who generate this VNF + version: + type: version + description: version of the software for this VNF + requirements: + - virtualLink: + capability: tosca.capabilities.nfv.VirtualLinkable + relationship: tosca.relationships.nfv.VirtualLinksTo + node: tosca.nodes.nfv.VL + + tosca.nodes.nfv.VDU: + derived_from: tosca.nodes.Compute + capabilities: + high_availability: + type: tosca.capabilities.nfv.HA + virtualbinding: + type: tosca.capabilities.nfv.VirtualBindable + monitoring_parameter: + type: tosca.capabilities.nfv.Metric + requirements: + - high_availability: + capability: tosca.capabilities.nfv.HA + relationship: tosca.relationships.nfv.HA + node: tosca.nodes.nfv.VDU + occurrences: [ 0, 1 ] + + tosca.nodes.nfv.CP: + derived_from: tosca.nodes.network.Port + properties: + type: + type: string + required: false + requirements: + - virtualLink: + capability: tosca.capabilities.nfv.VirtualLinkable + relationship: tosca.relationships.nfv.VirtualLinksTo + node: tosca.nodes.nfv.VL + - virtualBinding: + capability: tosca.capabilities.nfv.VirtualBindable + relationship: tosca.relationships.nfv.VirtualBindsTo + node: tosca.nodes.nfv.VDU + attributes: + address: + type: string + + tosca.nodes.nfv.VL: + derived_from: tosca.nodes.network.Network + properties: + vendor: + type: string + required: true + description: name of the vendor who generate this VL + capabilities: + virtual_linkable: + type: tosca.capabilities.nfv.VirtualLinkable + + tosca.nodes.nfv.VL.ELine: + derived_from: tosca.nodes.nfv.VL + capabilities: + virtual_linkable: + occurrences: 2 + + tosca.nodes.nfv.VL.ELAN: + derived_from: tosca.nodes.nfv.VL + + tosca.nodes.nfv.VL.ETree: + derived_from: tosca.nodes.nfv.VL + + tosca.nodes.nfv.FP: + derived_from: tosca.nodes.Root + properties: + policy: + type: string + required: false + description: name of the vendor who generate this VL + requirements: + - forwarder: + capability: tosca.capabilities.nfv.Forwarder + relationship: tosca.relationships.nfv.ForwardsTo + +########################################################################## +# Relationship Type. +# A Relationship Type is a reusable entity that defines the type of one +# or more relationships between Node Types or Node Templates. +########################################################################## + +relationship_types: + tosca.relationships.nfv.VirtualLinksTo: + derived_from: tosca.relationships.network.LinksTo + valid_target_types: [ tosca.capabilities.nfv.VirtualLinkable ] + + tosca.relationships.nfv.VirtualBindsTo: + derived_from: tosca.relationships.network.BindsTo + valid_target_types: [ tosca.capabilities.nfv.VirtualBindable ] + + tosca.relationships.nfv.HA: + derived_from: tosca.relationships.Root + valid_target_types: [ tosca.capabilities.nfv.HA ] + + tosca.relationships.nfv.Monitor: + derived_from: tosca.relationships.ConnectsTo + valid_target_types: [ tosca.capabilities.nfv.Metric ] + + tosca.relationships.nfv.ForwardsTo: + derived_from: tosca.relationships.root + valid_target_types: [ tosca.capabilities.nfv.Forwarder] + +########################################################################## +# Capability Type. +# A Capability Type is a reusable entity that describes a kind of +# capability that a Node Type can declare to expose. +########################################################################## + +capability_types: + tosca.capabilities.nfv.VirtualLinkable: + derived_from: tosca.capabilities.network.Linkable + + tosca.capabilities.nfv.VirtualBindable: + derived_from: tosca.capabilities.network.Bindable + + tosca.capabilities.nfv.HA: + derived_from: tosca.capabilities.Root + valid_source_types: [ tosca.nodes.nfv.VDU ] + + tosca.capabilities.nfv.HA.ActiveActive: + derived_from: tosca.capabilities.nfv.HA + + tosca.capabilities.nfv.HA.ActivePassive: + derived_from: tosca.capabilities.nfv.HA + + tosca.capabilities.nfv.Metric: + derived_from: tosca.capabilities.Root + + tosca.capabilities.nfv.Forwarder: + derived_from: tosca.capabilities.Root + +########################################################################## + # Interfaces Type. + # The Interfaces element describes a list of one or more interface + # definitions for a modelable entity (e.g., a Node or Relationship Type) + # as defined within the TOSCA Simple Profile specification. +########################################################################## + +########################################################################## + # Data Type. + # A Datatype is a complex data type declaration which contains other + # complex or simple data types. +########################################################################## + +########################################################################## + # Artifact Type. + # An Artifact Type is a reusable entity that defines the type of one or more + # files which Node Types or Node Templates can have dependent relationships + # and used during operations such as during installation or deployment. +########################################################################## + +########################################################################## + # Policy Type. + # TOSCA Policy Types represent logical grouping of TOSCA nodes that have + # an implied relationship and need to be orchestrated or managed together + # to achieve some result. +########################################################################## + +########################################################################## + # Group Type + # +########################################################################## +group_types: + tosca.groups.nfv.VNFFG: + derived_from: tosca.groups.Root + + properties: + vendor: + type: string + required: true + description: name of the vendor who generate this VNFFG + + version: + type: string + required: true + description: version of this VNFFG + + number_of_endpoints: + type: integer + required: true + description: count of the external endpoints included in this VNFFG + + dependent_virtual_link: + type: list + entry_schema: + type: string + required: true + description: Reference to a VLD used in this Forwarding Graph + + connection_point: + type: list + entry_schema: + type: string + required: true + description: Reference to Connection Points forming the VNFFG + + constituent_vnfs: + type: list + entry_schema: + type: string + required: true + description: Reference to a list of VNFD used in this VNF Forwarding Graph diff --git a/nfvparser/src/main/python/toscaparser/extensions/nfv/__init__.py b/nfvparser/src/main/python/toscaparser/extensions/nfv/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/nfvparser/src/main/python/toscaparser/extensions/nfv/__init__.py diff --git a/nfvparser/src/main/python/toscaparser/extensions/nfv/tests/__init__.py b/nfvparser/src/main/python/toscaparser/extensions/nfv/tests/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/nfvparser/src/main/python/toscaparser/extensions/nfv/tests/__init__.py diff --git a/nfvparser/src/main/python/toscaparser/extensions/nfv/tests/data/tosca_helloworld_nfv.yaml b/nfvparser/src/main/python/toscaparser/extensions/nfv/tests/data/tosca_helloworld_nfv.yaml new file mode 100644 index 0000000..6afa9f0 --- /dev/null +++ b/nfvparser/src/main/python/toscaparser/extensions/nfv/tests/data/tosca_helloworld_nfv.yaml @@ -0,0 +1,31 @@ +tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0 + +description: Template for deploying a single server with predefined properties. + +metadata: + template_name: TOSCA NFV Sample Template + +topology_template: + node_templates: + VNF1: + type: tosca.nodes.nfv.VNF + properties: + id: vnf1 + vendor: acmetelco + version: 1.0 + + VDU1: + type: tosca.nodes.nfv.VDU + + CP1: + type: tosca.nodes.nfv.CP + properties: + type: vPort + requirements: + - virtualLink: PrivateNetwork + - virtualBinding: VDU1 + + PrivateNetwork: + type: tosca.nodes.nfv.VL + properties: + vendor: ACME Networks diff --git a/nfvparser/src/main/python/toscaparser/extensions/nfv/tests/data/vRNC/Definitions/rnc_definition.yaml b/nfvparser/src/main/python/toscaparser/extensions/nfv/tests/data/vRNC/Definitions/rnc_definition.yaml new file mode 100644 index 0000000..52fbd4c --- /dev/null +++ b/nfvparser/src/main/python/toscaparser/extensions/nfv/tests/data/vRNC/Definitions/rnc_definition.yaml @@ -0,0 +1,173 @@ +## 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. + +tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0 + +#metadata: +# template_name: tosca_simple_profile_for_nfv_vRNC +# template_author: opnfv_parser_project +# template_version: tosca_simple_profile_for_nfv_1_0 + +# Optional description of the definitions inside the file. +description: > + NFV TOSCA simple profile for RNC types + 1. Compute Node MM, CM, DM, LB... + 1.1 MM: MaintainModule; + 1.2 CM: Control Module; + 1.3 DM: Data Module; + 1.4 LB: LineCard Module. + 2. Network Node VL and CP + +# The import section shall be ignored if the value of tosca_definitions_version +# is tosca_simple_profile_for_nfv_1_0_0, otherwise will be needed. + +# list of node type definitions +node_types: + rnc.nodes.VNF: + derived_from: tosca.nodes.nfv.VNF + properties: + vnftype: + type: string + description: type of the RNC + default: UMTS + required: false + constraints: + - valid_values: [ TDS-CDMA, UMTS, CDMA ] + attributes: + private_ip_of_MM: + type: string + description: IP of master MM + private_ip_of_CM: + type: string + description: IP of master CM + private_ip_of_DM: + type: string + description: IP of master DM + private_ip_of_LB: + type: string + description: IP of master LB + requirements: + - virtualLink_VNFM: + capability: tosca.capabilities.nfv.VirtualLinkable + relationship: tosca.relationships.nfv.VirtualLinksTo + node: rnc.nodes.VL + - virtualLink_EMS: + capability: tosca.capabilities.nfv.VirtualLinkable + relationship: tosca.relationships.nfv.VirtualLinksTo + node: rnc.nodes.VL + - virtualLink_TRAFFIC: + capability: tosca.capabilities.nfv.VirtualLinkable + relationship: tosca.relationships.nfv.VirtualLinksTo + node: rnc.nodes.VL + + rnc.nodes.compute.MM: + derived_from: tosca.nodes.nfv.VDU + properties: + activestatus: + type: integer + required: false + description: 1 for active or 0 for passive + constraints: + - valid_values: [ 0, 1 ] + id: + type: string + defaule: MM + required: false + description: > + A identifier of this VDU within the scope of the VNFD, + including version functional description and other + identification information. + + rnc.nodes.compute.CM: + derived_from: tosca.nodes.nfv.VDU + properties: + activestatus: + type: integer + required: false + description: 1 for active or 0 for passive + constraints: + - valid_values: [ 0, 1 ] + + rnc.nodes.compute.DM: + derived_from: tosca.nodes.nfv.VDU + + rnc.nodes.compute.LB: + derived_from: tosca.nodes.nfv.VDU + + rnc.nodes.BlockStorage: + derived_from: tosca.nodes.BlockStorage + + rnc.nodes.VL: + derived_from: tosca.nodes.nfv.VL + + rnc.nodes.CP: + derived_from: tosca.nodes.nfv.CP + + rnc.nodes.CP.MM: + derived_from: tosca.nodes.nfv.CP + # It's ok here because of the weakly validation. + + rnc.nodes.CP.CM: + derived_from: tosca.nodes.nfv.CP + requirements: + - virtualLink: + capability: tosca.capabilities.nfv.VirtualLinkable + relationship: tosca.relationships.nfv.VirtualLinksTo + node: rnc.nodes.VL + - virtualBinding: + capability: tosca.capabilities.nfv.VirtualBindable + relationship: tosca.relationships.nfv.VirtualBindsTo + node: rnc.nodes.compute.CM + + rnc.nodes.CP.DM: + derived_from: tosca.nodes.nfv.CP + requirements: + - virtualLink: + capability: tosca.capabilities.nfv.VirtualLinkable + relationship: tosca.relationships.nfv.VirtualLinksTo + node: rnc.nodes.VL + - virtualBinding: + capability: tosca.capabilities.nfv.VirtualBindable + relationship: tosca.relationships.nfv.VirtualBindsTo + node: rnc.nodes.compute.DM + + rnc.nodes.CP.LB: + derived_from: tosca.nodes.nfv.CP + requirements: + - virtualLink: + capability: tosca.capabilities.nfv.VirtualLinkable + relationship: tosca.relationships.nfv.VirtualLinksTo + node: rnc.nodes.VL + - virtualBinding: + capability: tosca.capabilities.nfv.VirtualBindable + relationship: tosca.relationships.nfv.VirtualBindsTo + node: rnc.nodes.compute.LB + +# list of capability type definitions +capability_types: + rnc.capabilities.Container: + derived_from: tosca.capabilities.Container + properties: + swap: + type: scalar-unit.size + description: swap info + required: false + default: 0 + constraints: + - greater_or_equal: 0 MB + iops: + type: integer + description: IOPS for disk + required: false + default: 0 + constraints: + - greater_than: 0 diff --git a/nfvparser/src/main/python/toscaparser/extensions/nfv/tests/data/vRNC/Definitions/vRNC.yaml b/nfvparser/src/main/python/toscaparser/extensions/nfv/tests/data/vRNC/Definitions/vRNC.yaml new file mode 100644 index 0000000..4441372 --- /dev/null +++ b/nfvparser/src/main/python/toscaparser/extensions/nfv/tests/data/vRNC/Definitions/vRNC.yaml @@ -0,0 +1,552 @@ +## 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. + +tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0 + +metadata: + template_name: tosca_simple_profile_for_nfv_vRNC + template_author: opnfv_parser_project + template_version: tosca_simple_profile_for_nfv_1_0 + +# Optional description of the definitions inside the file. +description: > + TOSCA simple profile for RNC + 1. Compute Node MM, CM, DM, LB... + 1.1 MM: MaintainModule; + 1.2 CM: Control Module; + 1.3 DM: Data Module; + 1.4 LB: LineCard Module + 2. Network Node VL and CP + +imports: + - rnc_definition.yaml + +# list of YAML alias anchors (or macros) +dsl_definitions: + compute_props_os_DEF: &compute_props_os_DEF + architecture: x86_64 + type: Linux + distribution: Cirros + version: 0.3.2 + + compute_props_host_MM: &compute_props_host_MM + disk_size: 1 GB + num_cpus: 1 + mem_size: 512 MB + + compute_props_host_CM: &compute_props_host_CM + disk_size: 0 GB + num_cpus: 1 + mem_size: 512 MB + + compute_props_host_DM: &compute_props_host_DM + disk_size: 0 GB + num_cpus: 1 + mem_size: 512 MB + + compute_props_host_LB: &compute_props_host_LB + disk_size: 0 GB + num_cpus: 1 + mem_size: 512 MB + +# topology template definition of the cloud application or service +topology_template: + # a description of the topology template + description: > + simple RNC template + + inputs: + mm_storage_size: + type: integer + default: 1 + description: mm additional block storage size + constraints: + - in_range: [ 1, 200 ] + id: + type: string + description: ID of this VNF + default: UMTS + vendor: + type: string + description: name of the vendor who generate this VNF + default: opnfv_parser_project + version: + type: version + description: version of the software for this VNF + default: 1.0 + + substitution_mappings: + node_type: rnc.nodes.VNF + requirements: + virtualLink_VNFM: [ MM_Port_CTRL, virtualLink ] + virtualLink_EMS: [ MM_Port_EMS, virtualLink ] + virtualLink_TRAFFIC: [ LB_Port_EXTERMEDIA, virtualLink ] + + # definition of the node templates of the topology + node_templates: + MM_Active: + type: tosca.nodes.SoftwareComponent + properties: + component_version: 1.0 + requirements: + - host: MM_Active_Host + interfaces: + Standard: + create: + implementation: ./Scripts/MM/mm_install.sh + configure: + implementation: ./Scripts/MM/mm_active_configure.sh + + MM_Active_Host: + type: rnc.nodes.compute.MM + capabilities: + os: + properties: *compute_props_os_DEF + host: + properties: *compute_props_host_MM + requirements: + - local_storage: + node: MM_BlockStorage + relationship: Storage_attachesto + artifacts: + #the VM image of MM + vm_image: mm.image + + MM_Passive: + type: tosca.nodes.SoftwareComponent + properties: + component_version: 1.0 + requirements: + - host: MM_Passive_Host + interfaces: + Standard: + create: + implementation: ./Scripts/MM/mm_install.sh + configure: + implementation: ./Scripts/MM/mm_passvie_configure.sh + + MM_Passive_Host: + type: rnc.nodes.compute.MM + capabilities: + os: + properties: *compute_props_os_DEF + host: + properties: *compute_props_host_MM + requirements: + - local_storage: + node: MM_BlockStorage + relationship: Storage_attachesto + - high_availability: MM_Active_Host + artifacts: + #the VM image of MM + vm_image: mm.image + + MM_BlockStorage: + type: rnc.nodes.BlockStorage + properties: + size: { get_input: mm_storage_size } + interfaces: + Configure: + post_configure_target: + implementation: ./Scripts/MM/storage_script.sh + + CM_Active: + type: tosca.nodes.SoftwareComponent + properties: + component_version: 1.0 + requirements: + - host: CM_Active_Host + interfaces: + Standard: + create: + implementation: ./Scripts/CM/cm_install.sh + configure: + implementation: ./Scripts/CM/cm_active_configure.sh + + CM_Active_Host: + type: rnc.nodes.compute.CM + capabilities: + os: + properties: *compute_props_os_DEF + host: + properties: *compute_props_host_CM + scalable: + properties: + min_instances: 1 + max_instances: 12 + default_instances: 1 + artifacts: + #the VM image of CM + vm_image: cm.image + + CM_Passive: + type: tosca.nodes.SoftwareComponent + properties: + component_version: 1.0 + requirements: + - host: CM_Passive_Host + interfaces: + Standard: + create: + implementation: ./Scripts/CM/cm_install.sh + configure: + implementation: ./Scripts/CM/cm_passvie_configure.sh + + CM_Passive_Host: + type: rnc.nodes.compute.CM + capabilities: + os: + properties: *compute_props_os_DEF + host: + properties: *compute_props_host_CM + scalable: + properties: + min_instances: 1 + max_instances: 12 + default_instances: 1 + requirements: + - high_availability: CM_Active_Host + artifacts: + #the VM image of CM + vm_image: mm.image + + DM: + type: tosca.nodes.SoftwareComponent + properties: + component_version: 1.0 + requirements: + - host: DM_Host + interfaces: + Standard: + create: + implementation: ./Scripts/DM/dm_install.sh + configure: + implementation: ./Scripts/DM/dm_configure.sh + + DM_Host: + type: rnc.nodes.compute.DM + capabilities: + os: + properties: *compute_props_os_DEF + host: + properties: *compute_props_host_DM + scalable: + properties: + min_instances: 1 + max_instances: 12 + default_instances: 1 + artifacts: + vm_image: dm.image + + LB: + type: tosca.nodes.SoftwareComponent + properties: + component_version: 1.0 + requirements: + - host: LB_Host + interfaces: + Standard: + create: + implementation: ./Scripts/LB/lb_install.sh + configure: + implementation: ./Scripts/LB/lb_configure.sh + + LB_Host: + type: rnc.nodes.compute.LB + capabilities: + os: + properties: *compute_props_os_DEF + host: + properties: *compute_props_host_LB + scalable: + properties: + min_instances: 1 + max_instances: 2 + default_instances: 1 + artifacts: + #the VM image of LB + vm_image: lb.image + + CTRL_Net: + type: rnc.nodes.VL + properties: + vendor: ZTE + cidr: "128.0.0.0/8" + network_name: Ctrl_Net + network_type: vlan + segmentation_id: 110 + dhcp_enabled: false + + INTERMEDIA_Net: + type: rnc.nodes.VL + properties: + vendor: ZTE + cidr: 10.0.0.0/8 + start_ip: 10.1.0.1 + end_ip: 10.1.2.254 + network_name: InterMedia_Net + network_type: vlan + segmentation_id: 111 + dhcp_enabled: false + + EXTERMEDIA_Net: + type: rnc.nodes.VL + properties: + vendor: ZTE + cidr: 172.1.0.0/16 + start_ip: 172.1.0.2 + end_ip: 172.1.2.254 + gateway_ip: 172.1.0.1 + network_name: ExterMdedia_Net + network_type: vlan + segmentation_id: 100 + dhcp_enabled: false + + EMS_Net: + type: rnc.nodes.VL + properties: + vendor: ZTE + cidr: 129.0.0.0/24 + start_ip: 129.0.0.2 + end_ip: 129.0.0.64 + gateway_ip: 129.0.0.1 + network_name: Ems_Net + network_type: vlan + segmentation_id: 101 + dhcp_enabled: false + + MM_Active_Port_EMS: + type: rnc.nodes.CP.MM + properties: + order: 0 + is_default: true + requirements: + - virtualBinding: MM_Active_Host + - virtualLink: EMS_Net + + MM_Active_Port_EXTERMEDIA: + type: rnc.nodes.CP.MM + properties: + order: 1 + is_default: true + requirements: + - virtualBinding: MM_Active_Host + - virtualLink: EMS_Net + + MM_Active_Port_CTRL: + type: rnc.nodes.CP.MM + properties: + order: 2 + is_default: false + requirements: + - virtualBinding: MM_Active_Host + - virtualLink: CTRL_Net + + MM_Active_Port_INTERMEDIA: + type: rnc.nodes.CP.MM + properties: + order: 3 + is_default: false + requirements: + - virtualBinding: MM_Active_Host + - virtualLink: EXTERMEDIA_Net + + MM_Passive_Port_EMS: + type: rnc.nodes.CP.MM + properties: + order: 0 + is_default: true + requirements: + - virtualBinding: MM_Passive_Host + - virtualLink: EMS_Net + + MM_Passive_Port_EXTERMEDIA: + type: rnc.nodes.CP.MM + properties: + order: 1 + is_default: true + requirements: + - virtualBinding: MM_Passive_Host + - virtualLink: EXTERMEDIA_Net + + MM_Passive_Port_CTRL: + type: rnc.nodes.CP.MM + properties: + order: 2 + is_default: false + requirements: + - virtualBinding: MM_Passive_Host + - virtualLink: CTRL_Net + + MM_Passive_Port_INTERMEDIA: + type: rnc.nodes.CP.MM + properties: + order: 3 + is_default: false + requirements: + - virtualBinding: MM_Passive_Host + - virtualLink: INTERMEDIA_Net + + CM_Active_Port_CTRL: + type: rnc.nodes.CP.CM + properties: + order: 0 + is_default: true + requirements: + - virtualBinding: CM_Active_Host + - virtualLink: CTRL_Net + + CM_Active_Port_INTERMEDIA: + type: rnc.nodes.CP.CM + properties: + order: 1 + is_default: false + requirements: + - virtualBinding: CM_Active_Host + - virtualLink: INTERMEDIA_Net + + CM_Passive_Port_CTRL: + type: rnc.nodes.CP.CM + properties: + order: 0 + is_default: true + requirements: + - virtualBinding: CM_Passive_Host + - virtualLink: CTRL_Net + + CM_Passive_Port_INTERMEDIA: + type: rnc.nodes.CP.CM + properties: + order: 1 + is_default: false + requirements: + - virtualBinding: CM_Passive_Host + - virtualLink: INTERMEDIA_Net + + DM_Port_CTRL: + type: rnc.nodes.CP.DM + properties: + order: 0 + is_default: true + requirements: + - virtualBinding: DM_Host + - virtualLink: CTRL_Net + + DM_Port_INTERMEDIA: + type: rnc.nodes.CP.DM + properties: + order: 1 + is_default: false + requirements: + - virtualBinding: DM_Host + - virtualLink: INTERMEDIA_Net + + LB_Port_CTRL: + type: rnc.nodes.CP.LB + properties: + order: 0 + is_default: true + requirements: + - virtualBinding: LB_Host + - virtualLink: CTRL_Net + + LB_Port_INTERMEDIA: + type: rnc.nodes.CP.LB + properties: + order: 1 + is_default: false + requirements: + - virtualBinding: LB_Host + - virtualLink: INTERMEDIA_Net + + LB_Port_EXTERMEDIA: + type: rnc.nodes.CP.LB + properties: + order: 2 + is_default: false + requirements: + - virtualBinding: LB_Host + - virtualLink: EXTERMEDIA_Net + + # definition of the relationship templates of the topology + relationship_templates: + Storage_attachesto: + type: tosca.relationships.AttachesTo + properties: + location: /data_location + + # definition of output parameters for the topology template + outputs: + private_ip_of_MM: + description: The Inner(CtrPlane) IP address of the MM. + value: { get_attribute: [ MM_Active_Host, private_address ] } + + private_ip_of_CM: + description: The Inner(CtrPlane) IP address of the CM. + value: { get_attribute: [ CM_Active_Host, private_address ] } + + private_ip_of_DM: + description: The Inner(CtrPlane) IP address of the DM. + value: { get_attribute: [ DM_Host, private_address ] } + + private_ip_of_LB: + description: The Inner(CtrPlane) IP address of the LB. + value: { get_attribute: [ LB_Host, private_address ] } + + # definition of logical groups of node templates within the topology + # To be continue about this section + groups: + AntiAffinityServerGroup: + type: tosca.groups.Root + description: > + Logical component grouping for anti affinity placement, + MM_Acitve, MM_Passive, CM_Acitve, CM_Passive, LB must host + on different host to reduce the impact to each other. + members: [ MM_Active, MM_Passive, CM_Active, CM_Passive, LB ] + + AffinityServerGroup: + type: tosca.groups.Root + description: > + Logical component grouping for affinity placement, + CM and DM will be host on the same host to get high performence + members: [ CM_Active, DM ] + + policies: + - AntiAffinityPolicy: + # type: tosca.policies.Placement + type: tosca.policies.Placement.Antilocate + # Current only placement in openstack community + description: Apply anti-locate placement policy to group + targets: [ AntiAffinityServerGroup ] + + - AffinityPolicy: + #type: tosca.policies.Placement + type: tosca.policies.Placement.Colocate + # Current only placement in openstack community + description: Apply anti-locate placement policy to group + targets: [ AffinityServerGroup ] + + # ServerGroupScaling_DM: # added future + # members: [ DM, ]# only one, will be error + # policies: + # - name: MyScaleUpPolicy + # - type: tosca.policy.scale.up | tosca.policy.scale.down + # - rule: fn.utilizaton [ DM ], greater_than: 80 + # - trigger: script_dm + + # ServerGroupScaling_LB: # added future + # members: [ LB, ] # only one, will be error + # policies: + # - name: MyScaleUpPolicy + # - type: tosca.policy.scale.up | tosca.policy.scale.down + # - rule: fn.utilizaton [ LB ], greater_than: 80 + # - trigger: script_lb diff --git a/nfvparser/src/main/python/toscaparser/extensions/nfv/tests/data/vRNC/README.txt b/nfvparser/src/main/python/toscaparser/extensions/nfv/tests/data/vRNC/README.txt new file mode 100644 index 0000000..9ea77a4 --- /dev/null +++ b/nfvparser/src/main/python/toscaparser/extensions/nfv/tests/data/vRNC/README.txt @@ -0,0 +1,22 @@ +README: + +This CSAR contains all definitions that are required for deploying a simple +vRNC(virtual Radio Network Controller) on a cloud. + +Entry information for processing through an orchestrator is contained in file +TOSCA-Metadata/TOSCA.meta. This file provides high-level information such as +CSAR version or creator of the CSAR. Furthermore, it provides pointers to the +various TOSCA definitions files that contain the real details. +The entry 'Entry-Definitions' points to the definitions file which holds the +service template for the workload. +'Entry-Definitions' is optional. An orchestrator can also process the contents +like this: +1) Read in and process each definitions file. +2) For each definitions file: + 2.1) Read in all * type definitions (node types, capability types, etc.) and + store them in an internal map +3) Verify and build dependencies (e.g. inheritance) between all type definitions + previously read in. Orchestrator built-in types (e.g. TOSCA base types) are + also considered in this step. +4) Process the actual service template (the file with a node_templates section). + Validate using previously obtained type information.
\ No newline at end of file diff --git a/nfvparser/src/main/python/toscaparser/extensions/nfv/tests/data/vRNC/TOSCA-Metadata/TOSCA.meta b/nfvparser/src/main/python/toscaparser/extensions/nfv/tests/data/vRNC/TOSCA-Metadata/TOSCA.meta new file mode 100644 index 0000000..45f9ab2 --- /dev/null +++ b/nfvparser/src/main/python/toscaparser/extensions/nfv/tests/data/vRNC/TOSCA-Metadata/TOSCA.meta @@ -0,0 +1,4 @@ +TOSCA-Meta-File-Version: 1.0 +CSAR-Version: 1.1 +Created-By: shang.xiaodog@zte.com.cn +Entry-Definitions: Definitions/vRNC.yaml
\ No newline at end of file diff --git a/nfvparser/src/main/python/toscaparser/extensions/nfv/tests/test_tosca_nfv_tpl.py b/nfvparser/src/main/python/toscaparser/extensions/nfv/tests/test_tosca_nfv_tpl.py new file mode 100644 index 0000000..b166d83 --- /dev/null +++ b/nfvparser/src/main/python/toscaparser/extensions/nfv/tests/test_tosca_nfv_tpl.py @@ -0,0 +1,29 @@ +# 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 + +from toscaparser.tests.base import TestCase +from toscaparser.tosca_template import ToscaTemplate + + +class ToscaNFVTemplateTest(TestCase): + + '''TOSCA NFV template.''' + tosca_tpl = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/tosca_helloworld_nfv.yaml") + tosca = ToscaTemplate(tosca_tpl) + + def test_version(self): + self.assertEqual(self.tosca.version, + "tosca_simple_profile_for_nfv_1_0_0") diff --git a/nfvparser/src/main/python/toscaparser/extensions/nfv/tests/test_tosca_vRNC.py b/nfvparser/src/main/python/toscaparser/extensions/nfv/tests/test_tosca_vRNC.py new file mode 100644 index 0000000..a0ffc21 --- /dev/null +++ b/nfvparser/src/main/python/toscaparser/extensions/nfv/tests/test_tosca_vRNC.py @@ -0,0 +1,62 @@ +# 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 + +from toscaparser.tests.base import TestCase +from toscaparser.tosca_template import ToscaTemplate + + +class ToscaVRNCTemplateTest(TestCase): + + '''NFV TOSCA vRNC template.''' + tosca_tpl = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "data/vRNC/Definitions/vRNC.yaml") + tosca = ToscaTemplate(tosca_tpl) + + def test_version(self): + self.assertEqual(self.tosca.version, + "tosca_simple_profile_for_nfv_1_0_0") + + def test_input(self): + input_names = sorted(["mm_storage_size", "id", + "vendor", "version"]) + self.assertEqual(sorted([i.name for i in self.tosca.inputs]), + input_names) + + def test_nodetemplates(self): + expected_node_list = sorted( + ["MM_Active", "MM_Passive", "MM_BlockStorage", + "MM_Active_Host", "MM_Passive_Host", + "CM_Active", "CM_Passive", "DM", "LB", + "CM_Active_Host", "CM_Passive_Host", "DM_Host", "LB_Host", + "EXTERMEDIA_Net", "INTERMEDIA_Net", "EMS_Net", "CTRL_Net", + "MM_Active_Port_EMS", "MM_Active_Port_CTRL", + "MM_Active_Port_EXTERMEDIA", "MM_Active_Port_INTERMEDIA", + "MM_Passive_Port_EMS", "MM_Passive_Port_CTRL", + "MM_Passive_Port_EXTERMEDIA", "MM_Passive_Port_INTERMEDIA", + "CM_Active_Port_CTRL", "CM_Active_Port_INTERMEDIA", + "CM_Passive_Port_CTRL", "CM_Passive_Port_INTERMEDIA", + "DM_Port_CTRL", "DM_Port_INTERMEDIA", + "LB_Port_INTERMEDIA", "LB_Port_EXTERMEDIA", "LB_Port_CTRL"]) + + node_list = sorted([node.name for node in self.tosca.nodetemplates]) + self.assertEqual(node_list, expected_node_list) + + def test_output(self): + expected_output_name = sorted( + ["private_ip_of_CM", "private_ip_of_DM", + "private_ip_of_LB", "private_ip_of_MM"]) + + output_list = sorted([output.name for output in self.tosca.outputs]) + self.assertEqual(output_list, expected_output_name) diff --git a/nfvparser/src/main/python/toscaparser/extensions/nfv/tosca_simple_profile_for_nfv_1_0_0.py b/nfvparser/src/main/python/toscaparser/extensions/nfv/tosca_simple_profile_for_nfv_1_0_0.py new file mode 100644 index 0000000..24eabab --- /dev/null +++ b/nfvparser/src/main/python/toscaparser/extensions/nfv/tosca_simple_profile_for_nfv_1_0_0.py @@ -0,0 +1,19 @@ +# 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. + +# VERSION and DEFS_FILE are required for all extensions + +VERSION = 'tosca_simple_profile_for_nfv_1_0_0' + +DEFS_FILE = "TOSCA_nfv_definition_1_0_0.yaml" + +SECTIONS = ('metadata') |