Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-321-clearwater 40be30864 -> 328914285 (forced update)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/32891428/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/artifacts.yaml ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/artifacts.yaml b/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/artifacts.yaml index cfb0df5..945622f 100644 --- a/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/artifacts.yaml +++ b/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/artifacts.yaml @@ -24,7 +24,7 @@ artifact_types: specification_url: 'http://docs.oasis-open.org/tosca/TOSCA-Simple-Profile-YAML/v1.0/cos01/TOSCA-Simple-Profile-YAML-v1.0-cos01.html#DEFN_TYPE_ARTIFACTS_ROOT' description: >- This is the default (root) TOSCA Artifact Type definition that all other TOSCA base Artifact Types derive from. - + tosca.artifacts.File: _extensions: shorthand_name: File @@ -34,11 +34,11 @@ artifact_types: description: >- This artifact type is used when an artifact definition needs to have its associated file simply treated as a file and no special handling/handlers are invoked (i.e., it is not treated as either an implementation or deployment artifact type). derived_from: tosca.artifacts.Root - + # # Deployments # - + tosca.artifacts.Deployment: _extensions: shorthand_name: Deployment # ARIA NOTE: omitted in the spec @@ -51,7 +51,7 @@ artifact_types: represents a binary packaging of an application or service that is used to install/create or deploy it as part of a node's lifecycle. derived_from: tosca.artifacts.Root - + tosca.artifacts.Deployment.Image: _extensions: shorthand_name: Deployment.Image @@ -64,7 +64,7 @@ artifact_types: (whether real or virtual) whose contents are typically already installed and pre-configured (i.e., "stateful") and prepared to be run on a known target container. derived_from: tosca.artifacts.Deployment - + tosca.artifacts.Deployment.Image.VM: _extensions: shorthand_name: Deployment.VM # ARIA NOTE: omitted in the spec @@ -78,11 +78,11 @@ artifact_types: with any configurations and can be run on another machine using a hypervisor which virtualizes typical server (i.e., hardware) resources. derived_from: tosca.artifacts.Deployment - + # # Implementations # - + tosca.artifacts.Implementation: _extensions: shorthand_name: Implementation # ARIA NOTE: omitted in the spec @@ -94,7 +94,7 @@ artifact_types: This artifact type represents the parent type for all implementation artifacts in TOSCA. These artifacts are used to implement operations of TOSCA interfaces either directly (e.g., scripts) or indirectly (e.g., config. files). derived_from: tosca.artifacts.Root - + tosca.artifacts.Implementation.Bash: _extensions: shorthand_name: Implementation.Bash # ARIA NOTE: mistake in spec? shouldn't we have "Implementation." as prefix? @@ -106,7 +106,7 @@ artifact_types: derived_from: tosca.artifacts.Implementation mime_type: application/x-sh file_ext: [ sh ] - + tosca.artifacts.Implementation.Python: _extensions: shorthand_name: Implementation.Python # ARIA NOTE: mistake in spec? shouldn't we have "Implementation." as prefix? http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/32891428/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/capabilities.yaml ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/capabilities.yaml b/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/capabilities.yaml index b705d47..66a4046 100644 --- a/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/capabilities.yaml +++ b/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/capabilities.yaml @@ -51,7 +51,7 @@ capability_types: derived_from: tosca.capabilities.Root properties: num_cpus: - description: >- + description: >- Number of (actual or virtual) CPUs associated with the Compute node. type: integer constraints: @@ -239,7 +239,7 @@ capability_types: specification_url: 'http://docs.oasis-open.org/tosca/TOSCA-Simple-Profile-YAML/v1.0/cos01/TOSCA-Simple-Profile-YAML-v1.0-cos01.html#DEFN_TYPE_CAPABILITIES_ENDPOINT_PUBLIC' description: >- This capability represents a public endpoint which is accessible to the general internet (and its public IP address ranges). - + This public endpoint capability also can be used to create a floating (IP) address that the underlying network assigns from a pool allocated from the application's underlying public network. This floating address is managed by the underlying network such that can be routed an application's private address and remains reliable to internet clients. @@ -292,14 +292,14 @@ capability_types: description: >- This is the default TOSCA type that should be used or extended to define a specialized database endpoint capability. derived_from: tosca.capabilities.Endpoint - + # # Network # tosca.capabilities.network.Bindable: _extensions: - shorthand_name: Bindable # ARIA NOTE: mistake in spec? has "network." as a prefix + shorthand_name: Bindable # ARIA NOTE: mistake in spec? has "network." as a prefix type_qualified_name: tosca:Bindable specification: tosca-simple-1.0 specification_section: 5.4.11 http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/32891428/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/data.yaml ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/data.yaml b/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/data.yaml index 771a969..61d4186 100644 --- a/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/data.yaml +++ b/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/data.yaml @@ -18,7 +18,7 @@ data_types: # # Primitive # - + timestamp: _extensions: coerce_value: aria_extension_tosca.simple_v1_0.data_types.coerce_timestamp @@ -60,7 +60,7 @@ data_types: specification: tosca-simple-1.0 specification_section: 3.2.5 specification_url: 'http://docs.oasis-open.org/tosca/TOSCA-Simple-Profile-YAML/v1.0/cos01/TOSCA-Simple-Profile-YAML-v1.0-cos01.html#TYPE_TOSCA_MAP' - + # # Scalar # @@ -142,7 +142,7 @@ data_types: The optional user (name or ID) used for non-token based credentials. type: string required: false - + tosca.datatypes.network.NetworkInfo: _extensions: shorthand_name: NetworkInfo @@ -171,7 +171,7 @@ data_types: entry_schema: type: string required: false - + tosca.datatypes.network.PortInfo: _extensions: shorthand_name: PortInfo @@ -210,7 +210,7 @@ data_types: entry_schema: type: string required: false - + tosca.datatypes.network.PortDef: _extensions: shorthand_name: PortDef http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/32891428/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/interfaces.yaml ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/interfaces.yaml b/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/interfaces.yaml index 473bd98..29cc8dd 100644 --- a/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/interfaces.yaml +++ b/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/interfaces.yaml @@ -24,7 +24,7 @@ interface_types: specification_url: 'http://docs.oasis-open.org/tosca/TOSCA-Simple-Profile-YAML/v1.0/cos01/TOSCA-Simple-Profile-YAML-v1.0-cos01.html#_Ref384391055' description: >- This is the default (root) TOSCA Interface Type definition that all other TOSCA Interface Types derive from. - + tosca.interfaces.node.lifecycle.Standard: _extensions: shorthand_name: Standard http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/32891428/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/nodes.yaml ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/nodes.yaml b/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/nodes.yaml index 1d2fe90..05963b7 100644 --- a/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/nodes.yaml +++ b/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/nodes.yaml @@ -45,14 +45,14 @@ node_types: type: tosca.interfaces.node.lifecycle.Standard capabilities: feature: - type: tosca.capabilities.Node + type: tosca.capabilities.Node requirements: - dependency: capability: tosca.capabilities.Node node: tosca.nodes.Root relationship: tosca.relationships.DependsOn occurrences: [ 0, UNBOUNDED ] - + tosca.nodes.Compute: _extensions: shorthand_name: Compute @@ -133,11 +133,11 @@ node_types: capability: tosca.capabilities.Endpoint relationship: tosca.relationships.RoutesTo occurrences: [ 0, UNBOUNDED ] - + # # Software # - + tosca.nodes.SoftwareComponent: _extensions: shorthand_name: SoftwareComponent @@ -211,7 +211,7 @@ node_types: capability: tosca.capabilities.Container node: tosca.nodes.WebServer relationship: tosca.relationships.HostedOn - + tosca.nodes.DBMS: _extensions: shorthand_name: DBMS # ARIA NOTE: omitted in the spec @@ -276,7 +276,7 @@ node_types: capability: tosca.capabilities.Container node: tosca.nodes.DBMS relationship: tosca.relationships.HostedOn - + # # Container # @@ -351,7 +351,7 @@ node_types: capabilities: storage_endpoint: type: tosca.capabilities.Endpoint - + tosca.nodes.BlockStorage: _extensions: shorthand_name: BlockStorage @@ -463,7 +463,7 @@ node_types: capabilities: link: type: tosca.capabilities.network.Linkable - + tosca.nodes.network.Port: _extensions: shorthand_name: Port @@ -472,7 +472,7 @@ node_types: specification_section: 7.5.2 description: >- The TOSCA Port node represents a logical entity that associates between Compute and Network normative types. - + The Port node type effectively represents a single virtual NIC on the Compute node instance. derived_from: tosca.nodes.Root properties: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/32891428/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/policies.yaml ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/policies.yaml b/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/policies.yaml index c65e38b..7b35bb9 100644 --- a/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/policies.yaml +++ b/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/policies.yaml @@ -24,7 +24,7 @@ policy_types: specification_url: 'http://docs.oasis-open.org/tosca/TOSCA-Simple-Profile-YAML/v1.0/cos01/TOSCA-Simple-Profile-YAML-v1.0-cos01.html#DEFN_TYPE_POLICIES_ROOT' description: >- This is the default (root) TOSCA Policy Type definition that all other TOSCA base Policy Types derive from. - + tosca.policies.Placement: _extensions: shorthand_name: Placement # ARIA NOTE: omitted in the spec @@ -35,7 +35,7 @@ policy_types: description: >- This is the default (root) TOSCA Policy Type definition that is used to govern placement of TOSCA nodes or groups of nodes. derived_from: tosca.policies.Root - + tosca.policies.Scaling: _extensions: shorthand_name: Scaling # ARIA NOTE: omitted in the spec @@ -46,7 +46,7 @@ policy_types: description: >- This is the default (root) TOSCA Policy Type definition that is used to govern scaling of TOSCA nodes or groups of nodes. derived_from: tosca.policies.Root - + tosca.policies.Update: _extensions: shorthand_name: Update # ARIA NOTE: omitted in the spec @@ -57,7 +57,7 @@ policy_types: description: >- This is the default (root) TOSCA Policy Type definition that is used to govern update of TOSCA nodes or groups of nodes. derived_from: tosca.policies.Root - + tosca.policies.Performance: _extensions: shorthand_name: Performance # ARIA NOTE: omitted in the spec http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/32891428/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/relationships.yaml ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/relationships.yaml b/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/relationships.yaml index b9d3176..9f2c32c 100644 --- a/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/relationships.yaml +++ b/extensions/aria_extension_tosca/profiles/tosca-simple-1.0/relationships.yaml @@ -43,7 +43,7 @@ relationship_types: interfaces: Configure: type: tosca.interfaces.relationship.Configure - + tosca.relationships.DependsOn: _extensions: shorthand_name: DependsOn @@ -55,7 +55,7 @@ relationship_types: This type represents a general dependency relationship between two nodes. derived_from: tosca.relationships.Root valid_target_types: [ tosca.capabilities.Node ] - + tosca.relationships.HostedOn: _extensions: shorthand_name: HostedOn @@ -67,7 +67,7 @@ relationship_types: This type represents a hosting relationship between two nodes. derived_from: tosca.relationships.Root valid_target_types: [ tosca.capabilities.Container ] - + tosca.relationships.ConnectsTo: _extensions: shorthand_name: ConnectsTo @@ -83,7 +83,7 @@ relationship_types: credential: type: tosca.datatypes.Credential required: false - + tosca.relationships.AttachesTo: _extensions: shorthand_name: AttachesTo @@ -116,7 +116,7 @@ relationship_types: The logical name of the device as exposed to the instance. Note: A runtime property that gets set when the model gets instantiated by the orchestrator. type: string - + tosca.relationships.RoutesTo: _extensions: shorthand_name: RoutesTo @@ -128,11 +128,11 @@ relationship_types: This type represents an intentional network routing between two Endpoints in different networks. derived_from: tosca.relationships.ConnectsTo valid_target_types: [ tosca.capabilities.Endpoint ] - + # # Network # - + tosca.relationships.network.LinksTo: _extensions: shorthand_name: LinksTo @@ -144,7 +144,7 @@ relationship_types: This relationship type represents an association relationship between Port and Network node types. derived_from: tosca.relationships.DependsOn valid_target_types: [ tosca.capabilities.network.Linkable ] - + tosca.relationships.network.BindsTo: _extensions: shorthand_name: BindsTo # ARIA NOTE: the spec says "network.BindsTo" which seems wrong http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/32891428/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/nodes.yaml ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/nodes.yaml b/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/nodes.yaml index 73f0ecd..8d1f0a2 100644 --- a/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/nodes.yaml +++ b/extensions/aria_extension_tosca/profiles/tosca-simple-nfv-1.0/nodes.yaml @@ -98,11 +98,11 @@ node_types: # ARIA NOTE: commented out in 5.9.2.5 description: >- Monitoring parameter, which can be tracked for a VNFC based on this VDU. Examples include: - memory-consumption, CPU-utilisation, bandwidth-consumption, VNFC downtime, etc. + memory-consumption, CPU-utilisation, bandwidth-consumption, VNFC downtime, etc. type: tosca.capabilities.nfv.Metric #requirements: # ARIA NOTE: virtual_storage is TBD - + # ARIA NOTE: csd04 attempts to deprecate the inherited local_storage requirement, but this # is not possible in TOSCA artifacts: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/32891428/extensions/aria_extension_tosca/simple_v1_0/data_types.py ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/simple_v1_0/data_types.py b/extensions/aria_extension_tosca/simple_v1_0/data_types.py index 513b517..216f1e4 100644 --- a/extensions/aria_extension_tosca/simple_v1_0/data_types.py +++ b/extensions/aria_extension_tosca/simple_v1_0/data_types.py @@ -163,7 +163,7 @@ class Version(object): #TYPE_TOSCA_VERSION>`__ """ - REGULAR = \ + REGEX = \ r'^(?P<major>\d+)\.(?P<minor>\d+)(\.(?P<fix>\d+)' + \ r'((\.(?P<qualifier>\d+))(\-(?P<build>\d+))?)?)?$' @@ -176,7 +176,7 @@ class Version(object): def __init__(self, entry_schema, constraints, value, aspect): # pylint: disable=unused-argument str_value = str(value) - match = re.match(Version.REGULAR, str_value) + match = re.match(Version.REGEX, str_value) if match is None: raise ValueError( 'version must be formatted as <major_version>.<minor_version>' @@ -376,11 +376,14 @@ class Scalar(object): def __init__(self, entry_schema, constraints, value, aspect): # pylint: disable=unused-argument str_value = str(value) - match = re.match(self.REGULAR, str_value) # pylint: disable=no-member + match = re.match(self.REGEX, str_value) # pylint: disable=no-member if match is None: raise ValueError('scalar must be formatted as <scalar> <unit>: %s' % safe_repr(value)) self.factor = float(match.group('scalar')) + if self.factor < 0: + raise ValueError('scalar is negative: %s' % safe_repr(self.factor)) + self.unit = match.group('unit') unit_lower = self.unit.lower() @@ -435,7 +438,7 @@ class ScalarSize(Scalar): """ # See: http://www.regular-expressions.info/floatingpoint.html - REGULAR = \ + REGEX = \ r'^(?P<scalar>[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s*(?P<unit>B|kB|KiB|MB|MiB|GB|GiB|TB|TiB)$' UNITS = { @@ -464,7 +467,7 @@ class ScalarTime(Scalar): """ # See: http://www.regular-expressions.info/floatingpoint.html - REGULAR = r'^(?P<scalar>[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s*(?P<unit>ns|us|ms|s|m|h|d)$' + REGEX = r'^(?P<scalar>[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s*(?P<unit>ns|us|ms|s|m|h|d)$' UNITS = { 'ns': 0.000000001, @@ -490,7 +493,7 @@ class ScalarFrequency(Scalar): """ # See: http://www.regular-expressions.info/floatingpoint.html - REGULAR = r'^(?P<scalar>[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s*(?P<unit>Hz|kHz|MHz|GHz)$' + REGEX = r'^(?P<scalar>[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s*(?P<unit>Hz|kHz|MHz|GHz)$' UNITS = { 'Hz': 1.0, http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/32891428/extensions/aria_extension_tosca/simple_v1_0/modeling/capabilities.py ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/capabilities.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/capabilities.py index 5427c7e..1b95bec 100644 --- a/extensions/aria_extension_tosca/simple_v1_0/modeling/capabilities.py +++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/capabilities.py @@ -68,12 +68,14 @@ def get_inherited_capability_definitions(context, presentation, for_presentation capability_definition = capability_definitions[capability_name] # Check if we changed the type - type1 = capability_definition.type - type2 = our_capability_definition.type - if type1 != type2: + type1 = capability_definition._get_type(context) + type2 = our_capability_definition._get_type(context) + + if not type1._is_descendant(context, type2): context.validation.report( - 'capability definition changes type from "{0}" to "{1}" in "{2}"' - .format(type1, type2, presentation._fullname), + 'capability definition type "{0}" is not a descendant of overridden ' + 'capability definition type "{1}"' \ + .format(type1._name, type2._name), locator=our_capability_definition._locator, level=Issue.BETWEEN_TYPES) merge_capability_definition(context, presentation, capability_definition, @@ -168,6 +170,8 @@ def merge_capability_definition(context, presentation, capability_definition, from_capability_definition): raw_properties = OrderedDict() + capability_definition._raw['type'] = from_capability_definition.type + # Merge properties from type from_property_defintions = from_capability_definition.properties merge_raw_parameter_definitions(context, presentation, raw_properties, from_property_defintions, http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/32891428/extensions/aria_extension_tosca/simple_v1_0/modeling/data_types.py ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/data_types.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/data_types.py index 9dee0f2..13ce9a3 100644 --- a/extensions/aria_extension_tosca/simple_v1_0/modeling/data_types.py +++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/data_types.py @@ -159,10 +159,6 @@ def get_data_type(context, presentation, field_name, allow_none=False): else: return str - # Make sure not derived from self - if type_name == presentation._name: - return None - # Avoid circular definitions container_data_type = get_container_data_type(presentation) if (container_data_type is not None) and (container_data_type._name == type_name): http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/32891428/extensions/aria_extension_tosca/simple_v1_0/modeling/functions.py ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/functions.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/functions.py index 590c6a0..ecbfde9 100644 --- a/extensions/aria_extension_tosca/simple_v1_0/modeling/functions.py +++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/functions.py @@ -200,20 +200,24 @@ class GetProperty(Function): for modelable_entity in modelable_entities: properties = None + # First argument refers to a requirement template? if hasattr(modelable_entity, 'requirement_templates') \ and modelable_entity.requirement_templates \ and (req_or_cap_name in [v.name for v in modelable_entity.requirement_templates]): - for requirement_template in modelable_entity.requirement_templates: - if requirement_template.name == req_or_cap_name: - # First argument refers to a requirement - # TODO: should follow to matched capability in other node... + for requirement in modelable_entity.requirement_templates: + if requirement.name == req_or_cap_name: + # TODO raise CannotEvaluateFunctionException() - # break + # First argument refers to a capability? + elif hasattr(modelable_entity, 'capabilities') \ + and modelable_entity.capabilities \ + and (req_or_cap_name in modelable_entity.capabilities): + properties = modelable_entity.capabilities[req_or_cap_name].properties nested_property_name_or_index = self.nested_property_name_or_index[1:] + # First argument refers to a capability template? elif hasattr(modelable_entity, 'capability_templates') \ and modelable_entity.capability_templates \ and (req_or_cap_name in modelable_entity.capability_templates): - # First argument refers to a capability properties = modelable_entity.capability_templates[req_or_cap_name].properties nested_property_name_or_index = self.nested_property_name_or_index[1:] else: @@ -640,7 +644,7 @@ def get_target(container_holder, name, locator): def get_modelable_entity_parameter(modelable_entity, parameters, nested_parameter_name_or_index): if not parameters: - return False, True, None + return Evaluation(None, True) found = True final = True http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/32891428/extensions/aria_extension_tosca/simple_v1_0/modeling/interfaces.py ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/interfaces.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/interfaces.py index fffd5c1..23a03b7 100644 --- a/extensions/aria_extension_tosca/simple_v1_0/modeling/interfaces.py +++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/interfaces.py @@ -400,13 +400,15 @@ def merge_raw_operation_definitions(context, raw_operations, our_operations, int def merge_interface_definition(context, interface, our_source, presentation, type_name): if hasattr(our_source, 'type'): # Check if we changed the interface type - input_type1 = interface.type - input_type2 = our_source.type - if (input_type1 is not None) and (input_type2 is not None) and (input_type1 != input_type2): + type1 = interface._get_type(context) + type2 = our_source._get_type(context) + + if (type2 is not None) and not type1._is_descendant(context, type2): context.validation.report( - 'interface definition "%s" changes type from "%s" to "%s" in "%s"' - % (interface._name, input_type1, input_type2, presentation._fullname), - locator=input_type2._locator, level=Issue.BETWEEN_TYPES) + 'interface definition type "{0}" is not a descendant of overridden ' + 'interface definition type "{1}"' \ + .format(type1._name, type2._name), + locator=our_source._locator, level=Issue.BETWEEN_TYPES) # Add/merge inputs our_interface_inputs = our_source._get_inputs(context) \ http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/32891428/extensions/aria_extension_tosca/simple_v1_0/modeling/parameters.py ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/parameters.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/parameters.py index f271b4d..5c14ad2 100644 --- a/extensions/aria_extension_tosca/simple_v1_0/modeling/parameters.py +++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/parameters.py @@ -18,7 +18,8 @@ from aria.utils.formatting import pluralize from aria.parser.presentation import Value from aria.parser.validation import Issue -from .data_types import coerce_value +from .data_types import (coerce_value, get_primitive_data_type) +from ..presentation.types import get_type_by_name # @@ -149,16 +150,22 @@ def validate_required_values(context, presentation, values, definitions): def merge_raw_parameter_definition(context, presentation, raw_property_definition, our_property_definition, field_name, property_name): - # Check if we changed the type - # TODO: allow a sub-type? - type1 = raw_property_definition.get('type') - type2 = our_property_definition.type + # Check if we changed the parameter type + type1_name = raw_property_definition.get('type') + type1 = get_type_by_name(context, type1_name, 'data_types') + if type1 is None: + type1 = get_primitive_data_type(type1_name) + our_property_definition._reset_method_cache() + type2 = our_property_definition._get_type(context) + if type1 != type2: - context.validation.report( - 'override changes type from "%s" to "%s" for property "%s" in "%s"' - % (type1, type2, property_name, presentation._fullname), - locator=presentation._get_child_locator(field_name, property_name), - level=Issue.BETWEEN_TYPES) + if not hasattr(type1, '_is_descendant') or not type1._is_descendant(context, type2): + context.validation.report( + 'property definition type "{0}" is not a descendant of overridden ' + 'property definition type "{1}"' \ + .format(type1_name, type2._name), + locator=presentation._get_child_locator(field_name, property_name), + level=Issue.BETWEEN_TYPES) merge(raw_property_definition, our_property_definition._raw) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/32891428/extensions/aria_extension_tosca/simple_v1_0/presentation/types.py ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/simple_v1_0/presentation/types.py b/extensions/aria_extension_tosca/simple_v1_0/presentation/types.py index 920ebed..5f9750e 100644 --- a/extensions/aria_extension_tosca/simple_v1_0/presentation/types.py +++ b/extensions/aria_extension_tosca/simple_v1_0/presentation/types.py @@ -18,7 +18,8 @@ def convert_name_to_full_type_name(context, name, types_dict): # pylint: disable """ Converts a type name to its full type name, or else returns it unchanged. - Works by checking for ``shorthand_name`` in the types' ``_extensions`` field. See also + Works by checking for ``shorthand_name`` and ``type_qualified_name`` in the types' + ``_extensions`` field. See also :class:`aria_extension_tosca.v1_0.presentation.extensible.ExtensiblePresentation`. Can be used as the conversion function argument in ``type_validator`` and @@ -36,9 +37,10 @@ def convert_name_to_full_type_name(context, name, types_dict): # pylint: disable def get_type_by_name(context, name, *types_dict_names): """ - Gets a type either by its full name or its shorthand name or typequalified name. + Gets a type either by its full name or its shorthand name or type-qualified name. - Works by checking for ``shorthand_name`` in the types' ``_extensions`` field. See also + Works by checking for ``shorthand_name`` and ``type_qualified_name`` in the types' + ``_extensions`` field. See also :class:`~aria_extension_tosca.v1_0.presentation.extensible.ExtensiblePresentation`. The arguments from the third onwards are used to locate a nested field under http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/32891428/extensions/aria_extension_tosca/simple_v1_0/types.py ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/simple_v1_0/types.py b/extensions/aria_extension_tosca/simple_v1_0/types.py index 787aac2..b662a20 100644 --- a/extensions/aria_extension_tosca/simple_v1_0/types.py +++ b/extensions/aria_extension_tosca/simple_v1_0/types.py @@ -193,6 +193,17 @@ class DataType(ExtensiblePresentation): return get_data_type(context, self, 'derived_from', allow_none=True) @cachedmethod + def _is_descendant(self, context, the_type): + if the_type is None: + return False + if not hasattr(the_type, '_name'): + # Must be a primitive type + return self._get_primitive_ancestor(context) == the_type + if the_type._name == self._name: + return True + return self._is_descendant(context, the_type._get_parent(context)) + + @cachedmethod def _get_primitive_ancestor(self, context): parent = self._get_parent(context) if parent is not None: @@ -387,6 +398,14 @@ class InterfaceType(ExtensiblePresentation): 'interface_types') @cachedmethod + def _is_descendant(self, context, the_type): + if the_type is None: + return False + elif the_type._name == self._name: + return True + return self._is_descendant(context, the_type._get_parent(context)) + + @cachedmethod def _get_inputs(self, context): return FrozenDict(get_inherited_parameter_definitions(context, self, 'inputs')) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/32891428/tests/end2end/test_hello_world.py ---------------------------------------------------------------------- diff --git a/tests/end2end/test_hello_world.py b/tests/end2end/test_hello_world.py index 5e4d7fd..094ffc3 100644 --- a/tests/end2end/test_hello_world.py +++ b/tests/end2end/test_hello_world.py @@ -20,7 +20,7 @@ from .. import helpers def test_hello_world(testenv): - hello_world_template_uri = helpers.get_example_uri('hello-world', 'helloworld.yaml') + hello_world_template_uri = helpers.get_example_uri('hello-world', 'hello-world.yaml') service_name = testenv.install_service(hello_world_template_uri) try: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/32891428/tests/resources/service-templates/tosca-simple-1.0/node-cellar/node-cellar.yaml ---------------------------------------------------------------------- diff --git a/tests/resources/service-templates/tosca-simple-1.0/node-cellar/node-cellar.yaml b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/node-cellar.yaml index 5a46532..260f0bf 100644 --- a/tests/resources/service-templates/tosca-simple-1.0/node-cellar/node-cellar.yaml +++ b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/node-cellar.yaml @@ -89,7 +89,7 @@ topology_template: value: *DEFAULT_OPENSTACK_CREDENTIAL node_templates: - + # Application node_cellar: @@ -135,7 +135,7 @@ topology_template: properties: protocol: udp url_path: /nodecellar - + node_cellar_database: description: >- Node Cellar MongoDB database. @@ -151,7 +151,7 @@ topology_template: repository: node_cellar # Server software - + nodejs: description: >- Node.js instance. @@ -202,7 +202,7 @@ topology_template: loadbalancer: type: nginx.LoadBalancer properties: - algorithm: round-robin + algorithm: round-robin # Hosts @@ -273,7 +273,7 @@ topology_template: create: create_data_volume.sh groups: - + node_cellar_group: type: openstack.Secured members: @@ -286,7 +286,7 @@ topology_template: openstack_credential: { get_input: openstack_credential } policies: - + app_scaling: type: aria.Scaling properties: @@ -295,7 +295,7 @@ topology_template: targets: - node_cellar - nodejs - + host_scaling: type: openstack.Scaling properties: @@ -304,7 +304,7 @@ topology_template: default_instances: 2 targets: # node templates or groups - node_cellar_group - + juju: description: >- Juju plugin executes charms. @@ -345,7 +345,7 @@ policy_types: description: >- Workflow to put all nodes in/out of maintenance mode. For web servers, this will show a "this site is under maintenance and we'll be back soon" web page. Database nodes will then close all - client connections cleanly and shut down services. + client connections cleanly and shut down services. derived_from: aria.Workflow properties: implementation: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/32891428/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/mongodb.yaml ---------------------------------------------------------------------- diff --git a/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/mongodb.yaml b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/mongodb.yaml index 34d0a9d..7031252 100644 --- a/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/mongodb.yaml +++ b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/mongodb.yaml @@ -44,7 +44,7 @@ node_types: mongodb.Database: description: >- MongoDB database. - + Supports importing database data if a mongodb.DatabaseDump is provided. derived_from: tosca.nodes.Database interfaces: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/32891428/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/nodejs.yaml ---------------------------------------------------------------------- diff --git a/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/nodejs.yaml b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/nodejs.yaml index 19cc7b9..2b4d451 100644 --- a/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/nodejs.yaml +++ b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/nodejs.yaml @@ -30,7 +30,7 @@ node_types: file: https://nodejs.org/dist/v4.4.7/node-v4.4.7-linux-x64.tar.xz deploy_path: /opt/nodejs capabilities: - data_endpoint: # @override + data_endpoint: # @override type: tosca.capabilities.Endpoint properties: port: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/32891428/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/openstack.yaml ---------------------------------------------------------------------- diff --git a/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/openstack.yaml b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/openstack.yaml index 99ee902..6941c1a 100644 --- a/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/openstack.yaml +++ b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/openstack.yaml @@ -31,7 +31,7 @@ node_types: You may assign an image_id or attach an openstack.Image artifact (the artifact will take precedence). - + You may assign either flavor_id or flavor_name (flavor_id will take precedence). If neither are assigned, flavor_name has a default value. derived_from: tosca.nodes.Compute @@ -87,7 +87,7 @@ node_types: openstack.Volume: description: >- OpenStack volume. - + See: http://developer.openstack.org/api-ref-blockstorage-v2.html derived_from: tosca.nodes.BlockStorage properties: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/32891428/tests/resources/service-templates/tosca-simple-1.0/types/shorthand-1/shorthand-1.yaml ---------------------------------------------------------------------- diff --git a/tests/resources/service-templates/tosca-simple-1.0/types/shorthand-1/shorthand-1.yaml b/tests/resources/service-templates/tosca-simple-1.0/types/shorthand-1/shorthand-1.yaml index b295f95..bb5a84e 100644 --- a/tests/resources/service-templates/tosca-simple-1.0/types/shorthand-1/shorthand-1.yaml +++ b/tests/resources/service-templates/tosca-simple-1.0/types/shorthand-1/shorthand-1.yaml @@ -6,17 +6,17 @@ description: >- topology_template: node_templates: - + my_server: type: Compute requirements: - local_storage: - node: my_block_storage + node: my_block_storage relationship: type: AttachesTo properties: location: /path1/path2 - + my_block_storage: type: BlockStorage properties: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/32891428/tests/resources/service-templates/tosca-simple-1.0/types/typequalified-1/typequalified-1.yaml ---------------------------------------------------------------------- diff --git a/tests/resources/service-templates/tosca-simple-1.0/types/typequalified-1/typequalified-1.yaml b/tests/resources/service-templates/tosca-simple-1.0/types/typequalified-1/typequalified-1.yaml index 5f11fd4..b54604f 100644 --- a/tests/resources/service-templates/tosca-simple-1.0/types/typequalified-1/typequalified-1.yaml +++ b/tests/resources/service-templates/tosca-simple-1.0/types/typequalified-1/typequalified-1.yaml @@ -6,17 +6,17 @@ description: >- topology_template: node_templates: - + my_server: type: tosca:Compute requirements: - local_storage: - node: my_block_storage + node: my_block_storage relationship: type: AttachesTo properties: location: /path1/path2 - + my_block_storage: type: tosca:BlockStorage properties:
