Fail to parse properties in substitution_mappings
Fixed a bug regarding substitution_mappings does not correspond to properties and is not validated. Story: #2006308 Task: #36026 Change-Id: I3845d10a95c15be00d50deb8603925108f16d643
This commit is contained in:
parent
c1ca5d1af9
commit
2e51d21f7b
|
@ -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.
|
||||
|
||||
|
|
|
@ -39,6 +39,8 @@ topology_template:
|
|||
|
||||
substitution_mappings:
|
||||
node_type: example.app
|
||||
properties:
|
||||
receiver_port: 8080
|
||||
|
||||
node_templates:
|
||||
app:
|
||||
|
|
Loading…
Reference in New Issue