Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-258-Convert-runtime-properties-to-attributes e6e75a1d2 -> 6baadc0c9
removed runtime_properties from code Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/6baadc0c Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/6baadc0c Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/6baadc0c Branch: refs/heads/ARIA-258-Convert-runtime-properties-to-attributes Commit: 6baadc0c9fe9bb6dc1051d6f144067867db1a12c Parents: e6e75a1 Author: max-orlov <[email protected]> Authored: Wed May 17 14:49:16 2017 +0300 Committer: max-orlov <[email protected]> Committed: Wed May 17 14:49:16 2017 +0300 ---------------------------------------------------------------------- aria/cli/commands/nodes.py | 6 +++--- aria/modeling/service_instance.py | 1 - aria/modeling/service_template.py | 1 - aria/orchestrator/context/toolbelt.py | 3 ++- tests/mock/models.py | 7 ++----- tests/modeling/test_mixins.py | 1 - tests/modeling/test_models.py | 26 ++++++++++-------------- tests/orchestrator/context/test_toolbelt.py | 5 +++-- 8 files changed, 21 insertions(+), 29 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/6baadc0c/aria/cli/commands/nodes.py ---------------------------------------------------------------------- diff --git a/aria/cli/commands/nodes.py b/aria/cli/commands/nodes.py index e43493f..1bbefe6 100644 --- a/aria/cli/commands/nodes.py +++ b/aria/cli/commands/nodes.py @@ -47,9 +47,9 @@ def show(node_id, model_storage, logger): # print node attributes logger.info('Node attributes:') - if node.runtime_properties: - for prop_name, prop_value in node.runtime_properties.iteritems(): - logger.info('\t{0}: {1}'.format(prop_name, prop_value)) + if node.attributes: + for param_name, param in node.attributes.iteritems(): + logger.info('\t{0}: {1}'.format(param_name, param.value)) else: logger.info('\tNo attributes') http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/6baadc0c/aria/modeling/service_instance.py ---------------------------------------------------------------------- diff --git a/aria/modeling/service_instance.py b/aria/modeling/service_instance.py index 0f83ef5..cf9298b 100644 --- a/aria/modeling/service_instance.py +++ b/aria/modeling/service_instance.py @@ -520,7 +520,6 @@ class NodeBase(InstanceModelMixin): # endregion description = Column(Text) - runtime_properties = Column(modeling_types.Dict) state = Column(Enum(*STATES, name='node_state'), nullable=False, default=INITIAL) version = Column(Integer, default=1) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/6baadc0c/aria/modeling/service_template.py ---------------------------------------------------------------------- diff --git a/aria/modeling/service_template.py b/aria/modeling/service_template.py index 7eb35bd..9aeceb1 100644 --- a/aria/modeling/service_template.py +++ b/aria/modeling/service_template.py @@ -566,7 +566,6 @@ class NodeTemplateBase(TemplateModelMixin): type=self.type, description=deepcopy_with_locators(self.description), state=models.Node.INITIAL, - runtime_properties={}, node_template=self) utils.instantiate_dict(node, node.properties, self.properties) utils.instantiate_dict(node, node.attributes, self.attributes) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/6baadc0c/aria/orchestrator/context/toolbelt.py ---------------------------------------------------------------------- diff --git a/aria/orchestrator/context/toolbelt.py b/aria/orchestrator/context/toolbelt.py index def7d42..410623e 100644 --- a/aria/orchestrator/context/toolbelt.py +++ b/aria/orchestrator/context/toolbelt.py @@ -34,7 +34,8 @@ class NodeToolBelt(object): """ assert isinstance(self._op_context, operation.NodeOperationContext) host = self._op_context.node.host - return host.runtime_properties.get('ip') + return getattr(host.attributes.get('ip'), 'value', None) + class RelationshipToolBelt(object): http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/6baadc0c/tests/mock/models.py ---------------------------------------------------------------------- diff --git a/tests/mock/models.py b/tests/mock/models.py index f066551..2ec4b7a 100644 --- a/tests/mock/models.py +++ b/tests/mock/models.py @@ -120,7 +120,7 @@ def create_node_with_dependencies(include_attribute=False): node_template.service_template.services[0] = create_service(node_template.service_template) node = create_node(node_template, node_template.service_template.services[0]) if include_attribute: - node.runtime_properties = {'attribute1': 'value1'} + node.attributes['attribute1'] = models.Parameter.wrap('attribute1', 'value1') return node @@ -184,13 +184,10 @@ def create_dependent_node_template( ) -def create_node(dependency_node_template, service, name=NODE_NAME, state=models.Node.INITIAL, - runtime_properties=None): - runtime_properties = runtime_properties or {} +def create_node(dependency_node_template, service, name=NODE_NAME, state=models.Node.INITIAL): node = models.Node( name=name, type=dependency_node_template.type, - runtime_properties=runtime_properties, version=None, node_template=dependency_node_template, state=state, http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/6baadc0c/tests/modeling/test_mixins.py ---------------------------------------------------------------------- diff --git a/tests/modeling/test_mixins.py b/tests/modeling/test_mixins.py index a18a04e..2c91a4b 100644 --- a/tests/modeling/test_mixins.py +++ b/tests/modeling/test_mixins.py @@ -121,7 +121,6 @@ def test_relationship_model_ordering(context): new_node = modeling.models.Node( name='new_node', type=source_node.type, - runtime_properties={}, service=service, version=None, node_template=new_node_template, http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/6baadc0c/tests/modeling/test_models.py ---------------------------------------------------------------------- diff --git a/tests/modeling/test_models.py b/tests/modeling/test_models.py index 86e8482..57511dd 100644 --- a/tests/modeling/test_models.py +++ b/tests/modeling/test_models.py @@ -538,22 +538,20 @@ class TestNodeTemplate(object): class TestNode(object): @pytest.mark.parametrize( - 'is_valid, name, runtime_properties, state, version', + 'is_valid, name, state, version', [ - (False, m_cls, {}, 'state', 1), - (False, 'name', m_cls, 'state', 1), - (False, 'name', {}, 'state', 1), - (False, 'name', {}, m_cls, 1), - (False, m_cls, {}, 'state', m_cls), - - (True, 'name', {}, 'initial', 1), - (True, None, {}, 'initial', 1), - (True, 'name', None, 'initial', 1), - (True, 'name', {}, 'initial', None), + (False, m_cls, 'state', 1), + (False, 'name', 'state', 1), + (False, 'name', m_cls, 1), + (False, m_cls, 'state', m_cls), + + (True, 'name', 'initial', 1), + (True, None, 'initial', 1), + (True, 'name', 'initial', 1), + (True, 'name', 'initial', None), ] ) - def test_node_model_creation(self, node_template_storage, is_valid, name, runtime_properties, - state, version): + def test_node_model_creation(self, node_template_storage, is_valid, name, state, version): node = _test_model( is_valid=is_valid, storage=node_template_storage, @@ -562,7 +560,6 @@ class TestNode(object): node_template=node_template_storage.node_template.list()[0], type=node_template_storage.type.list()[0], name=name, - runtime_properties=runtime_properties, state=state, version=version, service=node_template_storage.service.list()[0] @@ -635,7 +632,6 @@ class TestNodeHostAddress(object): name='node', node_template=node_template, type=storage.type.list()[0], - runtime_properties={}, state='initial', service=storage.service.list()[0] ) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/6baadc0c/tests/orchestrator/context/test_toolbelt.py ---------------------------------------------------------------------- diff --git a/tests/orchestrator/context/test_toolbelt.py b/tests/orchestrator/context/test_toolbelt.py index d199954..fc34907 100644 --- a/tests/orchestrator/context/test_toolbelt.py +++ b/tests/orchestrator/context/test_toolbelt.py @@ -16,6 +16,7 @@ import pytest from aria import workflow, operation +from aria.modeling import models from aria.orchestrator import context from aria.orchestrator.workflows import api from aria.orchestrator.workflows.executor import thread @@ -93,7 +94,7 @@ def test_host_ip(workflow_context, executor, dataholder): operation_kwargs=dict(implementation=op_path(host_ip, module_path=__name__), inputs=inputs) ) dependency_node.interfaces[interface.name] = interface - dependency_node.runtime_properties['ip'] = '1.1.1.1' + dependency_node.attributes['ip'] = models.Parameter.wrap('ip', '1.1.1.1') workflow_context.model.node.update(dependency_node) @@ -110,7 +111,7 @@ def test_host_ip(workflow_context, executor, dataholder): execute(workflow_func=basic_workflow, workflow_context=workflow_context, executor=executor) - assert dataholder.get('host_ip') == dependency_node.runtime_properties.get('ip') + assert dataholder.get('host_ip') == dependency_node.attributes.get('ip').value def test_relationship_tool_belt(workflow_context, executor, dataholder):
