You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ariatosca.apache.org by em...@apache.org on 2017/06/01 19:19:33 UTC
incubator-ariatosca git commit: ARIA-254 Create of multiple nodes per
template
Repository: incubator-ariatosca
Updated Branches:
refs/heads/ARIA-254-multiple-nodes-per-template [created] acfc7f461
ARIA-254 Create of multiple nodes per template
* New aria.Scaling policy (and "scaling" role)
* NodeTemplate model no longer stores scaling values (default_instances,
etc.) but instead fetches them from applicable scaling policies
* Some code cleanup
Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/acfc7f46
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/acfc7f46
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/acfc7f46
Branch: refs/heads/ARIA-254-multiple-nodes-per-template
Commit: acfc7f461b7ee6f01b6095d8eb4e28554df8928c
Parents: 9174f94
Author: Tal Liron <ta...@gmail.com>
Authored: Thu Jun 1 14:17:17 2017 -0500
Committer: Tal Liron <ta...@gmail.com>
Committed: Thu Jun 1 14:17:17 2017 -0500
----------------------------------------------------------------------
aria/cli/commands/workflows.py | 4 +-
aria/cli/execution_logging.py | 4 +-
aria/core.py | 2 +-
aria/modeling/orchestration.py | 12 +-
aria/modeling/relationship.py | 2 +-
aria/modeling/service_changes.py | 8 +-
aria/modeling/service_common.py | 2 +-
aria/modeling/service_instance.py | 59 +++----
aria/modeling/service_template.py | 154 +++++++++++++------
aria/modeling/types.py | 4 +-
aria/orchestrator/workflow_runner.py | 2 +-
aria/orchestrator/workflows/executor/celery.py | 2 +-
aria/orchestrator/workflows/executor/process.py | 2 +-
aria/orchestrator/workflows/executor/thread.py | 2 +-
aria/storage/core.py | 2 +-
.../profiles/aria-1.0/aria-1.0.yaml | 25 ++-
.../simple_v1_0/assignments.py | 8 +
.../simple_v1_0/data_types.py | 22 ++-
.../simple_v1_0/definitions.py | 8 +
.../aria_extension_tosca/simple_v1_0/filters.py | 2 +
.../aria_extension_tosca/simple_v1_0/misc.py | 10 ++
.../simple_v1_0/modeling/__init__.py | 3 -
.../simple_v1_0/presentation/extensible.py | 1 +
.../presentation/field_validators.py | 20 +++
.../simple_v1_0/presentation/types.py | 2 +
.../simple_v1_0/presenter.py | 3 +-
.../simple_v1_0/templates.py | 8 +-
.../aria_extension_tosca/simple_v1_0/types.py | 10 +-
tests/end2end/test_hello_world.py | 2 +-
tests/mock/models.py | 8 +-
tests/modeling/test_mixins.py | 3 -
tests/modeling/test_models.py | 20 +--
tests/orchestrator/context/test_operation.py | 2 +-
.../node-cellar/node-cellar.yaml | 1 +
.../node-cellar/types/openstack.yaml | 3 +-
35 files changed, 285 insertions(+), 137 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/aria/cli/commands/workflows.py
----------------------------------------------------------------------
diff --git a/aria/cli/commands/workflows.py b/aria/cli/commands/workflows.py
index 221dbc4..baab973 100644
--- a/aria/cli/commands/workflows.py
+++ b/aria/cli/commands/workflows.py
@@ -42,7 +42,7 @@ def show(workflow_name, service_name, model_storage, logger):
logger.info('Retrieving workflow {0} for service {1}'.format(
workflow_name, service_name))
service = model_storage.service.get_by_name(service_name)
- workflow = next((wf for wf in service.workflows.values() if
+ workflow = next((wf for wf in service.workflows.itervalues() if
wf.name == workflow_name), None)
if not workflow:
raise AriaCliError(
@@ -91,7 +91,7 @@ def list(service_name, model_storage, logger):
"""
logger.info('Listing workflows for service {0}...'.format(service_name))
service = model_storage.service.get_by_name(service_name)
- workflows_list = sorted(service.workflows.values(), key=lambda w: w.name)
+ workflows_list = sorted(service.workflows.itervalues(), key=lambda w: w.name)
defaults = {
'service_template_name': service.service_template_name,
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/aria/cli/execution_logging.py
----------------------------------------------------------------------
diff --git a/aria/cli/execution_logging.py b/aria/cli/execution_logging.py
index 248ff7c..467123c 100644
--- a/aria/cli/execution_logging.py
+++ b/aria/cli/execution_logging.py
@@ -106,11 +106,11 @@ def stylize_log(item, mark_pattern):
if item.task:
# operation task
implementation = item.task.function
- inputs = dict(arg.unwrapped for arg in item.task.arguments.values())
+ inputs = dict(arg.unwrapped for arg in item.task.arguments.itervalues())
else:
# execution task
implementation = item.execution.workflow_name
- inputs = dict(inp.unwrapped for inp in item.execution.inputs.values())
+ inputs = dict(inp.unwrapped for inp in item.execution.inputs.itervalues())
stylized_str = color.StringStylizer(_get_format())
_populate_level(stylized_str, item)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/aria/core.py
----------------------------------------------------------------------
diff --git a/aria/core.py b/aria/core.py
index f660167..f286e66 100644
--- a/aria/core.py
+++ b/aria/core.py
@@ -106,7 +106,7 @@ class Core(object):
'Active execution ID: {1}'.format(service.name, active_executions[0].id))
if not force:
- available_nodes = [str(n.id) for n in service.nodes.values() if n.is_available()]
+ available_nodes = [str(n.id) for n in service.nodes.itervalues() if n.is_available()]
if available_nodes:
raise exceptions.DependentAvailableNodesError(
'Can\'t delete service `{0}` - there are available nodes for this service. '
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/aria/modeling/orchestration.py
----------------------------------------------------------------------
diff --git a/aria/modeling/orchestration.py b/aria/modeling/orchestration.py
index 97de552..3dd0aab 100644
--- a/aria/modeling/orchestration.py
+++ b/aria/modeling/orchestration.py
@@ -53,8 +53,8 @@ class ExecutionBase(ModelMixin):
__tablename__ = 'execution'
- __private_fields__ = ['service_fk',
- 'service_template']
+ __private_fields__ = ('service_fk',
+ 'service_template')
SUCCEEDED = 'succeeded'
FAILED = 'failed'
@@ -257,10 +257,10 @@ class TaskBase(ModelMixin):
__tablename__ = 'task'
- __private_fields__ = ['node_fk',
+ __private_fields__ = ('node_fk',
'relationship_fk',
'plugin_fk',
- 'execution_fk']
+ 'execution_fk')
PENDING = 'pending'
RETRYING = 'retrying'
@@ -397,8 +397,8 @@ class LogBase(ModelMixin):
__tablename__ = 'log'
- __private_fields__ = ['execution_fk',
- 'task_fk']
+ __private_fields__ = ('execution_fk',
+ 'task_fk')
@declared_attr
def execution(cls):
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/aria/modeling/relationship.py
----------------------------------------------------------------------
diff --git a/aria/modeling/relationship.py b/aria/modeling/relationship.py
index 40be5b2..f2c3986 100644
--- a/aria/modeling/relationship.py
+++ b/aria/modeling/relationship.py
@@ -352,7 +352,7 @@ def _get_class_for_table(model_class, tablename):
if tablename in (model_class.__name__, model_class.__tablename__):
return model_class
- for table_cls in model_class._decl_class_registry.values():
+ for table_cls in model_class._decl_class_registry.itervalues():
if tablename == getattr(table_cls, '__tablename__', None):
return table_cls
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/aria/modeling/service_changes.py
----------------------------------------------------------------------
diff --git a/aria/modeling/service_changes.py b/aria/modeling/service_changes.py
index 1974424..aeb4365 100644
--- a/aria/modeling/service_changes.py
+++ b/aria/modeling/service_changes.py
@@ -44,8 +44,8 @@ class ServiceUpdateBase(ModelMixin):
"""
__tablename__ = 'service_update'
- __private_fields__ = ['service_fk',
- 'execution_fk']
+ __private_fields__ = ('service_fk',
+ 'execution_fk')
created_at = Column(DateTime, nullable=False, index=True)
service_plan = Column(Dict, nullable=False)
@@ -123,7 +123,7 @@ class ServiceUpdateStepBase(ModelMixin):
__tablename__ = 'service_update_step'
- __private_fields__ = ['service_update_fk']
+ __private_fields__ = ('service_update_fk',)
_action_types = namedtuple('ACTION_TYPES', 'ADD, REMOVE, MODIFY')
ACTION_TYPES = _action_types(ADD='add', REMOVE='remove', MODIFY='modify')
@@ -219,7 +219,7 @@ class ServiceModificationBase(ModelMixin):
__tablename__ = 'service_modification'
- __private_fields__ = ['service_fk']
+ __private_fields__ = ('service_fk',)
STARTED = 'started'
FINISHED = 'finished'
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/aria/modeling/service_common.py
----------------------------------------------------------------------
diff --git a/aria/modeling/service_common.py b/aria/modeling/service_common.py
index 8f844a2..f88b102 100644
--- a/aria/modeling/service_common.py
+++ b/aria/modeling/service_common.py
@@ -239,7 +239,7 @@ class TypeBase(InstanceModelMixin):
__tablename__ = 'type'
- __private_fields__ = ['parent_type_fk']
+ __private_fields__ = ('parent_type_fk',)
variant = Column(Text, nullable=False)
description = Column(Text)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/aria/modeling/service_instance.py
----------------------------------------------------------------------
diff --git a/aria/modeling/service_instance.py b/aria/modeling/service_instance.py
index 703873e..902ad07 100644
--- a/aria/modeling/service_instance.py
+++ b/aria/modeling/service_instance.py
@@ -88,8 +88,8 @@ class ServiceBase(InstanceModelMixin):
__tablename__ = 'service'
- __private_fields__ = ['substitution_fk',
- 'service_template_fk']
+ __private_fields__ = ('substitution_fk',
+ 'service_template_fk')
# region foreign keys
@@ -357,10 +357,10 @@ class NodeBase(InstanceModelMixin):
__tablename__ = 'node'
- __private_fields__ = ['type_fk',
+ __private_fields__ = ('type_fk',
'host_fk',
'service_fk',
- 'node_template_fk']
+ 'node_template_fk')
INITIAL = 'initial'
CREATING = 'creating'
@@ -371,16 +371,17 @@ class NodeBase(InstanceModelMixin):
STARTED = 'started'
STOPPING = 'stopping'
DELETING = 'deleting'
- # 'deleted' isn't actually part of the tosca spec, since according the description of the
- # 'deleting' state: "Node is transitioning from its current state to one where it is deleted and
- # its state is no longer tracked by the instance model."
- # However, we prefer to be able to retrieve information about deleted nodes, so we chose to add
- # this 'deleted' state to enable us to do so.
DELETED = 'deleted'
ERROR = 'error'
- STATES = [INITIAL, CREATING, CREATED, CONFIGURING, CONFIGURED, STARTING, STARTED, STOPPING,
- DELETING, DELETED, ERROR]
+ # Note: 'deleted' isn't actually part of the TOSCA spec, since according the description of the
+ # 'deleting' state: "Node is transitioning from its current state to one where it is deleted and
+ # its state is no longer tracked by the instance model." However, we prefer to be able to
+ # retrieve information about deleted nodes, so we chose to add this 'deleted' state to enable us
+ # to do so.
+
+ STATES = (INITIAL, CREATING, CREATED, CONFIGURING, CONFIGURED, STARTING, STARTED, STOPPING,
+ DELETING, DELETED, ERROR)
_op_to_state = {'create': {'transitional': CREATING, 'finished': CREATED},
'configure': {'transitional': CONFIGURING, 'finished': CONFIGURED},
@@ -725,7 +726,9 @@ class GroupBase(InstanceModelMixin):
__tablename__ = 'group'
- __private_fields__ = ['type_fk', 'service_fk', 'group_template_fk']
+ __private_fields__ = ('type_fk',
+ 'service_fk',
+ 'group_template_fk')
# region foreign_keys
@@ -849,7 +852,9 @@ class PolicyBase(InstanceModelMixin):
__tablename__ = 'policy'
- __private_fields__ = ['type_fk', 'service_fk', 'policy_template_fk']
+ __private_fields__ = ('type_fk',
+ 'service_fk',
+ 'policy_template_fk')
# region foreign_keys
@@ -965,8 +970,8 @@ class SubstitutionBase(InstanceModelMixin):
__tablename__ = 'substitution'
- __private_fields__ = ['node_type_fk',
- 'substitution_template_fk']
+ __private_fields__ = ('node_type_fk',
+ 'substitution_template_fk')
# region foreign_keys
@@ -1060,10 +1065,10 @@ class SubstitutionMappingBase(InstanceModelMixin):
__tablename__ = 'substitution_mapping'
- __private_fields__ = ['substitution_fk',
+ __private_fields__ = ('substitution_fk',
'node_fk',
'capability_fk',
- 'requirement_template_fk']
+ 'requirement_template_fk')
# region foreign keys
@@ -1187,14 +1192,14 @@ class RelationshipBase(InstanceModelMixin):
__tablename__ = 'relationship'
- __private_fields__ = ['type_fk',
+ __private_fields__ = ('type_fk',
'source_node_fk',
'target_node_fk',
'target_capability_fk',
'requirement_template_fk',
'relationship_template_fk',
'target_position',
- 'source_position']
+ 'source_position')
# region foreign keys
@@ -1375,9 +1380,9 @@ class CapabilityBase(InstanceModelMixin):
__tablename__ = 'capability'
- __private_fields__ = ['capability_fk',
+ __private_fields__ = ('capability_fk',
'node_fk',
- 'capability_template_fk']
+ 'capability_template_fk')
# region foreign_keys
@@ -1506,11 +1511,11 @@ class InterfaceBase(InstanceModelMixin):
__tablename__ = 'interface'
- __private_fields__ = ['type_fk',
+ __private_fields__ = ('type_fk',
'node_fk',
'group_fk',
'relationship_fk',
- 'interface_template_fk']
+ 'interface_template_fk')
# region foreign_keys
@@ -1667,10 +1672,10 @@ class OperationBase(InstanceModelMixin):
__tablename__ = 'operation'
- __private_fields__ = ['service_fk',
+ __private_fields__ = ('service_fk',
'interface_fk',
'plugin_fk',
- 'operation_template_fk']
+ 'operation_template_fk')
# region foreign_keys
@@ -1864,9 +1869,9 @@ class ArtifactBase(InstanceModelMixin):
__tablename__ = 'artifact'
- __private_fields__ = ['type_fk',
+ __private_fields__ = ('type_fk',
'node_fk',
- 'artifact_template_fk']
+ 'artifact_template_fk')
# region foreign_keys
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/aria/modeling/service_template.py
----------------------------------------------------------------------
diff --git a/aria/modeling/service_template.py b/aria/modeling/service_template.py
index 42e0d01..399b04d 100644
--- a/aria/modeling/service_template.py
+++ b/aria/modeling/service_template.py
@@ -98,14 +98,14 @@ class ServiceTemplateBase(TemplateModelMixin):
__tablename__ = 'service_template'
- __private_fields__ = ['substitution_template_fk',
+ __private_fields__ = ('substitution_template_fk',
'node_type_fk',
'group_type_fk',
'policy_type_fk',
'relationship_type_fk',
'capability_type_fk',
'interface_type_fk',
- 'artifact_type_fk']
+ 'artifact_type_fk')
description = Column(Text)
main_file_name = Column(Text)
@@ -279,16 +279,17 @@ class ServiceTemplateBase(TemplateModelMixin):
def instantiate(self, container, model_storage, inputs=None): # pylint: disable=arguments-differ
from . import models
- context = ConsumptionContext.get_thread_local()
now = datetime.now()
service = models.Service(created_at=now,
updated_at=now,
description=deepcopy_with_locators(self.description),
service_template=self)
+
+ # TODO: we want to remove this use of the context
+ context = ConsumptionContext.get_thread_local()
context.modeling.instance = service
service.inputs = utils.merge_parameter_values(inputs, self.inputs)
- # TODO: now that we have inputs, we should scan properties and inputs and evaluate functions
for plugin_specification in self.plugin_specifications.itervalues():
if plugin_specification.enabled:
@@ -438,8 +439,8 @@ class NodeTemplateBase(TemplateModelMixin):
__tablename__ = 'node_template'
- __private_fields__ = ['type_fk',
- 'service_template_fk']
+ __private_fields__ = ('type_fk',
+ 'service_template_fk')
# region foreign_keys
@@ -522,27 +523,14 @@ class NodeTemplateBase(TemplateModelMixin):
# endregion
description = Column(Text)
- default_instances = Column(Integer, default=1)
- min_instances = Column(Integer, default=0)
- max_instances = Column(Integer, default=None)
target_node_template_constraints = Column(PickleType)
- def is_target_node_template_valid(self, target_node_template):
- if self.target_node_template_constraints:
- for node_template_constraint in self.target_node_template_constraints:
- if not node_template_constraint.matches(self, target_node_template):
- return False
- return True
-
@property
def as_raw(self):
return collections.OrderedDict((
('name', self.name),
('description', self.description),
('type_name', self.type.name),
- ('default_instances', self.default_instances),
- ('min_instances', self.min_instances),
- ('max_instances', self.max_instances),
('properties', formatting.as_raw_dict(self.properties)),
('attributes', formatting.as_raw_dict(self.properties)),
('interface_templates', formatting.as_raw_list(self.interface_templates)),
@@ -552,13 +540,7 @@ class NodeTemplateBase(TemplateModelMixin):
def instantiate(self, container):
from . import models
- if self.nodes:
- highest_name_suffix = max(int(n.name.rsplit('_', 1)[-1]) for n in self.nodes)
- suffix = highest_name_suffix + 1
- else:
- suffix = 1
- name = '{name}_{index}'.format(name=self.name, index=suffix)
- node = models.Node(name=name,
+ node = models.Node(name=self.next_name,
type=self.type,
description=deepcopy_with_locators(self.description),
state=models.Node.INITIAL,
@@ -570,10 +552,12 @@ class NodeTemplateBase(TemplateModelMixin):
utils.instantiate_dict(node, node.capabilities, self.capability_templates)
# Default attributes
- if 'tosca_name' in node.attributes:
+ if ('tosca_name' in node.attributes) \
+ and (node.attributes['tosca_name'].type_name == 'string'):
node.attributes['tosca_name'].value = self.name
- if 'tosca_id' in node.attributes:
- node.attributes['tosca_id'].value = name
+ if 'tosca_id' in node.attributes \
+ and (node.attributes['tosca_id'].type_name == 'string'):
+ node.attributes['tosca_id'].value = node.name
return node
@@ -613,6 +597,56 @@ class NodeTemplateBase(TemplateModelMixin):
utils.dump_dict_values(self.capability_templates, 'Capability templates')
utils.dump_list_values(self.requirement_templates, 'Requirement templates')
+ @property
+ def next_index(self):
+ """
+ Next available node index.
+
+ :returns: node index
+ :rtype: int
+ """
+
+ max_index = 0
+ if self.nodes:
+ max_index = max(int(n.name.rsplit('_', 1)[-1]) for n in self.nodes)
+ return max_index + 1
+
+ @property
+ def next_name(self):
+ """
+ Next available node name.
+
+ :returns: node name
+ :rtype: basestring
+ """
+
+ return '{name}_{index}'.format(name=self.name, index=self.next_index)
+
+ @property
+ def default_instances(self):
+ # TODO: currently finds the first matching policy; but we should emit a validation error
+ # if more than one policy applies to the same node
+ for policy_template in self.service_template.policy_templates.itervalues():
+ if policy_template.type.role == 'scaling':
+ if policy_template.is_for_node_template(self.name):
+ default_instances = policy_template.properties.get('default_instances')
+ if (default_instances is not None) \
+ and (default_instances.type_name == 'integer'):
+ return default_instances.value
+ break
+ return 1
+
+ def is_target_node_template_valid(self, target_node_template):
+ """
+ Checks if ``target_node_template`` matches all our ``target_node_template_constraints``.
+ """
+
+ if self.target_node_template_constraints:
+ for node_template_constraint in self.target_node_template_constraints:
+ if not node_template_constraint.matches(self, target_node_template):
+ return False
+ return True
+
class GroupTemplateBase(TemplateModelMixin):
"""
@@ -642,8 +676,8 @@ class GroupTemplateBase(TemplateModelMixin):
__tablename__ = 'group_template'
- __private_fields__ = ['type_fk',
- 'service_template_fk']
+ __private_fields__ = ('type_fk',
+ 'service_template_fk')
# region foreign keys
@@ -748,6 +782,12 @@ class GroupTemplateBase(TemplateModelMixin):
console.puts('Member node templates: {0}'.format(', '.join(
(str(context.style.node(v.name)) for v in self.node_templates))))
+ def contains_node_template(self, name):
+ for node_template in self.node_templates:
+ if node_template.name == name:
+ return True
+ return False
+
class PolicyTemplateBase(TemplateModelMixin):
"""
@@ -774,7 +814,8 @@ class PolicyTemplateBase(TemplateModelMixin):
__tablename__ = 'policy_template'
- __private_fields__ = ['type_fk', 'service_template_fk']
+ __private_fields__ = ('type_fk',
+ 'service_template_fk')
# region foreign keys
@@ -880,6 +921,21 @@ class PolicyTemplateBase(TemplateModelMixin):
console.puts('Target group templates: {0}'.format(', '.join(
(str(context.style.node(v.name)) for v in self.group_templates))))
+ def is_for_node_template(self, name):
+ for node_template in self.node_templates:
+ if node_template.name == name:
+ return True
+ for group_template in self.group_templates:
+ if group_template.contains_node_template(name):
+ return True
+ return False
+
+ def is_for_group_template(self, name):
+ for group_template in self.group_templates:
+ if group_template.name == name:
+ return True
+ return False
+
class SubstitutionTemplateBase(TemplateModelMixin):
"""
@@ -897,7 +953,7 @@ class SubstitutionTemplateBase(TemplateModelMixin):
__tablename__ = 'substitution_template'
- __private_fields__ = ['node_type_fk']
+ __private_fields__ = ('node_type_fk',)
# region foreign keys
@@ -987,10 +1043,10 @@ class SubstitutionTemplateMappingBase(TemplateModelMixin):
__tablename__ = 'substitution_template_mapping'
- __private_fields__ = ['substitution_template_fk',
+ __private_fields__ = ('substitution_template_fk',
'node_template_fk',
'capability_template_fk',
- 'requirement_template_fk']
+ 'requirement_template_fk')
# region foreign keys
@@ -1137,11 +1193,11 @@ class RequirementTemplateBase(TemplateModelMixin):
__tablename__ = 'requirement_template'
- __private_fields__ = ['target_node_type_fk',
+ __private_fields__ = ('target_node_type_fk',
'target_node_template_fk',
'target_capability_type_fk'
'node_template_fk',
- 'relationship_template_fk']
+ 'relationship_template_fk')
# region foreign keys
@@ -1252,7 +1308,7 @@ class RequirementTemplateBase(TemplateModelMixin):
# Find first node that matches the type
elif self.target_node_type is not None:
for target_node_template in \
- self.node_template.service_template.node_templates.values():
+ self.node_template.service_template.node_templates.itervalues():
if self.target_node_type.get_descendant(target_node_template.type.name) is None:
continue
@@ -1354,7 +1410,7 @@ class RelationshipTemplateBase(TemplateModelMixin):
__tablename__ = 'relationship_template'
- __private_fields__ = ['type_fk']
+ __private_fields__ = ('type_fk',)
# region foreign keys
@@ -1473,8 +1529,8 @@ class CapabilityTemplateBase(TemplateModelMixin):
__tablename__ = 'capability_template'
- __private_fields__ = ['type_fk',
- 'node_template_fk']
+ __private_fields__ = ('type_fk',
+ 'node_template_fk')
# region foreign keys
@@ -1632,10 +1688,10 @@ class InterfaceTemplateBase(TemplateModelMixin):
__tablename__ = 'interface_template'
- __private_fields__ = ['type_fk',
+ __private_fields__ = ('type_fk',
'node_template_fk',
'group_template_fk',
- 'relationship_template_fk']
+ 'relationship_template_fk')
# region foreign keys
@@ -1794,9 +1850,9 @@ class OperationTemplateBase(TemplateModelMixin):
__tablename__ = 'operation_template'
- __private_fields__ = ['service_template_fk',
+ __private_fields__ = ('service_template_fk',
'interface_template_fk',
- 'plugin_fk']
+ 'plugin_fk')
# region foreign keys
@@ -1969,8 +2025,8 @@ class ArtifactTemplateBase(TemplateModelMixin):
__tablename__ = 'artifact_template'
- __private_fields__ = ['type_fk',
- 'node_template_fk']
+ __private_fields__ = ('type_fk',
+ 'node_template_fk')
# region foreign keys
@@ -2094,8 +2150,8 @@ class PluginSpecificationBase(TemplateModelMixin):
__tablename__ = 'plugin_specification'
- __private_fields__ = ['service_template_fk',
- 'plugin_fk']
+ __private_fields__ = ('service_template_fk',
+ 'plugin_fk')
version = Column(Text)
enabled = Column(Boolean, nullable=False, default=True)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/aria/modeling/types.py
----------------------------------------------------------------------
diff --git a/aria/modeling/types.py b/aria/modeling/types.py
index 920a0c2..fe57617 100644
--- a/aria/modeling/types.py
+++ b/aria/modeling/types.py
@@ -258,10 +258,10 @@ StrictList = _StrictList()
def _mutable_association_listener(mapper, cls):
strict_dict_type_to_listener = \
- dict((v.type_cls, v.listener_cls) for v in _StrictDict._strict_map.values())
+ dict((v.type_cls, v.listener_cls) for v in _StrictDict._strict_map.itervalues())
strict_list_type_to_listener = \
- dict((v.type_cls, v.listener_cls) for v in _StrictList._strict_map.values())
+ dict((v.type_cls, v.listener_cls) for v in _StrictList._strict_map.itervalues())
for prop in mapper.column_attrs:
column_type = prop.columns[0].type
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/aria/orchestrator/workflow_runner.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/workflow_runner.py b/aria/orchestrator/workflow_runner.py
index 15a55b0..42257b8 100644
--- a/aria/orchestrator/workflow_runner.py
+++ b/aria/orchestrator/workflow_runner.py
@@ -81,7 +81,7 @@ class WorkflowRunner(object):
task_retry_interval=task_retry_interval)
# transforming the execution inputs to dict, to pass them to the workflow function
- execution_inputs_dict = dict(inp.unwrapped for inp in self.execution.inputs.values())
+ execution_inputs_dict = dict(inp.unwrapped for inp in self.execution.inputs.itervalues())
self._tasks_graph = workflow_fn(ctx=workflow_context, **execution_inputs_dict)
executor = executor or ProcessExecutor(plugin_manager=plugin_manager)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/aria/orchestrator/workflows/executor/celery.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/workflows/executor/celery.py b/aria/orchestrator/workflows/executor/celery.py
index 9d66d26..749b091 100644
--- a/aria/orchestrator/workflows/executor/celery.py
+++ b/aria/orchestrator/workflows/executor/celery.py
@@ -44,7 +44,7 @@ class CeleryExecutor(BaseExecutor):
def _execute(self, task):
self._tasks[task.id] = task
- arguments = dict(arg.unwrapped for arg in task.arguments.values())
+ arguments = dict(arg.unwrapped for arg in task.arguments.itervalues())
arguments['ctx'] = task.context
self._results[task.id] = self._app.send_task(
task.operation_mapping,
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/aria/orchestrator/workflows/executor/process.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/workflows/executor/process.py b/aria/orchestrator/workflows/executor/process.py
index 634f1f2..ec1be44 100644
--- a/aria/orchestrator/workflows/executor/process.py
+++ b/aria/orchestrator/workflows/executor/process.py
@@ -141,7 +141,7 @@ class ProcessExecutor(base.BaseExecutor):
return {
'task_id': task.id,
'function': task.function,
- 'operation_arguments': dict(arg.unwrapped for arg in task.arguments.values()),
+ 'operation_arguments': dict(arg.unwrapped for arg in task.arguments.itervalues()),
'port': self._server_port,
'context': task.context.serialization_dict,
}
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/aria/orchestrator/workflows/executor/thread.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/workflows/executor/thread.py b/aria/orchestrator/workflows/executor/thread.py
index 56a56a5..7d01c90 100644
--- a/aria/orchestrator/workflows/executor/thread.py
+++ b/aria/orchestrator/workflows/executor/thread.py
@@ -61,7 +61,7 @@ class ThreadExecutor(BaseExecutor):
self._task_started(task)
try:
task_func = imports.load_attribute(task.function)
- arguments = dict(arg.unwrapped for arg in task.arguments.values())
+ arguments = dict(arg.unwrapped for arg in task.arguments.itervalues())
task_func(ctx=task.context, **arguments)
self._task_succeeded(task)
except BaseException as e:
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/aria/storage/core.py
----------------------------------------------------------------------
diff --git a/aria/storage/core.py b/aria/storage/core.py
index 8302fc9..fb85992 100644
--- a/aria/storage/core.py
+++ b/aria/storage/core.py
@@ -163,5 +163,5 @@ class ModelStorage(Storage):
Drop all the tables from the model.
:return:
"""
- for mapi in self.registered.values():
+ for mapi in self.registered.itervalues():
mapi.drop()
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/extensions/aria_extension_tosca/profiles/aria-1.0/aria-1.0.yaml
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/profiles/aria-1.0/aria-1.0.yaml b/extensions/aria_extension_tosca/profiles/aria-1.0/aria-1.0.yaml
index c1dc11d..71d6e8e 100644
--- a/extensions/aria_extension_tosca/profiles/aria-1.0/aria-1.0.yaml
+++ b/extensions/aria_extension_tosca/profiles/aria-1.0/aria-1.0.yaml
@@ -58,4 +58,27 @@ policy_types:
the full path to a Python @workflow function that generates a task graph based on the
service topology.
type: string
- required: true
+
+ aria.Scaling:
+ _extensions:
+ type_qualified_name: aria:Scaling
+ role: scaling
+ description: >-
+ Scaling.
+ derived_from: tosca.policies.Scaling
+ properties:
+ default_instances:
+ type: integer
+ default: 1
+ constraints:
+ - greater_or_equal: 0
+ min_instances:
+ type: integer
+ default: 0
+ constraints:
+ - greater_or_equal: 0
+ max_instances:
+ type: integer
+ default: -1
+ constraints:
+ - greater_or_equal: -1
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/extensions/aria_extension_tosca/simple_v1_0/assignments.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/assignments.py b/extensions/aria_extension_tosca/simple_v1_0/assignments.py
index 79f6377..f7160b2 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/assignments.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/assignments.py
@@ -32,6 +32,7 @@ from .presentation.field_validators import (node_template_or_type_validator,
from .presentation.types import (convert_shorthand_to_full_type_name,
get_type_by_full_or_shorthand_name)
+
@implements_specification('3.5.9', 'tosca-simple-1.0')
class PropertyAssignment(AsIsPresentation):
"""
@@ -43,6 +44,7 @@ class PropertyAssignment(AsIsPresentation):
#DEFN_ELEMENT_PROPERTY_VALUE_ASSIGNMENT>`__
"""
+
@short_form_field('implementation')
@has_fields
@implements_specification('3.5.13-2', 'tosca-simple-1.0')
@@ -103,6 +105,7 @@ class OperationAssignment(ExtensiblePresentation):
extensions.update(self._extensions)
return extensions
+
@allow_unknown_fields
@has_fields
@implements_specification('3.5.14-2', 'tosca-simple-1.0')
@@ -154,6 +157,7 @@ class InterfaceAssignment(ExtensiblePresentation):
for operation in self.operations.itervalues(): # pylint: disable=no-member
operation._validate(context)
+
@short_form_field('type')
@has_fields
class RelationshipAssignment(ExtensiblePresentation):
@@ -198,6 +202,7 @@ class RelationshipAssignment(ExtensiblePresentation):
return the_type, 'relationship_type'
return None, None
+
@short_form_field('node')
@has_fields
@implements_specification('3.7.2', 'tosca-simple-1.0')
@@ -297,6 +302,7 @@ class RequirementAssignment(ExtensiblePresentation):
return None, None
+
@implements_specification('3.5.11', 'tosca-simple-1.0')
class AttributeAssignment(AsIsPresentation):
"""
@@ -308,6 +314,7 @@ class AttributeAssignment(AsIsPresentation):
#DEFN_ELEMENT_ATTRIBUTE_VALUE_ASSIGNMENT>`__
"""
+
@has_fields
@implements_specification('3.7.1', 'tosca-simple-1.0')
class CapabilityAssignment(ExtensiblePresentation):
@@ -350,6 +357,7 @@ class CapabilityAssignment(ExtensiblePresentation):
return capability_definition._get_type(context) \
if capability_definition is not None else None
+
@has_fields
@implements_specification('3.5.6', 'tosca-simple-1.0')
class ArtifactAssignment(ExtensiblePresentation):
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/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 c385f78..513b517 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/data_types.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/data_types.py
@@ -14,14 +14,14 @@
# limitations under the License.
import re
-from datetime import datetime, tzinfo, timedelta
+from datetime import (datetime, tzinfo, timedelta)
try:
from functools import total_ordering
except ImportError:
from total_ordering import total_ordering
from aria.parser import implements_specification
-from aria.utils.collections import StrictDict, OrderedDict
+from aria.utils.collections import (StrictDict, OrderedDict)
from aria.utils.formatting import safe_repr
from .modeling.data_types import (coerce_to_data_type_class, report_issue_for_bad_format,
@@ -48,8 +48,10 @@ class Timezone(tzinfo):
_ZERO = timedelta(0)
+
UTC = Timezone()
+
@total_ordering
@implements_specification('timestamp', 'yaml-1.1')
class Timestamp(object):
@@ -145,6 +147,7 @@ class Timestamp(object):
def _fraction_as_str(the_datetime):
return '{0:g}'.format(the_datetime.microsecond / 1000000.0).lstrip('0')
+
@total_ordering
@implements_specification('3.2.2', 'tosca-simple-1.0')
class Version(object):
@@ -229,6 +232,7 @@ class Version(object):
return True
return False
+
@implements_specification('3.2.3', 'tosca-simple-1.0')
class Range(object):
"""
@@ -276,6 +280,7 @@ class Range(object):
def as_raw(self):
return list(self.value)
+
@implements_specification('3.2.4', 'tosca-simple-1.0')
class List(list):
"""
@@ -309,6 +314,7 @@ class List(list):
def as_raw(self):
return list(self)
+
@implements_specification('3.2.5', 'tosca-simple-1.0')
class Map(StrictDict):
"""
@@ -348,6 +354,7 @@ class Map(StrictDict):
def as_raw(self):
return OrderedDict(self)
+
@total_ordering
@implements_specification('3.2.6', 'tosca-simple-1.0')
class Scalar(object):
@@ -416,6 +423,7 @@ class Scalar(object):
value = self.TYPE(scalar) # pylint: disable=no-member
return self.value < value
+
@implements_specification('3.2.6.4', 'tosca-simple-1.0')
class ScalarSize(Scalar):
"""
@@ -444,6 +452,7 @@ class ScalarSize(Scalar):
TYPE = int
UNIT = 'bytes'
+
@implements_specification('3.2.6.5', 'tosca-simple-1.0')
class ScalarTime(Scalar):
"""
@@ -469,6 +478,7 @@ class ScalarTime(Scalar):
TYPE = float
UNIT = 'seconds'
+
@implements_specification('3.2.6.6', 'tosca-simple-1.0')
class ScalarFrequency(Scalar):
"""
@@ -491,6 +501,7 @@ class ScalarFrequency(Scalar):
TYPE = float
UNIT = 'Hz'
+
#
# The following are hooked in the YAML as 'coerce_value' extensions
#
@@ -499,10 +510,12 @@ def coerce_timestamp(context, presentation, the_type, entry_schema, constraints,
return coerce_to_data_type_class(context, presentation, Timestamp, entry_schema, constraints,
value, aspect)
+
def coerce_version(context, presentation, the_type, entry_schema, constraints, value, aspect): # pylint: disable=unused-argument
return coerce_to_data_type_class(context, presentation, Version, entry_schema, constraints,
value, aspect)
+
def coerce_range(context, presentation, the_type, entry_schema, constraints, value, aspect):
if aspect == 'in_range':
# When we're in a "in_range" constraint, the values are *not* themselves ranges, but numbers
@@ -516,24 +529,29 @@ def coerce_range(context, presentation, the_type, entry_schema, constraints, val
return coerce_to_data_type_class(context, presentation, Range, entry_schema, constraints,
value, aspect)
+
def coerce_list(context, presentation, the_type, entry_schema, constraints, value, aspect): # pylint: disable=unused-argument
return coerce_to_data_type_class(context, presentation, List, entry_schema, constraints,
value, aspect)
+
def coerce_map_value(context, presentation, the_type, entry_schema, constraints, value, aspect): # pylint: disable=unused-argument
return coerce_to_data_type_class(context, presentation, Map, entry_schema, constraints, value,
aspect)
+
def coerce_scalar_unit_size(context, presentation, the_type, entry_schema, constraints, value, # pylint: disable=unused-argument
aspect):
return coerce_to_data_type_class(context, presentation, ScalarSize, entry_schema, constraints,
value, aspect)
+
def coerce_scalar_unit_time(context, presentation, the_type, entry_schema, constraints, value, # pylint: disable=unused-argument
aspect):
return coerce_to_data_type_class(context, presentation, ScalarTime, entry_schema, constraints,
value, aspect)
+
def coerce_scalar_unit_frequency(context, presentation, the_type, entry_schema, constraints, value, # pylint: disable=unused-argument
aspect):
return coerce_to_data_type_class(context, presentation, ScalarFrequency, entry_schema,
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/extensions/aria_extension_tosca/simple_v1_0/definitions.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/definitions.py b/extensions/aria_extension_tosca/simple_v1_0/definitions.py
index 8564249..9519586 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/definitions.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/definitions.py
@@ -34,6 +34,7 @@ from .modeling.data_types import get_data_type, get_property_constraints
from .modeling.interfaces import (get_and_override_input_definitions_from_type,
get_and_override_operation_definitions_from_type)
+
@has_fields
@implements_specification('3.5.8', 'tosca-simple-1.0')
class PropertyDefinition(ExtensiblePresentation):
@@ -120,6 +121,7 @@ class PropertyDefinition(ExtensiblePresentation):
def _get_constraints(self, context):
return get_property_constraints(context, self)
+
@has_fields
@implements_specification('3.5.10', 'tosca-simple-1.0')
class AttributeDefinition(ExtensiblePresentation):
@@ -189,6 +191,7 @@ class AttributeDefinition(ExtensiblePresentation):
def _get_type(self, context):
return get_data_type(context, self, 'type')
+
@has_fields
@implements_specification('3.5.12', 'tosca-simple-1.0')
class ParameterDefinition(PropertyDefinition):
@@ -223,6 +226,7 @@ class ParameterDefinition(PropertyDefinition):
as the result from the evaluation of an expression or a function.
"""
+
@short_form_field('implementation')
@has_fields
@implements_specification('3.5.13-1', 'tosca-simple-1.0')
@@ -264,6 +268,7 @@ class OperationDefinition(ExtensiblePresentation):
:rtype: dict of str, :class:`PropertyDefinition`
"""
+
@allow_unknown_fields
@has_fields
@implements_specification('3.5.14-1', 'tosca-simple-1.0')
@@ -322,6 +327,7 @@ class InterfaceDefinition(ExtensiblePresentation):
for operation in self.operations.itervalues(): # pylint: disable=no-member
operation._validate(context)
+
@short_form_field('type')
@has_fields
class RelationshipDefinition(ExtensiblePresentation):
@@ -350,6 +356,7 @@ class RelationshipDefinition(ExtensiblePresentation):
def _get_type(self, context):
return get_type_by_full_or_shorthand_name(context, self.type, 'relationship_types')
+
@short_form_field('capability')
@has_fields
@implements_specification('3.6.2', 'tosca-simple-1.0')
@@ -416,6 +423,7 @@ class RequirementDefinition(ExtensiblePresentation):
def _get_node_type(self, context):
return context.presentation.get_from_dict('service_template', 'node_types', self.node)
+
@short_form_field('type')
@has_fields
@implements_specification('3.6.1', 'tosca-simple-1.0')
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/extensions/aria_extension_tosca/simple_v1_0/filters.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/filters.py b/extensions/aria_extension_tosca/simple_v1_0/filters.py
index 838b505..889acdf 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/filters.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/filters.py
@@ -22,6 +22,7 @@ from .presentation.extensible import ExtensiblePresentation
from .presentation.field_validators import (node_filter_properties_validator,
node_filter_capabilities_validator)
+
@has_fields
class CapabilityFilter(ExtensiblePresentation):
@object_sequenced_list_field(ConstraintClause)
@@ -44,6 +45,7 @@ class CapabilityFilter(ExtensiblePresentation):
return None
+
@has_fields
@implements_specification('3.5.4', 'tosca-simple-1.0')
class NodeFilter(ExtensiblePresentation):
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/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 74eba18..d276813 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/misc.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/misc.py
@@ -36,6 +36,7 @@ from .presentation.field_validators import (constraint_clause_field_validator,
from .presentation.types import (convert_shorthand_to_full_type_name,
get_type_by_full_or_shorthand_name)
+
@implements_specification('3.5.1', 'tosca-simple-1.0')
class Description(AsIsPresentation):
"""
@@ -51,6 +52,7 @@ class Description(AsIsPresentation):
value = as_raw(self.value)
puts(context.style.meta(value))
+
@allow_unknown_fields
@has_fields
@implements_specification('3.9.3.2', 'tosca-simple-1.0')
@@ -85,6 +87,7 @@ class MetaData(ExtensiblePresentation):
:rtype: dict
"""
+
@short_form_field('url')
@has_fields
@implements_specification('3.5.5', 'tosca-simple-1.0')
@@ -126,6 +129,7 @@ class Repository(ExtensiblePresentation):
def _get_credential(self, context):
return get_data_type_value(context, self, 'credential', 'tosca.datatypes.Credential')
+
@short_form_field('file')
@has_fields
@implements_specification('3.5.7', 'tosca-simple-1.0')
@@ -176,6 +180,7 @@ class Import(ExtensiblePresentation):
:rtype: str
"""
+
@has_fields
@implements_specification('3.5.2-1', 'tosca-simple-1.0')
class ConstraintClause(ExtensiblePresentation):
@@ -288,6 +293,7 @@ class ConstraintClause(ExtensiblePresentation):
def _apply_to_value(self, context, presentation, value):
return apply_constraint_to_value(context, presentation, self, value)
+
@short_form_field('type')
@has_fields
class EntrySchema(ExtensiblePresentation):
@@ -323,6 +329,7 @@ class EntrySchema(ExtensiblePresentation):
def _get_constraints(self, context):
return get_property_constraints(context, self)
+
@short_form_field('primary')
@has_fields
class OperationImplementation(ExtensiblePresentation):
@@ -345,6 +352,7 @@ class OperationImplementation(ExtensiblePresentation):
:rtype: list of str
"""
+
class SubstitutionMappingsRequirement(AsIsPresentation):
@property
@cachedmethod
@@ -360,6 +368,7 @@ class SubstitutionMappingsRequirement(AsIsPresentation):
super(SubstitutionMappingsRequirement, self)._validate(context)
validate_subtitution_mappings_requirement(context, self)
+
class SubstitutionMappingsCapability(AsIsPresentation):
@property
@cachedmethod
@@ -375,6 +384,7 @@ class SubstitutionMappingsCapability(AsIsPresentation):
super(SubstitutionMappingsCapability, self)._validate(context)
validate_subtitution_mappings_capability(context, self)
+
@has_fields
@implements_specification('2.10', 'tosca-simple-1.0')
class SubstitutionMappings(ExtensiblePresentation):
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/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 440cb96..202fd4d 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py
@@ -165,9 +165,6 @@ def create_node_template_model(context, service_template, node_template):
model = NodeTemplate(name=node_template._name,
type=node_type)
- model.default_instances = 1
- model.min_instances = 0
-
if node_template.description:
model.description = node_template.description.value
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/extensions/aria_extension_tosca/simple_v1_0/presentation/extensible.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/presentation/extensible.py b/extensions/aria_extension_tosca/simple_v1_0/presentation/extensible.py
index a2fd6ee..3c03213 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/presentation/extensible.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/presentation/extensible.py
@@ -16,6 +16,7 @@
from aria.utils.caching import cachedmethod
from aria.parser.presentation import (Presentation, has_fields, primitive_dict_field)
+
@has_fields
class ExtensiblePresentation(Presentation):
"""
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/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 d7b03ae..e5ecfa7 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
@@ -24,6 +24,7 @@ from ..modeling.data_types import (get_primitive_data_type, get_data_type_name,
get_container_data_type)
from .types import get_type_by_full_or_shorthand_name, convert_shorthand_to_full_type_name
+
#
# NodeTemplate, RelationshipTemplate
#
@@ -56,6 +57,7 @@ def copy_validator(template_type_name, templates_dict_name):
return validator_fn
+
#
# PropertyDefinition, AttributeDefinition, ParameterDefinition, EntrySchema
#
@@ -97,6 +99,7 @@ def data_type_validator(type_name='data type'):
return validator
+
#
# PropertyDefinition, AttributeDefinition
#
@@ -141,6 +144,7 @@ def entry_schema_validator(field, presentation, context):
% (get_data_type_name(the_type), presentation._container._fullname),
locator=presentation._locator, level=Issue.BETWEEN_TYPES)
+
def data_value_validator(field, presentation, context):
"""
Makes sure that the field contains a valid value according to data type and constraints.
@@ -160,6 +164,7 @@ def data_value_validator(field, presentation, context):
if hasattr(presentation, '_get_constraints') else None
coerce_value(context, presentation, the_type, entry_schema, constraints, value, field.name)
+
#
# DataType
#
@@ -168,6 +173,7 @@ _data_type_validator = data_type_validator()
_data_type_derived_from_validator = derived_from_validator(convert_shorthand_to_full_type_name,
'data_types')
+
def data_type_derived_from_validator(field, presentation, context):
"""
Makes sure that the field refers to a valid parent data type (complex or primitive).
@@ -181,6 +187,7 @@ def data_type_derived_from_validator(field, presentation, context):
# hierarchy)
_data_type_derived_from_validator(field, presentation, context)
+
def data_type_constraints_validator(field, presentation, context):
"""
Makes sure that we do not have constraints if we are a complex type (with no primitive
@@ -197,6 +204,7 @@ def data_type_constraints_validator(field, presentation, context):
% presentation._fullname,
locator=presentation._get_child_locator(field.name), level=Issue.BETWEEN_TYPES)
+
def data_type_properties_validator(field, presentation, context):
"""
Makes sure that we do not have properties if we have a primitive ancestor.
@@ -215,6 +223,7 @@ def data_type_properties_validator(field, presentation, context):
% presentation._fullname,
locator=presentation._get_child_locator(field.name), level=Issue.BETWEEN_TYPES)
+
#
# ConstraintClause
#
@@ -235,6 +244,7 @@ def constraint_clause_field_validator(field, presentation, context):
if hasattr(the_type, '_get_constraints') else None
coerce_value(context, presentation, the_type, None, constraints, value, field.name)
+
def constraint_clause_in_range_validator(field, presentation, context):
"""
Makes sure that the value is a list with exactly two elements, that both lower bound contains a
@@ -274,6 +284,7 @@ def constraint_clause_in_range_validator(field, presentation, context):
% (field.name, presentation._fullname),
locator=presentation._get_child_locator(field.name), level=Issue.FIELD)
+
def constraint_clause_valid_values_validator(field, presentation, context):
"""
Makes sure that the value is a list of valid values for the container type.
@@ -290,6 +301,7 @@ def constraint_clause_valid_values_validator(field, presentation, context):
for value in values:
coerce_value(context, presentation, the_type, None, None, value, field.name)
+
def constraint_clause_pattern_validator(field, presentation, context):
"""
Makes sure that the value is a valid regular expression.
@@ -316,6 +328,7 @@ def constraint_clause_pattern_validator(field, presentation, context):
% (field.name, presentation._fullname),
locator=presentation._get_child_locator(field.name), level=Issue.FIELD, exception=e)
+
#
# RequirementAssignment
#
@@ -340,6 +353,7 @@ def node_template_or_type_validator(field, presentation, context):
report_issue_for_unknown_type(context, presentation, 'node template or node type',
field.name)
+
def capability_definition_or_type_validator(field, presentation, context):
"""
Makes sure refers to either a capability assignment name in the node template referred to by the
@@ -381,6 +395,7 @@ def capability_definition_or_type_validator(field, presentation, context):
% (presentation._name, presentation._container._fullname, safe_repr(value)),
locator=presentation._get_child_locator(field.name), level=Issue.BETWEEN_TYPES)
+
def node_filter_validator(field, presentation, context):
"""
Makes sure that the field has a value only if "node" refers to a node type.
@@ -401,6 +416,7 @@ def node_filter_validator(field, presentation, context):
% (presentation._fullname, presentation._container._fullname),
locator=presentation._locator, level=Issue.BETWEEN_FIELDS)
+
#
# RelationshipAssignment
#
@@ -426,6 +442,7 @@ def relationship_template_or_type_validator(field, presentation, context):
report_issue_for_unknown_type(context, presentation,
'relationship template or relationship type', field.name)
+
#
# PolicyType
#
@@ -449,6 +466,7 @@ def list_node_type_or_group_type_validator(field, presentation, context):
report_issue_for_unknown_type(context, presentation, 'node type or group type',
field.name, value)
+
#
# PolicyTemplate
#
@@ -506,6 +524,7 @@ def policy_targets_validator(field, presentation, context):
% (presentation._name, safe_repr(value)),
locator=presentation._locator, level=Issue.BETWEEN_TYPES)
+
#
# NodeFilter
#
@@ -532,6 +551,7 @@ def node_filter_properties_validator(field, presentation, context):
% (node_type._name, name),
locator=presentation._locator, level=Issue.BETWEEN_TYPES)
+
def node_filter_capabilities_validator(field, presentation, context):
"""
Makes sure that the field's elements refer to defined capabilities and properties in the target
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/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 088a246..e34405d 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/presentation/types.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/presentation/types.py
@@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+
def convert_shorthand_to_full_type_name(context, name, types_dict): # pylint: disable=unused-argument
"""
Converts a shorthand type name to its full type name, or else returns it unchanged.
@@ -31,6 +32,7 @@ def convert_shorthand_to_full_type_name(context, name, types_dict): # pylint: di
return full_name
return name
+
def get_type_by_full_or_shorthand_name(context, name, *types_dict_names):
"""
Gets a type either by its full name or its shorthand name.
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/extensions/aria_extension_tosca/simple_v1_0/presenter.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/presenter.py b/extensions/aria_extension_tosca/simple_v1_0/presenter.py
index f64078f..92e37d9 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/presenter.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/presenter.py
@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from aria.utils.collections import FrozenList, EMPTY_READ_ONLY_LIST
+from aria.utils.collections import (FrozenList, EMPTY_READ_ONLY_LIST)
from aria.utils.caching import cachedmethod
from aria.parser.presentation import Presenter
@@ -22,6 +22,7 @@ from .modeling.functions import (Concat, Token, GetInput, GetProperty, GetAttrib
GetOperationOutput, GetNodesOfType, GetArtifact)
from .templates import ServiceTemplate
+
class ToscaSimplePresenter1_0(Presenter): # pylint: disable=invalid-name,abstract-method
"""
ARIA presenter for the `TOSCA Simple Profile v1.0 cos01 <http://docs.oasis-open.org/tosca
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/extensions/aria_extension_tosca/simple_v1_0/templates.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/templates.py b/extensions/aria_extension_tosca/simple_v1_0/templates.py
index 123a00e..6f61a39 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/templates.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/templates.py
@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from aria.utils.collections import FrozenDict, FrozenList
+from aria.utils.collections import (FrozenDict, FrozenList)
from aria.utils.caching import cachedmethod
from aria.parser import implements_specification
from aria.parser.presentation import (has_fields, primitive_field, primitive_list_field,
@@ -40,6 +40,7 @@ from .presentation.types import (convert_shorthand_to_full_type_name,
from .types import (ArtifactType, DataType, CapabilityType, InterfaceType, RelationshipType,
NodeType, GroupType, PolicyType)
+
@has_fields
@implements_specification('3.7.3', 'tosca-simple-1.0')
class NodeTemplate(ExtensiblePresentation):
@@ -201,6 +202,7 @@ class NodeTemplate(ExtensiblePresentation):
'node_filter',
'copy'))
+
@has_fields
@implements_specification('3.7.4', 'tosca-simple-1.0')
class RelationshipTemplate(ExtensiblePresentation):
@@ -300,6 +302,7 @@ class RelationshipTemplate(ExtensiblePresentation):
'interfaces',
'copy'))
+
@has_fields
@implements_specification('3.7.5', 'tosca-simple-1.0')
class GroupTemplate(ExtensiblePresentation):
@@ -373,6 +376,7 @@ class GroupTemplate(ExtensiblePresentation):
self._get_property_values(context)
self._get_interfaces(context)
+
@has_fields
@implements_specification('3.7.6', 'tosca-simple-1.0')
class PolicyTemplate(ExtensiblePresentation):
@@ -437,6 +441,7 @@ class PolicyTemplate(ExtensiblePresentation):
super(PolicyTemplate, self)._validate(context)
self._get_property_values(context)
+
@has_fields
@implements_specification('3.8', 'tosca-simple-1.0')
class TopologyTemplate(ExtensiblePresentation):
@@ -547,6 +552,7 @@ class TopologyTemplate(ExtensiblePresentation):
'outputs',
'substitution_mappings'))
+
@has_fields
@implements_specification('3.9', 'tosca-simple-1.0')
class ServiceTemplate(ExtensiblePresentation):
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/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 d97b89c..7c1008f 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/types.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/types.py
@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from aria.utils.collections import FrozenDict, FrozenList
+from aria.utils.collections import (FrozenDict, FrozenList)
from aria.utils.caching import cachedmethod
from aria.parser import implements_specification
from aria.parser.presentation import (has_fields, allow_unknown_fields, primitive_field,
@@ -45,6 +45,7 @@ from .presentation.field_validators import (data_type_derived_from_validator,
list_node_type_or_group_type_validator)
from .presentation.types import convert_shorthand_to_full_type_name
+
@has_fields
@implements_specification('3.6.3', 'tosca-simple-1.0')
class ArtifactType(ExtensiblePresentation):
@@ -130,6 +131,7 @@ class ArtifactType(ExtensiblePresentation):
'file_ext',
'properties'))
+
@has_fields
@implements_specification('3.6.5', 'tosca-simple-1.0')
class DataType(ExtensiblePresentation):
@@ -224,6 +226,7 @@ class DataType(ExtensiblePresentation):
'constraints',
'properties'))
+
@has_fields
@implements_specification('3.6.6', 'tosca-simple-1.0')
class CapabilityType(ExtensiblePresentation):
@@ -326,6 +329,7 @@ class CapabilityType(ExtensiblePresentation):
'properties',
'attributes'))
+
@allow_unknown_fields
@has_fields
@implements_specification('3.6.4', 'tosca-simple-1.0')
@@ -405,6 +409,7 @@ class InterfaceType(ExtensiblePresentation):
'inputs',
'operations'))
+
@has_fields
@implements_specification('3.6.9', 'tosca-simple-1.0')
class RelationshipType(ExtensiblePresentation):
@@ -519,6 +524,7 @@ class RelationshipType(ExtensiblePresentation):
'attributes',
'interfaces'))
+
@has_fields
@implements_specification('3.6.8', 'tosca-simple-1.0')
class NodeType(ExtensiblePresentation):
@@ -667,6 +673,7 @@ class NodeType(ExtensiblePresentation):
'requirements',
'capabilities'))
+
@has_fields
@implements_specification('3.6.10', 'tosca-simple-1.0')
class GroupType(ExtensiblePresentation):
@@ -780,6 +787,7 @@ class GroupType(ExtensiblePresentation):
'properties',
'interfaces'))
+
@has_fields
@implements_specification('3.6.11', 'tosca-simple-1.0')
class PolicyType(ExtensiblePresentation):
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/tests/end2end/test_hello_world.py
----------------------------------------------------------------------
diff --git a/tests/end2end/test_hello_world.py b/tests/end2end/test_hello_world.py
index 71792dd..e0d0c56 100644
--- a/tests/end2end/test_hello_world.py
+++ b/tests/end2end/test_hello_world.py
@@ -56,5 +56,5 @@ def _verify_deployed_service_in_storage(service_name, model_storage):
assert service.name == service_name
assert len(service.executions) == 1
assert len(service.nodes) == 2
- assert all(node.state == node.STARTED for node in service.nodes.values())
+ assert all(node.state == node.STARTED for node in service.nodes.itervalues())
assert len(service.executions[0].logs) > 0
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/tests/mock/models.py
----------------------------------------------------------------------
diff --git a/tests/mock/models.py b/tests/mock/models.py
index 50aa340..3eb9fba 100644
--- a/tests/mock/models.py
+++ b/tests/mock/models.py
@@ -129,10 +129,7 @@ def create_node_template(service_template,
type=models.Type(variant='node', name='test_node_type'),
capability_templates=None,
requirement_templates=None,
- interface_templates=None,
- default_instances=1,
- min_instances=1,
- max_instances=1):
+ interface_templates=None):
capability_templates = capability_templates or {}
requirement_templates = requirement_templates or []
interface_templates = interface_templates or {}
@@ -142,9 +139,6 @@ def create_node_template(service_template,
capability_templates=capability_templates,
requirement_templates=requirement_templates,
interface_templates=interface_templates,
- default_instances=default_instances,
- min_instances=min_instances,
- max_instances=max_instances,
service_template=service_template)
service_template.node_templates[node_template.name] = node_template
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/tests/modeling/test_mixins.py
----------------------------------------------------------------------
diff --git a/tests/modeling/test_mixins.py b/tests/modeling/test_mixins.py
index 2c91a4b..2d94d7c 100644
--- a/tests/modeling/test_mixins.py
+++ b/tests/modeling/test_mixins.py
@@ -112,9 +112,6 @@ def test_relationship_model_ordering(context):
new_node_template = modeling.models.NodeTemplate(
name='new_node_template',
type=source_node.type,
- default_instances=1,
- min_instances=1,
- max_instances=1,
service_template=service.service_template
)
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/tests/modeling/test_models.py
----------------------------------------------------------------------
diff --git a/tests/modeling/test_models.py b/tests/modeling/test_models.py
index df3aebd..2f48d7c 100644
--- a/tests/modeling/test_models.py
+++ b/tests/modeling/test_models.py
@@ -505,19 +505,15 @@ class TestServiceModification(object):
class TestNodeTemplate(object):
@pytest.mark.parametrize(
- 'is_valid, name, default_instances, max_instances, min_instances, properties',
+ 'is_valid, name, properties',
[
- (False, m_cls, 1, 1, 1, {}),
- (False, 'name', m_cls, 1, 1, {}),
- (False, 'name', 1, m_cls, 1, {}),
- (False, 'name', 1, 1, m_cls, {}),
- (False, 'name', 1, 1, 1, m_cls),
+ (False, m_cls, {}),
+ (False, 'name', m_cls),
- (True, 'name', 1, 1, 1, {}),
+ (True, 'name', {}),
]
)
- def test_node_template_model_creation(self, service_storage, is_valid, name, default_instances,
- max_instances, min_instances, properties):
+ def test_node_template_model_creation(self, service_storage, is_valid, name, properties):
node_template = _test_model(
is_valid=is_valid,
storage=service_storage,
@@ -525,9 +521,6 @@ class TestNodeTemplate(object):
model_kwargs=dict(
name=name,
type=service_storage.type.list()[0],
- default_instances=default_instances,
- max_instances=max_instances,
- min_instances=min_instances,
properties=properties,
service_template=service_storage.service_template.list()[0]
))
@@ -616,9 +609,6 @@ class TestNodeHostAddress(object):
kwargs = dict(
name='node_template',
type=storage.type.list()[0],
- default_instances=1,
- max_instances=1,
- min_instances=1,
service_template=storage.service_template.list()[0]
)
if host_address:
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/tests/orchestrator/context/test_operation.py
----------------------------------------------------------------------
diff --git a/tests/orchestrator/context/test_operation.py b/tests/orchestrator/context/test_operation.py
index 3dcfaa2..91ac6bb 100644
--- a/tests/orchestrator/context/test_operation.py
+++ b/tests/orchestrator/context/test_operation.py
@@ -476,7 +476,7 @@ def operation_common(ctx, holder):
holder['actor_name'] = ctx.task.actor.name
holder['task_name'] = ctx.task.name
holder['function'] = ctx.task.function
- holder['arguments'] = dict(i.unwrapped for i in ctx.task.arguments.values())
+ holder['arguments'] = dict(i.unwrapped for i in ctx.task.arguments.itervalues())
@operation
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/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 4d53f9b..266bb0e 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
@@ -273,6 +273,7 @@ topology_template:
type: openstack.Scaling
properties:
bandwidth_threshold: 2 GB
+ default_instances: 2
targets: # node templates or groups
- node_cellar_group
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/acfc7f46/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 de5fb47..99ee902 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
@@ -15,6 +15,7 @@
imports:
- os.yaml
+ - aria-1.0
dsl_definitions:
@@ -169,7 +170,7 @@ policy_types:
openstack.Scaling:
description: >-
OpenStack scaling policy.
- derived_from: tosca.policies.Scaling
+ derived_from: aria.Scaling
properties:
bandwidth_threshold:
type: scalar-unit.size