summaryrefslogtreecommitdiffstats
path: root/tosca2heat/tosca-parser-0.3.0/toscaparser/parameters.py
diff options
context:
space:
mode:
authorshangxdy <shang.xiaodong@zte.com.cn>2016-04-07 14:08:49 -0400
committershangxdy <shang.xiaodong@zte.com.cn>2016-04-07 14:59:30 -0400
commitc8201c119ec686e79797721156767685fe848aca (patch)
treecce6aa15ded38d89c18a14b76c21f21e0b1a24f7 /tosca2heat/tosca-parser-0.3.0/toscaparser/parameters.py
parent4e4c86a06d58b1816c074c7f9da4c58bbf10368c (diff)
Update tosca lib to version 0.5
Use tosca-parser and heat-translator to analyze to the basic nfv-tosca type definitions, and use simple tosca new feature such as policy, group and trigger, which are now supported by the latest version of tosca-parser and heat-translator. JIRA:PARSER-18 Change-Id: I797bcacbb5b32005d0aeb0f3f32851ac96e30f01 Signed--off-by: shangxdy <shang.xiaodong@zte.com.cn> Signed-off-by: shangxdy <shang.xiaodong@zte.com.cn>
Diffstat (limited to 'tosca2heat/tosca-parser-0.3.0/toscaparser/parameters.py')
-rw-r--r--tosca2heat/tosca-parser-0.3.0/toscaparser/parameters.py114
1 files changed, 0 insertions, 114 deletions
diff --git a/tosca2heat/tosca-parser-0.3.0/toscaparser/parameters.py b/tosca2heat/tosca-parser-0.3.0/toscaparser/parameters.py
deleted file mode 100644
index 983aee3..0000000
--- a/tosca2heat/tosca-parser-0.3.0/toscaparser/parameters.py
+++ /dev/null
@@ -1,114 +0,0 @@
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
-
-
-import logging
-
-from toscaparser.common.exception import ExceptionCollector
-from toscaparser.common.exception import MissingRequiredFieldError
-from toscaparser.common.exception import UnknownFieldError
-from toscaparser.dataentity import DataEntity
-from toscaparser.elements.constraints import Schema
-from toscaparser.elements.entity_type import EntityType
-from toscaparser.utils.gettextutils import _
-
-
-log = logging.getLogger('tosca')
-
-
-class Input(object):
-
- INPUTFIELD = (TYPE, DESCRIPTION, DEFAULT, CONSTRAINTS) = \
- ('type', 'description', 'default', 'constraints')
-
- def __init__(self, name, schema_dict):
- self.name = name
- self.schema = Schema(name, schema_dict)
-
- @property
- def type(self):
- return self.schema.type
-
- @property
- def description(self):
- return self.schema.description
-
- @property
- def default(self):
- return self.schema.default
-
- @property
- def constraints(self):
- return self.schema.constraints
-
- def validate(self, value=None):
- self._validate_field()
- self.validate_type(self.type)
- if value:
- self._validate_value(value)
-
- def _validate_field(self):
- for name in self.schema.schema:
- if name not in self.INPUTFIELD:
- ExceptionCollector.appendException(
- UnknownFieldError(what='Input "%s"' % self.name,
- field=name))
-
- def validate_type(self, input_type):
- if input_type not in Schema.PROPERTY_TYPES:
- ExceptionCollector.appendException(
- ValueError(_('Invalid type "%s".') % type))
-
- def _validate_value(self, value):
- tosca = EntityType.TOSCA_DEF
- datatype = None
- if self.type in tosca:
- datatype = tosca[self.type]
- elif EntityType.DATATYPE_PREFIX + self.type in tosca:
- datatype = tosca[EntityType.DATATYPE_PREFIX + self.type]
-
- DataEntity.validate_datatype(self.type, value, None, datatype)
-
-
-class Output(object):
-
- OUTPUTFIELD = (DESCRIPTION, VALUE) = ('description', 'value')
-
- def __init__(self, name, attrs):
- self.name = name
- self.attrs = attrs
-
- @property
- def description(self):
- return self.attrs.get(self.DESCRIPTION)
-
- @property
- def value(self):
- return self.attrs.get(self.VALUE)
-
- def validate(self):
- self._validate_field()
-
- def _validate_field(self):
- if not isinstance(self.attrs, dict):
- ExceptionCollector.appendException(
- MissingRequiredFieldError(what='Output "%s"' % self.name,
- required=self.VALUE))
- if self.value is None:
- ExceptionCollector.appendException(
- MissingRequiredFieldError(what='Output "%s"' % self.name,
- required=self.VALUE))
- for name in self.attrs:
- if name not in self.OUTPUTFIELD:
- ExceptionCollector.appendException(
- UnknownFieldError(what='Output "%s"' % self.name,
- field=name))