summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshangxdy <shang.xiaodong@zte.com.cn>2017-08-13 13:17:03 +0800
committershangxdy <shang.xiaodong@zte.com.cn>2017-08-14 14:44:57 +0800
commit0ebd39bd15e93c9b9cfc52f5c89c1a95440ee659 (patch)
tree8f44660cb2cf876d2f2a4790e8f0569bfe72dc84
parentdc7e1761e1c06ce822308d74d5dededb9a85f940 (diff)
Support costum datatype definition in parameters
Currently, it's only allowed to define standard parameters in the input section, this patch support to define custom datatype in parameters. The patch will be submitted to OpenStack community. JIRA: PARSER-138 Change-Id: Ie83f446958f6daa301382d21d8a32128bf8dffc9 Signed-off-by: shangxdy <shang.xiaodong@zte.com.cn>
-rw-r--r--tosca2heat/tosca-parser/toscaparser/parameters.py8
-rw-r--r--tosca2heat/tosca-parser/toscaparser/topology_template.py2
2 files changed, 7 insertions, 3 deletions
diff --git a/tosca2heat/tosca-parser/toscaparser/parameters.py b/tosca2heat/tosca-parser/toscaparser/parameters.py
index 787db00..0e24b99 100644
--- a/tosca2heat/tosca-parser/toscaparser/parameters.py
+++ b/tosca2heat/tosca-parser/toscaparser/parameters.py
@@ -32,9 +32,10 @@ class Input(object):
'constraints', 'required', 'status',
'entry_schema')
- def __init__(self, name, schema_dict):
+ def __init__(self, name, schema_dict, custom_defs=None):
self.name = name
self.schema = Schema(name, schema_dict)
+ self.custom_defs = custom_defs or {}
self._validate_field()
self.validate_type(self.type)
@@ -75,7 +76,8 @@ class Input(object):
field=name))
def validate_type(self, input_type):
- if input_type not in Schema.PROPERTY_TYPES:
+ if input_type not in Schema.PROPERTY_TYPES and \
+ input_type not in self.custom_defs:
ExceptionCollector.appendException(
ValueError(_('Invalid type "%s".') % type))
@@ -89,6 +91,8 @@ class Input(object):
datatype = tosca[self.type]
elif EntityType.DATATYPE_NETWORK_PREFIX + self.type in tosca:
datatype = tosca[EntityType.DATATYPE_NETWORK_PREFIX + self.type]
+ elif self.type in self.custom_defs:
+ datatype = self.custom_defs[self.type]
DataEntity.validate_datatype(self.type, value, None, datatype)
diff --git a/tosca2heat/tosca-parser/toscaparser/topology_template.py b/tosca2heat/tosca-parser/toscaparser/topology_template.py
index 4571fe7..080108e 100644
--- a/tosca2heat/tosca-parser/toscaparser/topology_template.py
+++ b/tosca2heat/tosca-parser/toscaparser/topology_template.py
@@ -66,7 +66,7 @@ class TopologyTemplate(object):
def _inputs(self):
inputs = []
for name, attrs in self._tpl_inputs().items():
- input = Input(name, attrs)
+ input = Input(name, attrs, self.custom_defs)
if self.parsed_params and name in self.parsed_params:
input.validate(self.parsed_params[name])
else: