summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshangxdy <shang.xiaodong@zte.com.cn>2017-08-09 16:36:33 +0800
committershangxdy <shang.xiaodong@zte.com.cn>2017-08-09 16:36:33 +0800
commitaf80965fcdd0f2efb9c54714c5a0fe642ad95cb1 (patch)
treea6383a8225e910b7130b072886114cbc4525a3ad
parente22b58bdcd35465dc9f8144e9b0980e0f4366c90 (diff)
Support costum datatype in capability
Support custom datatype definition in property for capability, a scenario if following: VDU: type: tosca.nodes.nfv.VDU.Compute capabilities: virtual_compute: properties: virtual_memory: virtual_mem_size: 24G requested_additional_capabilities: {} virtual_cpu: num_virtual_cpu: 4 node_types: tosca.nodes.nfv.VDU.Compute: derived_from: tosca.nodes.Root capabilities: virtual_compute: type: tosca.capabilities.nfv.VirtualCompute capability_types: tosca.capabilities.nfv.VirtualCompute: derived_from: tosca.capabilities.Root properties: virtual_memory: type: tosca.datatypes.nfv.VirtualMemory requested_additional_capabilities: entry_schema: type: tosca.datatypes.nfv.RequestedAdditionalCapability required: false type: map virtual_cpu: type: tosca.datatypes.nfv.VirtualCpu This patch will be submitted to Openstack. JIAR: PARSER-135 Change-Id: I7b5e3e909e0950de26b37123938fe719004d5417 Signed-off-by: shangxdy <shang.xiaodong@zte.com.cn>
-rw-r--r--tosca2heat/tosca-parser/toscaparser/capabilities.py6
-rw-r--r--tosca2heat/tosca-parser/toscaparser/entity_template.py2
2 files changed, 5 insertions, 3 deletions
diff --git a/tosca2heat/tosca-parser/toscaparser/capabilities.py b/tosca2heat/tosca-parser/toscaparser/capabilities.py
index c23ef72..1708fd8 100644
--- a/tosca2heat/tosca-parser/toscaparser/capabilities.py
+++ b/tosca2heat/tosca-parser/toscaparser/capabilities.py
@@ -16,10 +16,11 @@ from toscaparser.properties import Property
class Capability(object):
'''TOSCA built-in capabilities type.'''
- def __init__(self, name, properties, definition):
+ def __init__(self, name, properties, definition, custom_def):
self.name = name
self._properties = properties
self.definition = definition
+ self.custom_def = custom_def
def get_properties_objects(self):
'''Return a list of property objects.'''
@@ -30,7 +31,8 @@ class Capability(object):
props_def = self.definition.get_properties_def()
if props_def and name in props_def:
properties.append(Property(name, value,
- props_def[name].schema))
+ props_def[name].schema,
+ self.custom_def))
return properties
def get_properties(self):
diff --git a/tosca2heat/tosca-parser/toscaparser/entity_template.py b/tosca2heat/tosca-parser/toscaparser/entity_template.py
index cc3d620..d454ac0 100644
--- a/tosca2heat/tosca-parser/toscaparser/entity_template.py
+++ b/tosca2heat/tosca-parser/toscaparser/entity_template.py
@@ -164,7 +164,7 @@ class EntityTemplate(object):
if 'properties' in props and props['properties']:
properties.update(props['properties'])
- cap = Capability(name, properties, c)
+ cap = Capability(name, properties, c, self.custom_def)
capability.append(cap)
return capability