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.
|
implementation of a Node type.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
SECTIONS = (NODE_TYPE, REQUIREMENTS, CAPABILITIES) = \
|
SECTIONS = (NODE_TYPE, REQUIREMENTS, CAPABILITIES, PROPERTIES) = \
|
||||||
('node_type', 'requirements', 'capabilities')
|
('node_type', 'requirements', 'capabilities', 'properties')
|
||||||
|
|
||||||
OPTIONAL_OUTPUTS = ['tosca_id', 'tosca_name', 'state']
|
OPTIONAL_OUTPUTS = ['tosca_id', 'tosca_name', 'state']
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@ class SubstitutionMappings(object):
|
||||||
|
|
||||||
self._capabilities = None
|
self._capabilities = None
|
||||||
self._requirements = None
|
self._requirements = None
|
||||||
|
self._properties = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def type(self):
|
def type(self):
|
||||||
|
@ -72,6 +73,10 @@ class SubstitutionMappings(object):
|
||||||
def requirements(self):
|
def requirements(self):
|
||||||
return self.sub_mapping_def.get(self.REQUIREMENTS)
|
return self.sub_mapping_def.get(self.REQUIREMENTS)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def properties(self):
|
||||||
|
return self.sub_mapping_def.get(self.PROPERTIES)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def node_definition(self):
|
def node_definition(self):
|
||||||
return NodeType(self.node_type, self.custom_defs)
|
return NodeType(self.node_type, self.custom_defs)
|
||||||
|
@ -85,6 +90,7 @@ class SubstitutionMappings(object):
|
||||||
self._validate_inputs()
|
self._validate_inputs()
|
||||||
self._validate_capabilities()
|
self._validate_capabilities()
|
||||||
self._validate_requirements()
|
self._validate_requirements()
|
||||||
|
self._validate_properties()
|
||||||
self._validate_outputs()
|
self._validate_outputs()
|
||||||
|
|
||||||
def _validate_keys(self):
|
def _validate_keys(self):
|
||||||
|
@ -191,6 +197,22 @@ class SubstitutionMappings(object):
|
||||||
# UnknownFieldError(what='SubstitutionMappings',
|
# UnknownFieldError(what='SubstitutionMappings',
|
||||||
# field=req))
|
# 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):
|
def _validate_outputs(self):
|
||||||
"""validate the outputs of substitution mappings.
|
"""validate the outputs of substitution mappings.
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,8 @@ topology_template:
|
||||||
|
|
||||||
substitution_mappings:
|
substitution_mappings:
|
||||||
node_type: example.app
|
node_type: example.app
|
||||||
|
properties:
|
||||||
|
receiver_port: 8080
|
||||||
|
|
||||||
node_templates:
|
node_templates:
|
||||||
app:
|
app:
|
||||||
|
|
Loading…
Reference in New Issue