From d5cacdb9f0d955664fcece4a78a27a71facb3dc1 Mon Sep 17 00:00:00 2001 From: Tung Doan Date: Mon, 28 May 2018 07:54:42 -0700 Subject: [PATCH] Add EXPERIMENTAL support for MEC Since Multi-access Edge Computing has become one of main use cases in OpenStack. This patch adds an experimental support for MEC description. Change-Id: I294df9e245e0c03226796e03c37fdc4f603d139f --- doc/source/usage.rst | 2 + toscaparser/extensions/exttools.py | 3 +- .../mec/TOSCA_mec_definition_1_0_0.yaml | 168 ++++++++++++++++++ toscaparser/extensions/mec/__init__.py | 0 .../mec/tosca_simple_profile_for_mec_1_0_0.py | 19 ++ toscaparser/tests/test_toscatplvalidation.py | 3 +- 6 files changed, 193 insertions(+), 2 deletions(-) create mode 100644 toscaparser/extensions/mec/TOSCA_mec_definition_1_0_0.yaml create mode 100644 toscaparser/extensions/mec/__init__.py create mode 100644 toscaparser/extensions/mec/tosca_simple_profile_for_mec_1_0_0.py diff --git a/doc/source/usage.rst b/doc/source/usage.rst index 08f6e80a..4da77e6b 100644 --- a/doc/source/usage.rst +++ b/doc/source/usage.rst @@ -12,5 +12,7 @@ test program which is located at the root level of the project. Alternatively, you can install 0.3.0 or higher PyPI release of TOSCA-Parser as available at the https://pypi.python.org/project/tosca-parser and test use the parser via CLI entry point as:: + tosca-parser --template-file=toscaparser/tests/data/tosca_helloworld.yaml + The value to the --template-file is required to be a relative or an absolute path. diff --git a/toscaparser/extensions/exttools.py b/toscaparser/extensions/exttools.py index 53104220..2efed353 100644 --- a/toscaparser/extensions/exttools.py +++ b/toscaparser/extensions/exttools.py @@ -11,6 +11,7 @@ # License for the specific language governing permissions and limitations # under the License. +import collections import importlib import logging import os @@ -29,7 +30,7 @@ class ExtTools(object): def _load_extensions(self): '''Dynamically load all the extensions .''' - extensions = {} + extensions = collections.OrderedDict() # Use the absolute path of the class path abs_path = os.path.dirname(os.path.abspath(__file__)) diff --git a/toscaparser/extensions/mec/TOSCA_mec_definition_1_0_0.yaml b/toscaparser/extensions/mec/TOSCA_mec_definition_1_0_0.yaml new file mode 100644 index 00000000..c45c917c --- /dev/null +++ b/toscaparser/extensions/mec/TOSCA_mec_definition_1_0_0.yaml @@ -0,0 +1,168 @@ +# 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_mec_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.mec.MEA: + derived_from: tosca.nodes.Root # Or should this be its own top - level type? + properties: + id: + type: string + description: ID of this MEA + vendor: + type: string + description: name of the vendor who generate this MEA + version: + type: version + description: version of the software for this MEA + requirements: + - virtualLink: + capability: tosca.capabilities.mec.VirtualLinkable + relationship: tosca.relationships.mec.VirtualLinksTo + node: tosca.nodes.mec.VL + + tosca.nodes.mec.VDU: + derived_from: tosca.nodes.Compute + capabilities: + high_availability: + type: tosca.capabilities.mec.HA + virtualbinding: + type: tosca.capabilities.mec.VirtualBindable + monitoring_parameter: + type: tosca.capabilities.mec.Metric + requirements: + - high_availability: + capability: tosca.capabilities.mec.HA + relationship: tosca.relationships.mec.HA + node: tosca.nodes.mec.VDU + occurrences: [ 0, 1 ] + + tosca.nodes.mec.CP: + derived_from: tosca.nodes.network.Port + properties: + type: + type: string + required: false + requirements: + - virtualLink: + capability: tosca.capabilities.mec.VirtualLinkable + relationship: tosca.relationships.mec.VirtualLinksTo + node: tosca.nodes.mec.VL + - virtualBinding: + capability: tosca.capabilities.mec.VirtualBindable + relationship: tosca.relationships.mec.VirtualBindsTo + node: tosca.nodes.mec.VDU + attributes: + address: + type: string + + tosca.nodes.mec.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.mec.VirtualLinkable + + tosca.nodes.mec.VL.ELine: + derived_from: tosca.nodes.mec.VL + capabilities: + virtual_linkable: + occurrences: 2 + + tosca.nodes.mec.VL.ELAN: + derived_from: tosca.nodes.mec.VL + + tosca.nodes.mec.VL.ETree: + derived_from: tosca.nodes.mec.VL + + tosca.nodes.mec.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.mec.Forwarder + relationship: tosca.relationships.mec.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.mec.VirtualLinksTo: + derived_from: tosca.relationships.network.LinksTo + valid_target_types: [ tosca.capabilities.mec.VirtualLinkable ] + + tosca.relationships.mec.VirtualBindsTo: + derived_from: tosca.relationships.network.BindsTo + valid_target_types: [ tosca.capabilities.mec.VirtualBindable ] + + tosca.relationships.mec.HA: + derived_from: tosca.relationships.Root + valid_target_types: [ tosca.capabilities.mec.HA ] + + tosca.relationships.mec.Monitor: + derived_from: tosca.relationships.ConnectsTo + valid_target_types: [ tosca.capabilities.mec.Metric ] + + tosca.relationships.mec.ForwardsTo: + derived_from: tosca.relationships.root + valid_target_types: [ tosca.capabilities.mec.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.mec.VirtualLinkable: + derived_from: tosca.capabilities.network.Linkable + + tosca.capabilities.mec.VirtualBindable: + derived_from: tosca.capabilities.network.Bindable + + tosca.capabilities.mec.HA: + derived_from: tosca.capabilities.Root + valid_source_types: [ tosca.nodes.mec.VDU ] + + tosca.capabilities.mec.HA.ActiveActive: + derived_from: tosca.capabilities.mec.HA + + tosca.capabilities.mec.HA.ActivePassive: + derived_from: tosca.capabilities.mec.HA + + tosca.capabilities.mec.Metric: + derived_from: tosca.capabilities.Root + + tosca.capabilities.mec.Forwarder: + derived_from: tosca.capabilities.Root \ No newline at end of file diff --git a/toscaparser/extensions/mec/__init__.py b/toscaparser/extensions/mec/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/toscaparser/extensions/mec/tosca_simple_profile_for_mec_1_0_0.py b/toscaparser/extensions/mec/tosca_simple_profile_for_mec_1_0_0.py new file mode 100644 index 00000000..11302ba7 --- /dev/null +++ b/toscaparser/extensions/mec/tosca_simple_profile_for_mec_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_mec_1_0_0' + +DEFS_FILE = "TOSCA_mec_definition_1_0_0.yaml" + +SECTIONS = ('metadata') diff --git a/toscaparser/tests/test_toscatplvalidation.py b/toscaparser/tests/test_toscatplvalidation.py index cdd4402e..288a84e8 100644 --- a/toscaparser/tests/test_toscatplvalidation.py +++ b/toscaparser/tests/test_toscatplvalidation.py @@ -101,7 +101,8 @@ class ToscaTemplateValidationTest(TestCase): _('The template version "tosca_simple_yaml_1_10 in ' 'custom_types/imported_sample.yaml" is invalid. ' 'Valid versions are "tosca_simple_yaml_1_0, ' - 'tosca_simple_profile_for_nfv_1_0_0".')) + 'tosca_simple_profile_for_nfv_1_0_0, ' + 'tosca_simple_profile_for_mec_1_0_0".')) exception.ExceptionCollector.assertExceptionMessage( exception.UnknownFieldError, _('Template custom_types/imported_sample.yaml contains unknown '