diff options
author | shangxdy <shang.xiaodong@zte.com.cn> | 2017-09-26 20:40:39 +0800 |
---|---|---|
committer | shangxdy <shang.xiaodong@zte.com.cn> | 2017-09-26 20:47:53 +0800 |
commit | 000ea52b78b072435f01d67dd799023117e67a2e (patch) | |
tree | 1f14cdb4485e2184904b553b82afd9e7139a18e5 /nfvparser/toscaparser/parameters.py | |
parent | 53065490134870ead778bff590cfd9e43ddd9f77 (diff) |
Sync code from nfv-toscaprser
Currently nfv-toscaparser has published the regular version of 0.5.1
the patch will synchronize the code.
JIRA: MODELING-23
Change-Id: If95579fc366b69b2b14b2e441ff9a3e6807e3820
Signed-off-by: shangxdy <shang.xiaodong@zte.com.cn>
Diffstat (limited to 'nfvparser/toscaparser/parameters.py')
-rw-r--r-- | nfvparser/toscaparser/parameters.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/nfvparser/toscaparser/parameters.py b/nfvparser/toscaparser/parameters.py index 787db00..d2d2eb3 100644 --- a/nfvparser/toscaparser/parameters.py +++ b/nfvparser/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 DataEntity.validate_datatype(self.type, value, None, datatype) |