Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-106-Create-sqla-logging-handler d483195bd -> a9bd63da2 (forced update)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/787d7e7e/extensions/aria_extension_tosca/simple_v1_0/functions.py ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/simple_v1_0/functions.py b/extensions/aria_extension_tosca/simple_v1_0/functions.py index d17a960..e385817 100644 --- a/extensions/aria_extension_tosca/simple_v1_0/functions.py +++ b/extensions/aria_extension_tosca/simple_v1_0/functions.py @@ -171,15 +171,20 @@ class GetProperty(Function): def _evaluate(self, context, container): modelable_entities = get_modelable_entities(context, container, self.locator, self.modelable_entity_name) - req_or_cap_name = self.nested_property_name_or_index[0] for modelable_entity in modelable_entities: + properties = None + if hasattr(modelable_entity, 'requirement_templates') \ and modelable_entity.requirement_templates \ - and (req_or_cap_name in modelable_entity.requirement_templates): - # First argument refers to a requirement - properties = modelable_entity.requirement_templates[req_or_cap_name].properties + 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... + raise CannotEvaluateFunctionException() + break nested_property_name_or_index = self.nested_property_name_or_index[1:] elif hasattr(modelable_entity, 'capability_templates') \ and modelable_entity.capability_templates \ @@ -501,8 +506,7 @@ def get_host(context, container): # pylint: disable=unused-argument ends. """ - print container.relationships - exit() + return [] def get_source(context, container): # pylint: disable=unused-argument """ @@ -510,6 +514,8 @@ def get_source(context, container): # pylint: disable=unused-argument source end of the relationship that contains the referencing function. """ + return [] + def get_target(context, container): # pylint: disable=unused-argument """ A TOSCA orchestrator will interpret this keyword as the Node Template instance that is at the http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/787d7e7e/extensions/aria_extension_tosca/simple_v1_0/misc.py ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/simple_v1_0/misc.py b/extensions/aria_extension_tosca/simple_v1_0/misc.py index 4453c7a..42fc1ad 100644 --- a/extensions/aria_extension_tosca/simple_v1_0/misc.py +++ b/extensions/aria_extension_tosca/simple_v1_0/misc.py @@ -85,6 +85,7 @@ class MetaData(ExtensiblePresentation): :rtype: dict """ +@short_form_field('url') @has_fields @dsl_specification('3.5.5', 'tosca-simple-1.0') class Repository(ExtensiblePresentation): http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/787d7e7e/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py index 811da19..f340954 100644 --- a/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py +++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py @@ -22,6 +22,7 @@ from aria.parser.modeling import (Type, RelationshipType, PolicyType, ServiceMod ArtifactTemplate, Metadata, Parameter) from ..data_types import coerce_value +from platform import node def create_service_model(context): # pylint: disable=too-many-locals,too-many-branches model = ServiceModel() @@ -106,7 +107,8 @@ def create_service_model(context): # pylint: disable=too-many-locals,too-many-br return model def create_node_template(context, node_template): - model = NodeTemplate(name=node_template._name, type_name=node_template.type) + node_type = node_template._get_type(context) + model = NodeTemplate(name=node_template._name, type_name=node_type._name) if node_template.description: model.description = node_template.description.value @@ -137,12 +139,11 @@ def create_node_template(context, node_template): return model def create_interface_template(context, interface): - the_type = interface._get_type(context) + interface_type = interface._get_type(context) + model = InterfaceTemplate(name=interface._name, type_name=interface_type._name) - model = InterfaceTemplate(name=interface._name, type_name=the_type._name) - - if the_type.description: - model.description = the_type.description.value + if interface_type.description: + model.description = interface_type.description.value inputs = interface.inputs if inputs: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/787d7e7e/extensions/aria_extension_tosca/simple_v1_0/modeling/requirements.py ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/requirements.py b/extensions/aria_extension_tosca/simple_v1_0/modeling/requirements.py index 97e30ee..2a68da2 100644 --- a/extensions/aria_extension_tosca/simple_v1_0/modeling/requirements.py +++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/requirements.py @@ -171,7 +171,8 @@ def convert_requirement_from_definition_to_assignment(context, requirement_defin # Make sure the type is derived if not definition_relationship_type._is_descendant(context, relationship_type): context.validation.report( - 'assigned relationship type "%s" is not a descendant of declared relationship type "%s"' + 'assigned relationship type "%s" is not a descendant of declared relationship type' + ' "%s"' \ % (relationship_type._name, definition_relationship_type._name), locator=container._locator, level=Issue.BETWEEN_TYPES) @@ -189,11 +190,11 @@ def convert_requirement_from_definition_to_assignment(context, requirement_defin if relationship_template is not None: # Property values from template - raw['properties'] = relationship_template._get_property_values(context) + raw['relationship']['properties'] = relationship_template._get_property_values(context) else: if relationship_property_definitions: # Convert property definitions to values - raw['properties'] = \ + raw['relationship']['properties'] = \ convert_property_definitions_to_values(context, relationship_property_definitions) @@ -210,9 +211,9 @@ def convert_requirement_from_definition_to_assignment(context, requirement_defin if relationship_definition: # Merge extra interface definitions # InterfaceDefinition: - relationship_interface_definitions = relationship_definition.interfaces + definition_interface_definitions = relationship_definition.interfaces merge_interface_definitions(context, relationship_interface_definitions, - relationship_interface_definitions, requirement_definition, + definition_interface_definitions, requirement_definition, container) if relationship_template is not None: @@ -272,15 +273,10 @@ def merge_requirement_assignment(context, relationship_property_definitions, requirement._raw['node_filter'] = deepcopy_with_locators(our_node_filter._raw) our_relationship = our_requirement.relationship # RelationshipAssignment - if our_relationship is not None: + if (our_relationship is not None) and (our_relationship.type is None): # Make sure we have a dict if 'relationship' not in requirement._raw: requirement._raw['relationship'] = OrderedDict() - elif not isinstance(requirement._raw['relationship'], dict): - # Convert existing short form to long form - the_type = requirement._raw['relationship'] - requirement._raw['relationship'] = OrderedDict() - requirement._raw['relationship']['type'] = deepcopy_with_locators(the_type) merge_requirement_assignment_relationship(context, our_relationship, relationship_property_definitions, @@ -289,11 +285,6 @@ def merge_requirement_assignment(context, relationship_property_definitions, def merge_requirement_assignment_relationship(context, presentation, property_definitions, interface_definitions, requirement, our_relationship): - the_type = our_relationship.type - if the_type is not None: - # Could be a type or a template: - requirement._raw['relationship']['type'] = deepcopy_with_locators(the_type) - our_relationship_properties = our_relationship._raw.get('properties') if our_relationship_properties: # Make sure we have a dict @@ -310,7 +301,7 @@ def merge_requirement_assignment_relationship(context, presentation, property_de context.validation.report( 'relationship property "%s" not declared at definition of requirement "%s"' ' in "%s"' - % (property_name, presentation._fullname, + % (property_name, requirement._fullname, presentation._container._container._fullname), locator=our_relationship._get_child_locator('properties', property_name), level=Issue.BETWEEN_TYPES) @@ -333,9 +324,9 @@ def merge_requirement_assignment_relationship(context, presentation, property_de interface_definition, interface_name) else: context.validation.report( - 'interface definition "%s" not declared at definition of requirement "%s"' + 'relationship interface "%s" not declared at definition of requirement "%s"' ' in "%s"' - % (interface_name, presentation._fullname, + % (interface_name, requirement._fullname, presentation._container._container._fullname), locator=our_relationship._locator, level=Issue.BETWEEN_TYPES) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/787d7e7e/extensions/aria_extension_tosca/simple_v1_0/presentation/field_validators.py ---------------------------------------------------------------------- diff --git a/extensions/aria_extension_tosca/simple_v1_0/presentation/field_validators.py b/extensions/aria_extension_tosca/simple_v1_0/presentation/field_validators.py index f1b0a20..6ff4384 100644 --- a/extensions/aria_extension_tosca/simple_v1_0/presentation/field_validators.py +++ b/extensions/aria_extension_tosca/simple_v1_0/presentation/field_validators.py @@ -332,8 +332,8 @@ def node_template_or_type_validator(field, presentation, context): node_templates = \ context.presentation.get('service_template', 'topology_template', 'node_templates') \ or {} - node_types = context.presentation.get('service_template', 'node_types') or {} - if (value not in node_templates) and (value not in node_types): + if (value not in node_templates) and \ + (get_type_by_full_or_shorthand_name(context, value, 'node_types') is None): report_issue_for_unknown_type(context, presentation, 'node template or node type', field.name) @@ -358,8 +358,7 @@ def capability_definition_or_type_validator(field, presentation, context): if value in capabilities: return - capability_types = context.presentation.get('service_template', 'capability_types') - if (capability_types is not None) and (value in capability_types): + if get_type_by_full_or_shorthand_name(context, value, 'capability_types') is not None: if node is not None: context.validation.report( '"%s" refers to a capability type even though "node" has a value in "%s"' @@ -419,9 +418,8 @@ def relationship_template_or_type_validator(field, presentation, context): context.presentation.get('service_template', 'topology_template', 'relationship_templates') \ or {} - relationship_types = \ - context.presentation.get('service_template', 'relationship_types') or {} - if (value not in relationship_templates) and (value not in relationship_types): + if (value not in relationship_templates) and \ + (get_type_by_full_or_shorthand_name(context, value, 'relationship_types') is None): report_issue_for_unknown_type(context, presentation, 'relationship template or relationship type', field.name) @@ -442,9 +440,9 @@ def list_node_type_or_group_type_validator(field, presentation, context): values = getattr(presentation, field.name) if values is not None: for value in values: - node_types = context.presentation.get('service_template', 'node_types') or {} - group_types = context.presentation.get('service_template', 'group_types') or {} - if (value not in node_types) and (value not in group_types): + if \ + (get_type_by_full_or_shorthand_name(context, value, 'node_types') is None) and \ + (get_type_by_full_or_shorthand_name(context, value, 'group_types') is None): report_issue_for_unknown_type(context, presentation, 'node type or group type', field.name, value) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/787d7e7e/tests/end2end/test_parser.py ---------------------------------------------------------------------- diff --git a/tests/end2end/test_parser.py b/tests/end2end/test_parser.py deleted file mode 100644 index 7c243ab..0000000 --- a/tests/end2end/test_parser.py +++ /dev/null @@ -1,40 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. - -from tests.parser.service_templates import consume_node_cellar - - -def test_validation(): - consume_node_cellar('validate') - - -def test_validation_no_cache(): - consume_node_cellar('validate', False) - - -def test_presentation(): - consume_node_cellar('presentation') - - -def test_model(): - consume_node_cellar('model') - - -def test_types(): - consume_node_cellar('types') - - -def test_instance(): - consume_node_cellar('instance') http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/787d7e7e/tests/end2end/test_tosca_simple_v1_0.py ---------------------------------------------------------------------- diff --git a/tests/end2end/test_tosca_simple_v1_0.py b/tests/end2end/test_tosca_simple_v1_0.py new file mode 100644 index 0000000..f2a41ce --- /dev/null +++ b/tests/end2end/test_tosca_simple_v1_0.py @@ -0,0 +1,112 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. + +from tests.parser.service_templates import (consume_use_case, consume_node_cellar) + + +# Use Cases + +def test_use_case_compute_1(): + consume_use_case('compute-1', 'instance') + + +def test_use_case_software_component_1(): + consume_use_case('software-component-1', 'instance') + + +def test_use_case_block_storage_1(): + consume_use_case('block-storage-1', 'instance') + + +def test_use_case_block_storage_2(): + consume_use_case('block-storage-2', 'instance') + + +def test_use_case_block_storage_3(): + consume_use_case('block-storage-3', 'instance') + + +def test_use_case_block_storage_4(): + consume_use_case('block-storage-4', 'instance') + + +def test_use_case_block_storage_5(): + consume_use_case('block-storage-5', 'instance') + + +def test_use_case_block_storage_6(): + consume_use_case('block-storage-6', 'instance') + + +def test_use_case_object_storage_1(): + consume_use_case('object-storage-1', 'instance') + + +def test_use_case_network_1(): + consume_use_case('network-1', 'instance') + + +def test_use_case_network_2(): + consume_use_case('network-2', 'instance') + + +def test_use_case_network_3(): + consume_use_case('network-3', 'instance') + + +def test_use_case_network_4(): + consume_use_case('network-4', 'instance') + + +def test_use_case_webserver_dbms_1(): + consume_use_case('webserver-dbms-1', 'model') + + +def test_use_case_webserver_dbms_2(): + consume_use_case('webserver-dbms-2', 'instance') + + +def test_use_case_multi_tier_1(): + consume_use_case('multi-tier-1', 'instance') + + +def test_use_case_container_1(): + consume_use_case('container-1', 'model') + + +# NodeCellar + +def test_node_cellar_validation(): + consume_node_cellar('validate') + + +def test_node_cellar_validation_no_cache(): + consume_node_cellar('validate', False) + + +def test_node_cellar_presentation(): + consume_node_cellar('presentation') + + +def test_node_cellar_model(): + consume_node_cellar('model') + + +def test_node_cellar_types(): + consume_node_cellar('types') + + +def test_node_cellar_instance(): + consume_node_cellar('instance') http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/787d7e7e/tests/parser/service_templates.py ---------------------------------------------------------------------- diff --git a/tests/parser/service_templates.py b/tests/parser/service_templates.py index 8c361e6..a07fba8 100644 --- a/tests/parser/service_templates.py +++ b/tests/parser/service_templates.py @@ -15,14 +15,28 @@ from aria.utils.caching import cachedmethod -from .utils import (get_uri, create_context, create_consumer) +from .utils import (get_example_uri, get_test_uri, create_context, create_consumer) + + +def consume_use_case(use_case_name, consumer_class_name='instance', cache=True): + cachedmethod.ENABLED = cache + uri = get_example_uri('tosca-simple-1.0', 'use-cases', use_case_name, + '{0}.yaml'.format(use_case_name)) + context = create_context(uri) + #context.args.append('--inputs=' + get_example_uri('node-cellar', 'inputs.yaml')) + consumer, dumper = create_consumer(context, consumer_class_name) + consumer.consume() + context.validation.dump_issues() + assert not context.validation.has_issues + return context, dumper def consume_node_cellar(consumer_class_name='instance', cache=True): cachedmethod.ENABLED = cache - uri = get_uri('node-cellar', 'node-cellar.yaml') + uri = get_test_uri('tosca-simple-1.0', 'node-cellar', 'node-cellar.yaml') context = create_context(uri) - context.args.append('--inputs=' + get_uri('node-cellar', 'inputs.yaml')) + context.args.append('--inputs=' + get_test_uri('tosca-simple-1.0', 'node-cellar', + 'inputs.yaml')) consumer, dumper = create_consumer(context, consumer_class_name) consumer.consume() context.validation.dump_issues() http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/787d7e7e/tests/parser/utils.py ---------------------------------------------------------------------- diff --git a/tests/parser/utils.py b/tests/parser/utils.py index e55e6e5..994aac6 100644 --- a/tests/parser/utils.py +++ b/tests/parser/utils.py @@ -28,13 +28,18 @@ from aria.parser.consumption import ( ) from aria.utils.imports import import_fullname +from tests import ROOT_DIR from tests.resources import DIR -SERVICE_TEMPLATES_DIR = os.path.join(DIR, 'service_templates') +SERVICE_TEMPLATES_DIR = os.path.join(DIR, 'service-templates') -def get_uri(*args): +def get_example_uri(*args): + return os.path.join(ROOT_DIR, 'examples', *args) + + +def get_test_uri(*args): return os.path.join(SERVICE_TEMPLATES_DIR, *args) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/787d7e7e/tests/resources/service-templates/tosca-simple-1.0/node-cellar/inputs.yaml ---------------------------------------------------------------------- diff --git a/tests/resources/service-templates/tosca-simple-1.0/node-cellar/inputs.yaml b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/inputs.yaml new file mode 100644 index 0000000..37ab9ea --- /dev/null +++ b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/inputs.yaml @@ -0,0 +1,3 @@ +openstack_credential: + user: username + token: password http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/787d7e7e/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 new file mode 100644 index 0000000..3afcf5f --- /dev/null +++ b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/node-cellar.yaml @@ -0,0 +1,299 @@ +# +# Copyright (c) 2016 GigaSpaces Technologies Ltd. All rights reserved. +# +# 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. +# + +# NFV is not used here, but we are using it just to validate the imports +tosca_definitions_version: tosca_simple_profile_for_nfv_1_0 +#tosca_definitions_version: tosca_simple_yaml_1_0 + +description: >- + Node Cellar TOSCA blueprint. + Here is some Unicode: ä¸å. + +metadata: + template_name: node-cellar + template_author: ARIA + template_version: '1.0.0' + aria_version: '0.0' + +imports: + - types/openstack.yaml + - types/nodejs.yaml + - types/mongodb.yaml + - types/nginx.yaml + - types/aria.yaml + +dsl_definitions: + + default_openstack_credential: &DEFAULT_OPENSTACK_CREDENTIAL + user: openstackadmin + token: { concat: [ openstack, 123 ] } + +repositories: + + node_cellar: + description: >- + The repository for the Node Cellar application and its dependencies. + url: https://github.com/ccoenraets/nodecellar/archive/ + credential: + user: guest + token: '' + +interface_types: + + Maintenance: + derived_from: tosca.interfaces.Root + enable: {} + disable: {} + +node_types: + + NodeMongoApplication: + derived_from: nodejs.Application + interfaces: + Maintenance: + type: Maintenance + requirements: + - database: + capability: tosca.capabilities.Endpoint.Database + node: mongodb.Database + +topology_template: + + inputs: + openstack_credential: + type: openstack.Credential + value: *DEFAULT_OPENSTACK_CREDENTIAL + + node_templates: + + # Application + + node_cellar: + description: >- + Node Cellar Node.js web application. + type: NodeMongoApplication + artifacts: + node_cellar: + description: >- + The Node Cellar application package. + type: os.Archive + file: master.zip + repository: node_cellar + deploy_path: /opt/nodejs/applications/node-cellar + properties: + unpack_credential: + user: gigaspaces + token: { get_property: [ SELF, app_endpoint, protocol ] } + #token: { get_property: [ HOST, flavor_name ] } + interfaces: + Maintenance: + enable: juju > charm.maintenance_on + disable: juju > charm.maintenance_off + requirements: + - database: node_cellar_database + capabilities: + app_endpoint: + properties: + protocol: udp + url_path: /nodecellar + + node_cellar_database: + description: >- + Node Cellar MongoDB database. + type: mongodb.Database + properties: + name: node_cellar + artifacts: + initial: + description: >- + The Node Cellar initial database. + type: mongodb.DatabaseDump + file: node-cellar.json + repository: node_cellar + + # Server software + + nodejs: + description: >- + Node.js instance. + type: nodejs.Server + requirements: + - host: application_host + node_filter: # cannot be validated + properties: + #- flavor_name: { valid_values: [ {concat:[m1,.,small]} ] } # won't work because not validated :/ + - flavor_name: { valid_values: [ m1.small ] } + capabilities: + - scalable: + properties: + - max_instances: { greater_or_equal: 8 } + + mongodb: + description: >- + MongoDB instance. + type: mongodb.Server + requirements: + - host: + node: openstack.Instance + node_filter: + properties: + - flavor_name: { valid_values: [ m1.medium, { concat: [ { concat: [ m1, . ] }, large ] } ] } + #- flavor_name: { valid_values: [ m1.medium, m1.large ] } + capabilities: + - scalable: + properties: + - max_instances: { greater_or_equal: 8 } + + loadbalancer: + type: nginx.LoadBalancer + properties: + algorithm: round-robin + requirements: + - host: loadbalancer_host + + # Hosts + + loadbalancer_host: + description: >- + Host for the loadbalancer. + type: openstack.Instance + properties: + flavor_name: m1.small + os_users: # map of os.UserInfo + root: + password: admin123 + interfaces: + Standard: + inputs: + openstack_credential: { get_input: openstack_credential } + configure: juju > charm.loadbalancer + + application_host: + copy: loadbalancer_host + description: >- + Host for applications. + properties: + flavor_name: m1.small + os_users: # map of os.UserInfo + nodejs: + password: nodejs123 + groups: + - www-data + capabilities: + scalable: + properties: + max_instances: 10 + + data_host: + copy: loadbalancer_host + description: >- + Host for data. + properties: + flavor_name: m1.large + flavor_id: 5d62e82c-924e-4fa9-b1e4-c133867596f7 + os_users: # map of os.UserInfo + mongodb: + password: mongo123 + requirements: + - local_storage: + node: data_volume + relationship: + properties: + location: /mnt/volume + capabilities: + scalable: + properties: + max_instances: 10 + + data_volume: + type: openstack.Volume + properties: + size: 10 GB + interfaces: + Standard: + inputs: + openstack_credential: { get_input: openstack_credential } + + groups: + + node_cellar_group: + type: openstack.Secured + members: + - loadbalancer + - application_host + - data_host + interfaces: + Standard: + inputs: + openstack_credential: { get_input: openstack_credential } + + policies: + + scaling: + type: openstack.Scaling + properties: + bandwidth_threshold: 2 GB + targets: # node templates or groups + - node_cellar_group + + juju: + description: >- + Juju plugin executes charms. + type: aria.Plugin + properties: + executor: host_agent + install: false + + maintenance_on: + type: MaintenanceWorkflow + properties: + enabled: true + + maintenance_off: + type: MaintenanceWorkflow + properties: + enabled: false + + substitution_mappings: + + node_type: tosca.nodes.WebApplication + requirements: + host: [ node_cellar, host ] # doesn't really make sense; just for testing + capabilities: + app_endpoint: [ loadbalancer, client ] + +policy_types: + + MaintenanceWorkflow: + 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. + derived_from: aria.Workflow + properties: + function: # @override + type: string + default: workflows.maintenance + implementation: + type: string + default: tests/resources/service-templates/tosca-simple-1.0/node-cellar + enabled: + description: >- + Whether to turn maintenance mode on or off. + type: boolean + #ctx: + # type: string + # default: abc http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/787d7e7e/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/aria.yaml ---------------------------------------------------------------------- diff --git a/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/aria.yaml b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/aria.yaml new file mode 100644 index 0000000..2ddb238 --- /dev/null +++ b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/aria.yaml @@ -0,0 +1,93 @@ + +policy_types: + + aria.Plugin: + _extensions: + role: plugin + description: >- + ARIA Plugin definition. + derived_from: tosca.policies.Root + properties: + executor: + description: >- + Where to execute the plugin's operations. + type: string + constraints: + - valid_values: [ central_deployment_agent, host_agent ] + source: + description: >- + Where to execute the plugin's operations. Where to retrieve the plugin from. Could be + either a path relative to the plugins dir inside the blueprint's root dir or a url. If + install is false, source is redundant. If install is true, source (or package_name) is + mandatory. + type: string + required: false + install_arguments: + description: >- + Optional arguments passed to the 'pip install' command created for the plugin + installation. + type: string + required: false + install: + description: >- + Whether to install the plugin or not as it might already be installed as part of the + agent. + type: boolean + default: true + package_name: + description: >- + Managed plugin package name. If install is false, package_name is redundant. If install is + true, package_name (or source) is mandatory. + type: string + required: false + package_version: + description: >- + Managed plugin package version. + type: string + required: false + supported_platform: + description: >- + Managed plugin supported platform (e.g. linux_x86_64). + type: string + required: false + supported_distribution: + description: >- + Managed plugin distribution. + type: string + required: false + distribution_version: + description: >- + Managed plugin distribution version. + type: string + required: false + distribution_release: + description: >- + Managed plugin distribution release. + type: string + required: false + + aria.Workflow: + _extensions: + role: workflow + description: >- + ARIA Workflow definition. + derived_from: tosca.policies.Root + properties: + function: + description: >- + Python workflow function. + type: string + implementation: + description: >- + The implementation artifact name (i.e., the primary script file name within a TOSCA CSAR + file). + type: string + required: false + dependencies: + description: >- + The optional ordered list of one or more dependent or secondary implementation artifact + name which are referenced by the primary implementation artifact (e.g., a library the + script installs or a secondary script). + type: list + entry_schema: string + required: false http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/787d7e7e/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 new file mode 100644 index 0000000..612dbcb --- /dev/null +++ b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/mongodb.yaml @@ -0,0 +1,73 @@ +# +# Copyright (c) 2016 GigaSpaces Technologies Ltd. All rights reserved. +# +# 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. +# + +imports: + - os.yaml + +node_types: + + mongodb.Server: + description: >- + MongoDB server application. + derived_from: tosca.nodes.DBMS + properties: + root_password: # @override + type: string + default: admin + port: # @override + type: integer + default: 27017 + artifacts: + mongodb: + description: >- + MongoDB application package. + type: os.Archive + file: https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1604-3.2.8.tgz + deploy_path: /opt/mongodb + capabilities: + host: # @override + type: tosca.capabilities.Container + valid_source_types: [ mongodb.Database ] + + mongodb.Database: + description: >- + MongoDB database. + + Supports importing database data if a mongodb.DatabaseDump is provided. + derived_from: tosca.nodes.Database + interfaces: + Standard: + type: tosca.interfaces.node.lifecycle.Standard + create: + implementation: + primary: mongodb/create_and_import_database.sh + dependencies: + - mongodb/utils/api.sh + - utils/os.sh + requirements: + - host: # @override + capability: tosca.capabilities.Container + node: mongodb.Server + relationship: tosca.relationships.HostedOn + +artifact_types: + + mongodb.DatabaseDump: + description: >- + Dump of a MongoDB database. + derived_from: tosca.artifacts.Root + file_ext: + - json http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/787d7e7e/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/nginx.yaml ---------------------------------------------------------------------- diff --git a/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/nginx.yaml b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/nginx.yaml new file mode 100644 index 0000000..8986a21 --- /dev/null +++ b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/nginx.yaml @@ -0,0 +1,27 @@ +# +# Copyright (c) 2016 GigaSpaces Technologies Ltd. All rights reserved. +# +# 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. +# + +node_types: + + nginx.LoadBalancer: + description: >- + Nginx as a loadbalancer. + derived_from: tosca.nodes.LoadBalancer + requirements: + - host: + capability: tosca.capabilities.Container + node: tosca.nodes.Compute + relationship: tosca.relationships.HostedOn http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/787d7e7e/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 new file mode 100644 index 0000000..ec8dd83 --- /dev/null +++ b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/nodejs.yaml @@ -0,0 +1,69 @@ +# +# Copyright (c) 2016 GigaSpaces Technologies Ltd. All rights reserved. +# +# 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. +# + +imports: + - os.yaml + +node_types: + + nodejs.Server: + description: >- + Node.js server application. + derived_from: tosca.nodes.WebServer + artifacts: + nodejs: + description: >- + Node.js application package. + type: os.Archive + file: https://nodejs.org/dist/v4.4.7/node-v4.4.7-linux-x64.tar.xz + deploy_path: /opt/nodejs + capabilities: + data_endpoint: # @override + type: tosca.capabilities.Endpoint + properties: + port: + type: tosca.datatypes.network.PortDef + default: 8080 + url_path: + type: string + default: / + admin_endpoint: # @override + type: tosca.capabilities.Endpoint.Admin + properties: + port: + type: tosca.datatypes.network.PortDef + default: 8080 + url_path: + type: string + default: /admin + host: # @override + type: tosca.capabilities.Container + valid_source_types: [ nodejs.Application ] + + nodejs.Application: + derived_from: tosca.nodes.WebApplication + capabilities: + app_endpoint: # @override + type: tosca.capabilities.Endpoint + properties: + port: + type: tosca.datatypes.network.PortDef + default: 8080 + requirements: + - host: # @override + capability: tosca.capabilities.Container + node: nodejs.Server + relationship: tosca.relationships.HostedOn http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/787d7e7e/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 new file mode 100644 index 0000000..a18da53 --- /dev/null +++ b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/openstack.yaml @@ -0,0 +1,201 @@ +# +# Copyright (c) 2016 GigaSpaces Technologies Ltd. All rights reserved. +# +# 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. +# + +imports: + - os.yaml + +dsl_definitions: + + openstack: + uuid_constraints: &OPENSTACK_UUID_CONSTRAINTS + - pattern: '^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$' + +node_types: + + openstack.Instance: + description: >- + OpenStack instance. + + 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 + properties: + image_id: + description: >- + See: https://s3itwiki.uzh.ch/display/clouddoc/Supported+Images + type: openstack.UUID + default: 5d62e82c-924e-4fa9-b1e4-c133867596f7 + flavor_id: + type: openstack.UUID + required: false + flavor_name: + type: string + default: m1.medium + required: false + availability_zone: + description: >- + OpenStack availability zone. + type: string + required: false + os_users: + type: map + entry_schema: os.UserInfo + interfaces: + Standard: + type: tosca.interfaces.node.lifecycle.Standard + inputs: + openstack_credential: + description: The OpenStack API credential for all operations. + type: openstack.Credential + create: + implementation: + primary: openstack/create_instance.sh + dependencies: + - openstack/utils/api.sh + - utils/os.sh + requirements: + - local_storage: # @override + capability: tosca.capabilities.Attachment + node: openstack.Volume + relationship: tosca.relationships.AttachesTo +# relationship: +# type: tosca.relationships.AttachesTo +# interfaces: +# Standard: +# inputs: +# xxx: +# type: string +# default: { concat: [ a, b ] } + occurrences: [ 0, UNBOUNDED ] + + openstack.Volume: + description: >- + OpenStack volume. + + See: http://developer.openstack.org/api-ref-blockstorage-v2.html + derived_from: tosca.nodes.BlockStorage + properties: + tenant_id: + type: openstack.UUID + required: false + availability_zone: + type: string + required: false + source_volid: + type: openstack.UUID + required: false + description: + type: string + required: false + multiattach: + type: boolean + default: false + #snapshot_id: # @override + # type: openstack.UUID + # required: false + name: + type: string + required: false + volume_type: + type: string + required: false + metadata: + type: map + entry_schema: string + required: false + source_replica: + type: openstack.UUID + required: false + consistencygroup_id: + type: openstack.UUID + required: false + scheduler_hints: + type: map + entry_schema: string + required: false + interfaces: + Standard: + type: tosca.interfaces.node.lifecycle.Standard + inputs: + openstack_credential: + description: The OpenStack API credential for all operations. + type: openstack.Credential + create: + implementation: + primary: openstack/create_volume.sh + dependencies: + - openstack/utils/api.sh + - utils/os.sh + +group_types: + + openstack.Secured: + description: >- + OpenStack secured group. + derived_from: tosca.groups.Root + members: + - openstack.Instance + interfaces: + Standard: + type: tosca.interfaces.node.lifecycle.Standard + inputs: + openstack_credential: + description: The OpenStack API credential for all operations. + type: openstack.Credential + create: + implementation: + primary: openstack/create_secured_group.sh + dependencies: + - openstack/utils/api.sh + - utils/os.sh + +policy_types: + + openstack.Scaling: + description: >- + OpenStack scaling policy. + derived_from: tosca.policies.Scaling + properties: + bandwidth_threshold: + type: scalar-unit.size + default: 1 GB + targets: + - openstack.Instance + - openstack.Secured + +data_types: + + openstack.Credential: + derived_from: tosca.datatypes.Credential + + openstack.UUID: + description: >- + OpenStack UUID (in GUID format). + derived_from: string + constraints: *OPENSTACK_UUID_CONSTRAINTS + +artifact_types: + + openstack.Image: + description: >- + OpenStack image artifact. + derived_from: tosca.artifacts.Deployment.Image.VM + file_ext: + - img + - iso http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/787d7e7e/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/os.yaml ---------------------------------------------------------------------- diff --git a/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/os.yaml b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/os.yaml new file mode 100644 index 0000000..43ea78c --- /dev/null +++ b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/types/os.yaml @@ -0,0 +1,75 @@ +# +# Copyright (c) 2016 GigaSpaces Technologies Ltd. All rights reserved. +# +# 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. +# + +dsl_definitions: + + os: + user_and_group_name_constraints: &OS_USER_AND_GROUP_NAME_CONSTRAINTS + - pattern: '^[a-z0-9_-]{3,16}$' + password_constraints: &OS_PASSWORD_CONSTRAINTS + - pattern: '^[a-z0-9_-]{6,18}$' + +artifact_types: + + os.Package: + description: >- + Generic application package. + derived_from: tosca.artifacts.Root + + os.Archive: + description: >- + Application package in an archive. + derived_from: os.Package + file_ext: + - zip + - tar + - tar.gz + - tar.xz + properties: + unpack_credential: + type: tosca.datatypes.Credential + required: false + + os.Deb: + description: >- + Debian application package. + derived_from: os.Package + file_ext: + - deb + + os.RPM: + description: >- + RPM application package. + derived_from: os.Package + file_ext: + - rpm + +data_types: + + os.UserInfo: + description: >- + Information about an operating system user. + derived_from: tosca.datatypes.Root + properties: + password: + type: string + constraints: *OS_PASSWORD_CONSTRAINTS + groups: + type: list + entry_schema: + type: string + constraints: *OS_USER_AND_GROUP_NAME_CONSTRAINTS + required: false http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/787d7e7e/tests/resources/service-templates/tosca-simple-1.0/node-cellar/workflows.py ---------------------------------------------------------------------- diff --git a/tests/resources/service-templates/tosca-simple-1.0/node-cellar/workflows.py b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/workflows.py new file mode 100644 index 0000000..fff78bf --- /dev/null +++ b/tests/resources/service-templates/tosca-simple-1.0/node-cellar/workflows.py @@ -0,0 +1,16 @@ + +from aria import workflow +from aria.orchestrator.workflows.api.task import OperationTask + + +@workflow +def maintenance(ctx, graph, enabled): + """ + Custom workflow to call the operations on the Maintenance interface. + """ + + operation = 'Maintenance.enable' if enabled else 'Maintenance.disable' + + for node in ctx.model.node.iter(): + for interface in node.interfaces.filter_by(name='Maintenance', type_name='Maintenance'): + graph.add_tasks(OperationTask.node(instance=node, name=operation)) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/787d7e7e/tests/resources/service_templates/node-cellar/inputs.yaml ---------------------------------------------------------------------- diff --git a/tests/resources/service_templates/node-cellar/inputs.yaml b/tests/resources/service_templates/node-cellar/inputs.yaml deleted file mode 100644 index 37ab9ea..0000000 --- a/tests/resources/service_templates/node-cellar/inputs.yaml +++ /dev/null @@ -1,3 +0,0 @@ -openstack_credential: - user: username - token: password http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/787d7e7e/tests/resources/service_templates/node-cellar/node-cellar.yaml ---------------------------------------------------------------------- diff --git a/tests/resources/service_templates/node-cellar/node-cellar.yaml b/tests/resources/service_templates/node-cellar/node-cellar.yaml deleted file mode 100644 index 3e579bd..0000000 --- a/tests/resources/service_templates/node-cellar/node-cellar.yaml +++ /dev/null @@ -1,299 +0,0 @@ -# -# Copyright (c) 2016 GigaSpaces Technologies Ltd. All rights reserved. -# -# 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. -# - -# NFV is not used here, but we are using it just to validate the imports -tosca_definitions_version: tosca_simple_profile_for_nfv_1_0 -#tosca_definitions_version: tosca_simple_yaml_1_0 - -description: >- - Node Cellar TOSCA blueprint. - Here is some Unicode: ä¸å. - -metadata: - template_name: node-cellar - template_author: ARIA - template_version: '1.0.0' - aria_version: '0.0' - -imports: - - types/openstack.yaml - - types/nodejs.yaml - - types/mongodb.yaml - - types/nginx.yaml - - types/aria.yaml - -dsl_definitions: - - default_openstack_credential: &DEFAULT_OPENSTACK_CREDENTIAL - user: openstackadmin - token: { concat: [ openstack, 123 ] } - -repositories: - - node_cellar: - description: >- - The repository for the Node Cellar application and its dependencies. - url: https://github.com/ccoenraets/nodecellar/archive/ - credential: - user: guest - token: '' - -interface_types: - - Maintenance: - derived_from: tosca.interfaces.Root - enable: {} - disable: {} - -node_types: - - NodeMongoApplication: - derived_from: nodejs.Application - interfaces: - Maintenance: - type: Maintenance - requirements: - - database: - capability: tosca.capabilities.Endpoint.Database - node: mongodb.Database - -topology_template: - - inputs: - openstack_credential: - type: openstack.Credential - value: *DEFAULT_OPENSTACK_CREDENTIAL - - node_templates: - - # Application - - node_cellar: - description: >- - Node Cellar Node.js web application. - type: NodeMongoApplication - artifacts: - node_cellar: - description: >- - The Node Cellar application package. - type: os.Archive - file: master.zip - repository: node_cellar - deploy_path: /opt/nodejs/applications/node-cellar - properties: - unpack_credential: - user: gigaspaces - token: { get_property: [ SELF, app_endpoint, protocol ] } - #token: { get_property: [ HOST, flavor_name ] } - interfaces: - Maintenance: - enable: juju > charm.maintenance_on - disable: juju > charm.maintenance_off - requirements: - - database: node_cellar_database - capabilities: - app_endpoint: - properties: - protocol: udp - url_path: /nodecellar - - node_cellar_database: - description: >- - Node Cellar MongoDB database. - type: mongodb.Database - properties: - name: node_cellar - artifacts: - initial: - description: >- - The Node Cellar initial database. - type: mongodb.DatabaseDump - file: node-cellar.json - repository: node_cellar - - # Server software - - nodejs: - description: >- - Node.js instance. - type: nodejs.Server - requirements: - - host: application_host - node_filter: # cannot be validated - properties: - #- flavor_name: { valid_values: [ {concat:[m1,.,small]} ] } # won't work because not validated :/ - - flavor_name: { valid_values: [ m1.small ] } - capabilities: - - scalable: - properties: - - max_instances: { greater_or_equal: 8 } - - mongodb: - description: >- - MongoDB instance. - type: mongodb.Server - requirements: - - host: - node: openstack.Instance - node_filter: - properties: - - flavor_name: { valid_values: [ m1.medium, { concat: [ { concat: [ m1, . ] }, large ] } ] } - #- flavor_name: { valid_values: [ m1.medium, m1.large ] } - capabilities: - - scalable: - properties: - - max_instances: { greater_or_equal: 8 } - - loadbalancer: - type: nginx.LoadBalancer - properties: - algorithm: round-robin - requirements: - - host: loadbalancer_host - - # Hosts - - loadbalancer_host: - description: >- - Host for the loadbalancer. - type: openstack.Instance - properties: - flavor_name: m1.small - os_users: # map of os.UserInfo - root: - password: admin123 - interfaces: - Standard: - inputs: - openstack_credential: { get_input: openstack_credential } - configure: juju > charm.loadbalancer - - application_host: - copy: loadbalancer_host - description: >- - Host for applications. - properties: - flavor_name: m1.small - os_users: # map of os.UserInfo - nodejs: - password: nodejs123 - groups: - - www-data - capabilities: - scalable: - properties: - max_instances: 10 - - data_host: - copy: loadbalancer_host - description: >- - Host for data. - properties: - flavor_name: m1.large - flavor_id: 5d62e82c-924e-4fa9-b1e4-c133867596f7 - os_users: # map of os.UserInfo - mongodb: - password: mongo123 - requirements: - - local_storage: - node: data_volume - relationship: - properties: - location: /mnt/volume - capabilities: - scalable: - properties: - max_instances: 10 - - data_volume: - type: openstack.Volume - properties: - size: 10 GB - interfaces: - Standard: - inputs: - openstack_credential: { get_input: openstack_credential } - - groups: - - node_cellar_group: - type: openstack.Secured - members: - - loadbalancer - - application_host - - data_host - interfaces: - Standard: - inputs: - openstack_credential: { get_input: openstack_credential } - - policies: - - scaling: - type: openstack.Scaling - properties: - bandwidth_threshold: 2 GB - targets: # node templates or groups - - node_cellar_group - - juju: - description: >- - Juju plugin executes charms. - type: aria.Plugin - properties: - executor: host_agent - install: false - - maintenance_on: - type: MaintenanceWorkflow - properties: - enabled: true - - maintenance_off: - type: MaintenanceWorkflow - properties: - enabled: false - - substitution_mappings: - - node_type: tosca.nodes.WebApplication - requirements: - host: [ node_cellar, host ] # doesn't really make sense; just for testing - capabilities: - app_endpoint: [ loadbalancer, client ] - -policy_types: - - MaintenanceWorkflow: - 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. - derived_from: aria.Workflow - properties: - function: # @override - type: string - default: workflows.maintenance - implementation: - type: string - default: tests/resources/service_templates/node-cellar - enabled: - description: >- - Whether to turn maintenance mode on or off. - type: boolean - #ctx: - # type: string - # default: abc http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/787d7e7e/tests/resources/service_templates/node-cellar/types/aria.yaml ---------------------------------------------------------------------- diff --git a/tests/resources/service_templates/node-cellar/types/aria.yaml b/tests/resources/service_templates/node-cellar/types/aria.yaml deleted file mode 100644 index 2ddb238..0000000 --- a/tests/resources/service_templates/node-cellar/types/aria.yaml +++ /dev/null @@ -1,93 +0,0 @@ - -policy_types: - - aria.Plugin: - _extensions: - role: plugin - description: >- - ARIA Plugin definition. - derived_from: tosca.policies.Root - properties: - executor: - description: >- - Where to execute the plugin's operations. - type: string - constraints: - - valid_values: [ central_deployment_agent, host_agent ] - source: - description: >- - Where to execute the plugin's operations. Where to retrieve the plugin from. Could be - either a path relative to the plugins dir inside the blueprint's root dir or a url. If - install is false, source is redundant. If install is true, source (or package_name) is - mandatory. - type: string - required: false - install_arguments: - description: >- - Optional arguments passed to the 'pip install' command created for the plugin - installation. - type: string - required: false - install: - description: >- - Whether to install the plugin or not as it might already be installed as part of the - agent. - type: boolean - default: true - package_name: - description: >- - Managed plugin package name. If install is false, package_name is redundant. If install is - true, package_name (or source) is mandatory. - type: string - required: false - package_version: - description: >- - Managed plugin package version. - type: string - required: false - supported_platform: - description: >- - Managed plugin supported platform (e.g. linux_x86_64). - type: string - required: false - supported_distribution: - description: >- - Managed plugin distribution. - type: string - required: false - distribution_version: - description: >- - Managed plugin distribution version. - type: string - required: false - distribution_release: - description: >- - Managed plugin distribution release. - type: string - required: false - - aria.Workflow: - _extensions: - role: workflow - description: >- - ARIA Workflow definition. - derived_from: tosca.policies.Root - properties: - function: - description: >- - Python workflow function. - type: string - implementation: - description: >- - The implementation artifact name (i.e., the primary script file name within a TOSCA CSAR - file). - type: string - required: false - dependencies: - description: >- - The optional ordered list of one or more dependent or secondary implementation artifact - name which are referenced by the primary implementation artifact (e.g., a library the - script installs or a secondary script). - type: list - entry_schema: string - required: false http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/787d7e7e/tests/resources/service_templates/node-cellar/types/mongodb.yaml ---------------------------------------------------------------------- diff --git a/tests/resources/service_templates/node-cellar/types/mongodb.yaml b/tests/resources/service_templates/node-cellar/types/mongodb.yaml deleted file mode 100644 index 612dbcb..0000000 --- a/tests/resources/service_templates/node-cellar/types/mongodb.yaml +++ /dev/null @@ -1,73 +0,0 @@ -# -# Copyright (c) 2016 GigaSpaces Technologies Ltd. All rights reserved. -# -# 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. -# - -imports: - - os.yaml - -node_types: - - mongodb.Server: - description: >- - MongoDB server application. - derived_from: tosca.nodes.DBMS - properties: - root_password: # @override - type: string - default: admin - port: # @override - type: integer - default: 27017 - artifacts: - mongodb: - description: >- - MongoDB application package. - type: os.Archive - file: https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1604-3.2.8.tgz - deploy_path: /opt/mongodb - capabilities: - host: # @override - type: tosca.capabilities.Container - valid_source_types: [ mongodb.Database ] - - mongodb.Database: - description: >- - MongoDB database. - - Supports importing database data if a mongodb.DatabaseDump is provided. - derived_from: tosca.nodes.Database - interfaces: - Standard: - type: tosca.interfaces.node.lifecycle.Standard - create: - implementation: - primary: mongodb/create_and_import_database.sh - dependencies: - - mongodb/utils/api.sh - - utils/os.sh - requirements: - - host: # @override - capability: tosca.capabilities.Container - node: mongodb.Server - relationship: tosca.relationships.HostedOn - -artifact_types: - - mongodb.DatabaseDump: - description: >- - Dump of a MongoDB database. - derived_from: tosca.artifacts.Root - file_ext: - - json http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/787d7e7e/tests/resources/service_templates/node-cellar/types/nginx.yaml ---------------------------------------------------------------------- diff --git a/tests/resources/service_templates/node-cellar/types/nginx.yaml b/tests/resources/service_templates/node-cellar/types/nginx.yaml deleted file mode 100644 index 8986a21..0000000 --- a/tests/resources/service_templates/node-cellar/types/nginx.yaml +++ /dev/null @@ -1,27 +0,0 @@ -# -# Copyright (c) 2016 GigaSpaces Technologies Ltd. All rights reserved. -# -# 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. -# - -node_types: - - nginx.LoadBalancer: - description: >- - Nginx as a loadbalancer. - derived_from: tosca.nodes.LoadBalancer - requirements: - - host: - capability: tosca.capabilities.Container - node: tosca.nodes.Compute - relationship: tosca.relationships.HostedOn http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/787d7e7e/tests/resources/service_templates/node-cellar/types/nodejs.yaml ---------------------------------------------------------------------- diff --git a/tests/resources/service_templates/node-cellar/types/nodejs.yaml b/tests/resources/service_templates/node-cellar/types/nodejs.yaml deleted file mode 100644 index ec8dd83..0000000 --- a/tests/resources/service_templates/node-cellar/types/nodejs.yaml +++ /dev/null @@ -1,69 +0,0 @@ -# -# Copyright (c) 2016 GigaSpaces Technologies Ltd. All rights reserved. -# -# 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. -# - -imports: - - os.yaml - -node_types: - - nodejs.Server: - description: >- - Node.js server application. - derived_from: tosca.nodes.WebServer - artifacts: - nodejs: - description: >- - Node.js application package. - type: os.Archive - file: https://nodejs.org/dist/v4.4.7/node-v4.4.7-linux-x64.tar.xz - deploy_path: /opt/nodejs - capabilities: - data_endpoint: # @override - type: tosca.capabilities.Endpoint - properties: - port: - type: tosca.datatypes.network.PortDef - default: 8080 - url_path: - type: string - default: / - admin_endpoint: # @override - type: tosca.capabilities.Endpoint.Admin - properties: - port: - type: tosca.datatypes.network.PortDef - default: 8080 - url_path: - type: string - default: /admin - host: # @override - type: tosca.capabilities.Container - valid_source_types: [ nodejs.Application ] - - nodejs.Application: - derived_from: tosca.nodes.WebApplication - capabilities: - app_endpoint: # @override - type: tosca.capabilities.Endpoint - properties: - port: - type: tosca.datatypes.network.PortDef - default: 8080 - requirements: - - host: # @override - capability: tosca.capabilities.Container - node: nodejs.Server - relationship: tosca.relationships.HostedOn http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/787d7e7e/tests/resources/service_templates/node-cellar/types/openstack.yaml ---------------------------------------------------------------------- diff --git a/tests/resources/service_templates/node-cellar/types/openstack.yaml b/tests/resources/service_templates/node-cellar/types/openstack.yaml deleted file mode 100644 index a18da53..0000000 --- a/tests/resources/service_templates/node-cellar/types/openstack.yaml +++ /dev/null @@ -1,201 +0,0 @@ -# -# Copyright (c) 2016 GigaSpaces Technologies Ltd. All rights reserved. -# -# 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. -# - -imports: - - os.yaml - -dsl_definitions: - - openstack: - uuid_constraints: &OPENSTACK_UUID_CONSTRAINTS - - pattern: '^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$' - -node_types: - - openstack.Instance: - description: >- - OpenStack instance. - - 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 - properties: - image_id: - description: >- - See: https://s3itwiki.uzh.ch/display/clouddoc/Supported+Images - type: openstack.UUID - default: 5d62e82c-924e-4fa9-b1e4-c133867596f7 - flavor_id: - type: openstack.UUID - required: false - flavor_name: - type: string - default: m1.medium - required: false - availability_zone: - description: >- - OpenStack availability zone. - type: string - required: false - os_users: - type: map - entry_schema: os.UserInfo - interfaces: - Standard: - type: tosca.interfaces.node.lifecycle.Standard - inputs: - openstack_credential: - description: The OpenStack API credential for all operations. - type: openstack.Credential - create: - implementation: - primary: openstack/create_instance.sh - dependencies: - - openstack/utils/api.sh - - utils/os.sh - requirements: - - local_storage: # @override - capability: tosca.capabilities.Attachment - node: openstack.Volume - relationship: tosca.relationships.AttachesTo -# relationship: -# type: tosca.relationships.AttachesTo -# interfaces: -# Standard: -# inputs: -# xxx: -# type: string -# default: { concat: [ a, b ] } - occurrences: [ 0, UNBOUNDED ] - - openstack.Volume: - description: >- - OpenStack volume. - - See: http://developer.openstack.org/api-ref-blockstorage-v2.html - derived_from: tosca.nodes.BlockStorage - properties: - tenant_id: - type: openstack.UUID - required: false - availability_zone: - type: string - required: false - source_volid: - type: openstack.UUID - required: false - description: - type: string - required: false - multiattach: - type: boolean - default: false - #snapshot_id: # @override - # type: openstack.UUID - # required: false - name: - type: string - required: false - volume_type: - type: string - required: false - metadata: - type: map - entry_schema: string - required: false - source_replica: - type: openstack.UUID - required: false - consistencygroup_id: - type: openstack.UUID - required: false - scheduler_hints: - type: map - entry_schema: string - required: false - interfaces: - Standard: - type: tosca.interfaces.node.lifecycle.Standard - inputs: - openstack_credential: - description: The OpenStack API credential for all operations. - type: openstack.Credential - create: - implementation: - primary: openstack/create_volume.sh - dependencies: - - openstack/utils/api.sh - - utils/os.sh - -group_types: - - openstack.Secured: - description: >- - OpenStack secured group. - derived_from: tosca.groups.Root - members: - - openstack.Instance - interfaces: - Standard: - type: tosca.interfaces.node.lifecycle.Standard - inputs: - openstack_credential: - description: The OpenStack API credential for all operations. - type: openstack.Credential - create: - implementation: - primary: openstack/create_secured_group.sh - dependencies: - - openstack/utils/api.sh - - utils/os.sh - -policy_types: - - openstack.Scaling: - description: >- - OpenStack scaling policy. - derived_from: tosca.policies.Scaling - properties: - bandwidth_threshold: - type: scalar-unit.size - default: 1 GB - targets: - - openstack.Instance - - openstack.Secured - -data_types: - - openstack.Credential: - derived_from: tosca.datatypes.Credential - - openstack.UUID: - description: >- - OpenStack UUID (in GUID format). - derived_from: string - constraints: *OPENSTACK_UUID_CONSTRAINTS - -artifact_types: - - openstack.Image: - description: >- - OpenStack image artifact. - derived_from: tosca.artifacts.Deployment.Image.VM - file_ext: - - img - - iso http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/787d7e7e/tests/resources/service_templates/node-cellar/types/os.yaml ---------------------------------------------------------------------- diff --git a/tests/resources/service_templates/node-cellar/types/os.yaml b/tests/resources/service_templates/node-cellar/types/os.yaml deleted file mode 100644 index 43ea78c..0000000 --- a/tests/resources/service_templates/node-cellar/types/os.yaml +++ /dev/null @@ -1,75 +0,0 @@ -# -# Copyright (c) 2016 GigaSpaces Technologies Ltd. All rights reserved. -# -# 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. -# - -dsl_definitions: - - os: - user_and_group_name_constraints: &OS_USER_AND_GROUP_NAME_CONSTRAINTS - - pattern: '^[a-z0-9_-]{3,16}$' - password_constraints: &OS_PASSWORD_CONSTRAINTS - - pattern: '^[a-z0-9_-]{6,18}$' - -artifact_types: - - os.Package: - description: >- - Generic application package. - derived_from: tosca.artifacts.Root - - os.Archive: - description: >- - Application package in an archive. - derived_from: os.Package - file_ext: - - zip - - tar - - tar.gz - - tar.xz - properties: - unpack_credential: - type: tosca.datatypes.Credential - required: false - - os.Deb: - description: >- - Debian application package. - derived_from: os.Package - file_ext: - - deb - - os.RPM: - description: >- - RPM application package. - derived_from: os.Package - file_ext: - - rpm - -data_types: - - os.UserInfo: - description: >- - Information about an operating system user. - derived_from: tosca.datatypes.Root - properties: - password: - type: string - constraints: *OS_PASSWORD_CONSTRAINTS - groups: - type: list - entry_schema: - type: string - constraints: *OS_USER_AND_GROUP_NAME_CONSTRAINTS - required: false http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/787d7e7e/tests/resources/service_templates/node-cellar/workflows.py ---------------------------------------------------------------------- diff --git a/tests/resources/service_templates/node-cellar/workflows.py b/tests/resources/service_templates/node-cellar/workflows.py deleted file mode 100644 index fff78bf..0000000 --- a/tests/resources/service_templates/node-cellar/workflows.py +++ /dev/null @@ -1,16 +0,0 @@ - -from aria import workflow -from aria.orchestrator.workflows.api.task import OperationTask - - -@workflow -def maintenance(ctx, graph, enabled): - """ - Custom workflow to call the operations on the Maintenance interface. - """ - - operation = 'Maintenance.enable' if enabled else 'Maintenance.disable' - - for node in ctx.model.node.iter(): - for interface in node.interfaces.filter_by(name='Maintenance', type_name='Maintenance'): - graph.add_tasks(OperationTask.node(instance=node, name=operation))