summaryrefslogtreecommitdiffstats
path: root/tosca2heat/tosca-parser/toscaparser/elements
diff options
context:
space:
mode:
Diffstat (limited to 'tosca2heat/tosca-parser/toscaparser/elements')
-rw-r--r--tosca2heat/tosca-parser/toscaparser/elements/TOSCA_definition_1_0.yaml11
-rw-r--r--tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py2
-rw-r--r--tosca2heat/tosca-parser/toscaparser/elements/constraints.py8
-rw-r--r--tosca2heat/tosca-parser/toscaparser/elements/entity_type.py7
-rw-r--r--tosca2heat/tosca-parser/toscaparser/elements/grouptype.py2
-rw-r--r--tosca2heat/tosca-parser/toscaparser/elements/interfaces.py13
-rw-r--r--tosca2heat/tosca-parser/toscaparser/elements/nodetype.py6
-rw-r--r--tosca2heat/tosca-parser/toscaparser/elements/policytype.py5
-rw-r--r--tosca2heat/tosca-parser/toscaparser/elements/portspectype.py2
-rw-r--r--tosca2heat/tosca-parser/toscaparser/elements/relationshiptype.py16
-rw-r--r--tosca2heat/tosca-parser/toscaparser/elements/statefulentitytype.py3
11 files changed, 53 insertions, 22 deletions
diff --git a/tosca2heat/tosca-parser/toscaparser/elements/TOSCA_definition_1_0.yaml b/tosca2heat/tosca-parser/toscaparser/elements/TOSCA_definition_1_0.yaml
index 6f3b331..9f3369e 100644
--- a/tosca2heat/tosca-parser/toscaparser/elements/TOSCA_definition_1_0.yaml
+++ b/tosca2heat/tosca-parser/toscaparser/elements/TOSCA_definition_1_0.yaml
@@ -70,6 +70,8 @@ node_types:
type: tosca.capabilities.OperatingSystem
scalable:
type: tosca.capabilities.Scalable
+ endpoint:
+ type: tosca.capabilities.Endpoint.Admin
requirements:
- local_storage:
capability: tosca.capabilities.Attachment
@@ -527,6 +529,7 @@ capability_types:
network_name:
type: string
required: false
+ default: PRIVATE
initiator:
type: string
required: false
@@ -671,7 +674,7 @@ capability_types:
publish_ports:
type: list
entry_schema:
- type: PortSpec
+ type: tosca.datatypes.network.PortSpec
required: false
description: >
List of ports mappings from source (Docker container)
@@ -679,7 +682,7 @@ capability_types:
expose_ports:
type: list
entry_schema:
- type: PortSpec
+ type: tosca.datatypes.network.PortSpec
required: false
description: >
List of ports mappings from source (Docker container) to expose
@@ -799,7 +802,7 @@ data_types:
constraints:
- valid_values: [ udp, tcp, igmp ]
target:
- type: PortDef
+ type: tosca.datatypes.network.PortDef
required: false
target_range:
type: range
@@ -807,7 +810,7 @@ data_types:
constraints:
- in_range: [ 1, 65535 ]
source:
- type: PortDef
+ type: tosca.datatypes.network.PortDef
required: false
source_range:
type: range
diff --git a/tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py b/tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py
index 865690e..54cd9fe 100644
--- a/tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py
+++ b/tosca2heat/tosca-parser/toscaparser/elements/capabilitytype.py
@@ -44,7 +44,7 @@ class CapabilityTypeDef(StatefulEntityType):
for prop, schema in props.items():
# add parent property if not overridden by children type
if not self.properties or \
- prop not in self.properties.keys():
+ prop not in self.properties.keys():
properties.append(PropertyDef(prop, None, schema))
return properties
diff --git a/tosca2heat/tosca-parser/toscaparser/elements/constraints.py b/tosca2heat/tosca-parser/toscaparser/elements/constraints.py
index 8594b85..70863bc 100644
--- a/tosca2heat/tosca-parser/toscaparser/elements/constraints.py
+++ b/tosca2heat/tosca-parser/toscaparser/elements/constraints.py
@@ -27,10 +27,10 @@ class Schema(collections.Mapping):
KEYS = (
TYPE, REQUIRED, DESCRIPTION,
- DEFAULT, CONSTRAINTS, ENTRYSCHEMA
+ DEFAULT, CONSTRAINTS, ENTRYSCHEMA, STATUS
) = (
'type', 'required', 'description',
- 'default', 'constraints', 'entry_schema'
+ 'default', 'constraints', 'entry_schema', 'status'
)
PROPERTY_TYPES = (
@@ -86,6 +86,10 @@ class Schema(collections.Mapping):
return self.schema.get(self.DEFAULT)
@property
+ def status(self):
+ return self.schema.get(self.STATUS, '')
+
+ @property
def constraints(self):
if not self.constraints_list:
constraint_schemata = self.schema.get(self.CONSTRAINTS)
diff --git a/tosca2heat/tosca-parser/toscaparser/elements/entity_type.py b/tosca2heat/tosca-parser/toscaparser/elements/entity_type.py
index d7fcb18..9fd6c4d 100644
--- a/tosca2heat/tosca-parser/toscaparser/elements/entity_type.py
+++ b/tosca2heat/tosca-parser/toscaparser/elements/entity_type.py
@@ -93,7 +93,7 @@ class EntityType(object):
return False
def entity_value(self, defs, key):
- if key in defs:
+ if defs and key in defs:
return defs[key]
def get_value(self, ndtype, defs=None, parent=None):
@@ -102,7 +102,7 @@ class EntityType(object):
if not hasattr(self, 'defs'):
return None
defs = self.defs
- if ndtype in defs:
+ if defs and ndtype in defs:
# copy the value to avoid that next operations add items in the
# item definitions
value = copy.copy(defs[ndtype])
@@ -110,7 +110,7 @@ class EntityType(object):
p = self
if p:
while p:
- if ndtype in p.defs:
+ if p.defs and ndtype in p.defs:
# get the parent value
parent_value = p.defs[ndtype]
if value:
@@ -159,7 +159,6 @@ class EntityType(object):
def update_definitions(version):
exttools = ExtTools()
extension_defs_file = exttools.get_defs_file(version)
-
loader = toscaparser.utils.yamlparser.load_yaml
nfv_def_file = loader(extension_defs_file)
nfv_def = {}
diff --git a/tosca2heat/tosca-parser/toscaparser/elements/grouptype.py b/tosca2heat/tosca-parser/toscaparser/elements/grouptype.py
index 02c285a..4e58d64 100644
--- a/tosca2heat/tosca-parser/toscaparser/elements/grouptype.py
+++ b/tosca2heat/tosca-parser/toscaparser/elements/grouptype.py
@@ -87,7 +87,7 @@ class GroupType(StatefulEntityType):
'metadata' % (meta_data.get('type'))))
for entry_schema, entry_schema_type in meta_data.items():
if isinstance(entry_schema_type, dict) and not \
- entry_schema_type.get('type') == 'string':
+ entry_schema_type.get('type') == 'string':
ExceptionCollector.appendException(
InvalidTypeError(what='"%s" defined in group for '
'metadata "%s"'
diff --git a/tosca2heat/tosca-parser/toscaparser/elements/interfaces.py b/tosca2heat/tosca-parser/toscaparser/elements/interfaces.py
index 88fb8ab..47ec90a 100644
--- a/tosca2heat/tosca-parser/toscaparser/elements/interfaces.py
+++ b/tosca2heat/tosca-parser/toscaparser/elements/interfaces.py
@@ -22,6 +22,9 @@ SECTIONS = (LIFECYCLE, CONFIGURE, LIFECYCLE_SHORTNAME,
INTERFACEVALUE = (IMPLEMENTATION, INPUTS) = ('implementation', 'inputs')
+INTERFACE_DEF_RESERVED_WORDS = ['type', 'inputs', 'derived_from', 'version',
+ 'description']
+
class InterfacesDef(StatefulEntityType):
'''TOSCA built-in interfaces type.'''
@@ -40,8 +43,16 @@ class InterfacesDef(StatefulEntityType):
interfacetype = LIFECYCLE
if interfacetype == CONFIGURE_SHORTNAME:
interfacetype = CONFIGURE
+ if hasattr(self.ntype, 'interfaces') \
+ and self.ntype.interfaces \
+ and interfacetype in self.ntype.interfaces:
+ interfacetype = self.ntype.interfaces[interfacetype]['type']
if node_type:
- self.defs = self.TOSCA_DEF[interfacetype]
+ if self.node_template and self.node_template.custom_def \
+ and interfacetype in self.node_template.custom_def:
+ self.defs = self.node_template.custom_def[interfacetype]
+ else:
+ self.defs = self.TOSCA_DEF[interfacetype]
if value:
if isinstance(self.value, dict):
for i, j in self.value.items():
diff --git a/tosca2heat/tosca-parser/toscaparser/elements/nodetype.py b/tosca2heat/tosca-parser/toscaparser/elements/nodetype.py
index f5e4eb0..7d68c0b 100644
--- a/tosca2heat/tosca-parser/toscaparser/elements/nodetype.py
+++ b/tosca2heat/tosca-parser/toscaparser/elements/nodetype.py
@@ -98,10 +98,6 @@ class NodeType(StatefulEntityType):
provided capability.
'''
- # All types,include normative and custom types, here will
- # be substituted because the global moification of TOSCA_DEF
- self.TOSCA_DEF.update(self.custom_def)
-
# Filter the node types
node_types = [node_type for node_type in self.TOSCA_DEF.keys()
if node_type.startswith(self.NODE_PREFIX) and
@@ -141,8 +137,6 @@ class NodeType(StatefulEntityType):
'''Return a list of capability objects.'''
typecapabilities = []
caps = self.get_value(self.CAPABILITIES, None, True)
- if caps is None:
- caps = self.get_value(self.CAPABILITIES, None, True)
if caps:
# 'name' is symbolic name of the capability
# 'value' is a dict { 'type': <capability type name> }
diff --git a/tosca2heat/tosca-parser/toscaparser/elements/policytype.py b/tosca2heat/tosca-parser/toscaparser/elements/policytype.py
index 8fbb0f0..a922d26 100644
--- a/tosca2heat/tosca-parser/toscaparser/elements/policytype.py
+++ b/tosca2heat/tosca-parser/toscaparser/elements/policytype.py
@@ -20,9 +20,10 @@ from toscaparser.utils.validateutils import TOSCAVersionProperty
class PolicyType(StatefulEntityType):
'''TOSCA built-in policies type.'''
- SECTIONS = (DERIVED_FROM, METADATA, PROPERTIES, VERSION, DESCRIPTION, TARGETS) = \
+ SECTIONS = (DERIVED_FROM, METADATA, PROPERTIES, VERSION, DESCRIPTION,
+ TARGETS, TRIGGERS, TYPE) = \
('derived_from', 'metadata', 'properties', 'version',
- 'description', 'targets')
+ 'description', 'targets', 'triggers', 'type')
def __init__(self, ptype, custom_def=None):
super(PolicyType, self).__init__(ptype, self.POLICY_PREFIX,
diff --git a/tosca2heat/tosca-parser/toscaparser/elements/portspectype.py b/tosca2heat/tosca-parser/toscaparser/elements/portspectype.py
index d32e97e..0218305 100644
--- a/tosca2heat/tosca-parser/toscaparser/elements/portspectype.py
+++ b/tosca2heat/tosca-parser/toscaparser/elements/portspectype.py
@@ -58,7 +58,7 @@ class PortSpec(object):
# verify one of the specified values is set
if source is None and source_range is None and \
- target is None and target_range is None:
+ target is None and target_range is None:
ExceptionCollector.appendException(
InvalidTypeAdditionalRequirementsError(
type=PortSpec.TYPE_URI))
diff --git a/tosca2heat/tosca-parser/toscaparser/elements/relationshiptype.py b/tosca2heat/tosca-parser/toscaparser/elements/relationshiptype.py
index 25440ca..8eefbea 100644
--- a/tosca2heat/tosca-parser/toscaparser/elements/relationshiptype.py
+++ b/tosca2heat/tosca-parser/toscaparser/elements/relationshiptype.py
@@ -10,16 +10,25 @@
# License for the specific language governing permissions and limitations
# under the License.
+from toscaparser.common.exception import ExceptionCollector
+from toscaparser.common.exception import UnknownFieldError
from toscaparser.elements.statefulentitytype import StatefulEntityType
class RelationshipType(StatefulEntityType):
'''TOSCA built-in relationship type.'''
+ SECTIONS = (DERIVED_FROM, VALID_TARGET_TYPES, INTERFACES,
+ ATTRIBUTES, PROPERTIES, DESCRIPTION, VERSION,
+ CREDENTIAL) = ('derived_from', 'valid_target_types',
+ 'interfaces', 'attributes', 'properties',
+ 'description', 'version', 'credential')
+
def __init__(self, type, capability_name=None, custom_def=None):
super(RelationshipType, self).__init__(type, self.RELATIONSHIP_PREFIX,
custom_def)
self.capability_name = capability_name
self.custom_def = custom_def
+ self._validate_keys()
@property
def parent_type(self):
@@ -31,3 +40,10 @@ class RelationshipType(StatefulEntityType):
@property
def valid_target_types(self):
return self.entity_value(self.defs, 'valid_target_types')
+
+ def _validate_keys(self):
+ for key in self.defs.keys():
+ if key not in self.SECTIONS:
+ ExceptionCollector.appendException(
+ UnknownFieldError(what='Relationshiptype "%s"' % self.type,
+ field=key))
diff --git a/tosca2heat/tosca-parser/toscaparser/elements/statefulentitytype.py b/tosca2heat/tosca-parser/toscaparser/elements/statefulentitytype.py
index be9933e..2f221b3 100644
--- a/tosca2heat/tosca-parser/toscaparser/elements/statefulentitytype.py
+++ b/tosca2heat/tosca-parser/toscaparser/elements/statefulentitytype.py
@@ -35,6 +35,9 @@ class StatefulEntityType(EntityType):
if UnsupportedType.validate_type(entire_entitytype):
self.defs = None
else:
+ if entitytype.startswith(self.TOSCA + ":"):
+ entitytype = entitytype[(len(self.TOSCA) + 1):]
+ entire_entitytype = prefix + entitytype
if not entitytype.startswith(self.TOSCA):
entire_entitytype = prefix + entitytype
if entire_entitytype in list(self.TOSCA_DEF.keys()):