diff --git a/toscaparser/substitution_mappings.py b/toscaparser/substitution_mappings.py index 10641433..95dc4e21 100644 --- a/toscaparser/substitution_mappings.py +++ b/toscaparser/substitution_mappings.py @@ -32,8 +32,8 @@ class SubstitutionMappings(object): implementation of a Node type. ''' - SECTIONS = (NODE_TYPE, REQUIREMENTS, CAPABILITIES) = \ - ('node_type', 'requirements', 'capabilities') + SECTIONS = (NODE_TYPE, REQUIREMENTS, CAPABILITIES, PROPERTIES) = \ + ('node_type', 'requirements', 'capabilities', 'properties') OPTIONAL_OUTPUTS = ['tosca_id', 'tosca_name', 'state'] @@ -49,6 +49,7 @@ class SubstitutionMappings(object): self._capabilities = None self._requirements = None + self._properties = None @property def type(self): @@ -72,6 +73,10 @@ class SubstitutionMappings(object): def requirements(self): return self.sub_mapping_def.get(self.REQUIREMENTS) + @property + def properties(self): + return self.sub_mapping_def.get(self.PROPERTIES) + @property def node_definition(self): return NodeType(self.node_type, self.custom_defs) @@ -85,6 +90,7 @@ class SubstitutionMappings(object): self._validate_inputs() self._validate_capabilities() self._validate_requirements() + self._validate_properties() self._validate_outputs() def _validate_keys(self): @@ -191,6 +197,22 @@ class SubstitutionMappings(object): # UnknownFieldError(what='SubstitutionMappings', # field=req)) + def _validate_properties(self): + """validate the properties of substitution mappings.""" + # The properties in the substitution_mappings must be present + # in the node template properties. + tpls_properties = self.sub_mapping_def.get(self.PROPERTIES) + node_properties = \ + self.sub_mapped_node_template.get_properties_objects() \ + if self.sub_mapped_node_template else None + for req in node_properties if node_properties else []: + if (tpls_properties and + req not in list(tpls_properties.keys())): + pass + # ExceptionCollector.appendException( + # UnknownFieldError(what='SubstitutionMappings', + # field=req)) + def _validate_outputs(self): """validate the outputs of substitution mappings. diff --git a/toscaparser/tests/data/topology_template/validate/test_example_app_substitution_mappings.yaml b/toscaparser/tests/data/topology_template/validate/test_example_app_substitution_mappings.yaml index 718022a0..208cc316 100644 --- a/toscaparser/tests/data/topology_template/validate/test_example_app_substitution_mappings.yaml +++ b/toscaparser/tests/data/topology_template/validate/test_example_app_substitution_mappings.yaml @@ -39,6 +39,8 @@ topology_template: substitution_mappings: node_type: example.app + properties: + receiver_port: 8080 node_templates: app: