[1/2] incubator-ariatosca git commit: Generifying ARIA models [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-39-Genericize-storage-models b3b3c770b -> 3ca93f152 (forced update) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3ca93f15/tests/orchestrator/workflows/core/test_engine.py -- diff --git a/tests/orchestrator/workflows/core/test_engine.py b/tests/orchestrator/workflows/core/test_engine.py index baded7f..a6b55ba 100644 --- a/tests/orchestrator/workflows/core/test_engine.py +++ b/tests/orchestrator/workflows/core/test_engine.py @@ -23,7 +23,7 @@ from aria.orchestrator import ( workflow, operation, ) -from aria.storage import models +from aria.storage import model from aria.orchestrator.workflows import ( api, exceptions, @@ -146,7 +146,7 @@ class TestEngine(BaseTest): execution = workflow_context.execution assert execution.started_at <= execution.ended_at <= datetime.utcnow() assert execution.error is None -assert execution.status == models.Execution.TERMINATED +assert execution.status == model.Execution.TERMINATED def test_single_task_successful_execution(self, workflow_context, executor): @workflow @@ -175,7 +175,7 @@ class TestEngine(BaseTest): execution = workflow_context.execution assert execution.started_at <= execution.ended_at <= datetime.utcnow() assert execution.error is not None -assert execution.status == models.Execution.FAILED +assert execution.status == model.Execution.FAILED def test_two_tasks_execution_order(self, workflow_context, executor): @workflow @@ -236,7 +236,7 @@ class TestCancel(BaseTest): execution = workflow_context.execution assert execution.started_at <= execution.ended_at <= datetime.utcnow() assert execution.error is None -assert execution.status == models.Execution.CANCELLED +assert execution.status == model.Execution.CANCELLED def test_cancel_pending_execution(self, workflow_context, executor): @workflow @@ -247,7 +247,7 @@ class TestCancel(BaseTest): executor=executor) eng.cancel_execution() execution = workflow_context.execution -assert execution.status == models.Execution.CANCELLED +assert execution.status == model.Execution.CANCELLED class TestRetries(BaseTest): http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3ca93f15/tests/orchestrator/workflows/executor/test_executor.py -- diff --git a/tests/orchestrator/workflows/executor/test_executor.py b/tests/orchestrator/workflows/executor/test_executor.py index 7a11524..b15e8c3 100644 --- a/tests/orchestrator/workflows/executor/test_executor.py +++ b/tests/orchestrator/workflows/executor/test_executor.py @@ -21,6 +21,7 @@ from contextlib import contextmanager import pytest import retrying + try: import celery as _celery app = _celery.Celery() @@ -30,7 +31,7 @@ except ImportError: app = None import aria -from aria.storage import models +from aria.storage import model from aria.orchestrator import events from aria.orchestrator.workflows.executor import ( thread, @@ -82,7 +83,7 @@ class MockException(Exception): class MockTask(object): -INFINITE_RETRIES = models.Task.INFINITE_RETRIES +INFINITE_RETRIES = model.Task.INFINITE_RETRIES def __init__(self, func, inputs=None, ctx=None): self.states = [] @@ -99,7 +100,7 @@ class MockTask(object): self.max_attempts = 1 self.plugin_id = None -for state in models.Task.STATES: +for state in model.Task.STATES: setattr(self, state.upper(), state) @contextmanager http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3ca93f15/tests/orchestrator/workflows/executor/test_process_executor.py -- diff --git a/tests/orchestrator/workflows/executor/test_process_executor.py b/tests/orchestrator/workflows/executor/test_process_executor.py index 364d354..2e4af1f 100644 --- a/tests/orchestrator/workflows/executor/test_process_executor.py +++ b/tests/orchestrator/workflows/executor/test_process_executor.py @@ -22,7 +22,7 @@ from contextlib import contextmanager import pytest from aria import application_model_storage -from aria.storage import models +from aria.storage import model as aria_model from aria.utils.plugin import create as create_plugin from aria.storage.sql_mapi import SQLAlchemyModelAPI from aria.orchestrator import events @@ -108,7 +108,7 @@ def mock_plugin(plugin_manager, tmpdir): class MockTask(object): -INFINITE_RETRIES = models.Task.INFINITE_RETRIES +INFINITE_RETRIES = aria_model.Task.INFINITE_RETRIES def __init__(self, plugin, operation): self.id =
[3/4] incubator-ariatosca git commit: Generifying ARIA models
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/6e1f1260/tests/orchestrator/workflows/core/test_engine.py -- diff --git a/tests/orchestrator/workflows/core/test_engine.py b/tests/orchestrator/workflows/core/test_engine.py index baded7f..a6b55ba 100644 --- a/tests/orchestrator/workflows/core/test_engine.py +++ b/tests/orchestrator/workflows/core/test_engine.py @@ -23,7 +23,7 @@ from aria.orchestrator import ( workflow, operation, ) -from aria.storage import models +from aria.storage import model from aria.orchestrator.workflows import ( api, exceptions, @@ -146,7 +146,7 @@ class TestEngine(BaseTest): execution = workflow_context.execution assert execution.started_at <= execution.ended_at <= datetime.utcnow() assert execution.error is None -assert execution.status == models.Execution.TERMINATED +assert execution.status == model.Execution.TERMINATED def test_single_task_successful_execution(self, workflow_context, executor): @workflow @@ -175,7 +175,7 @@ class TestEngine(BaseTest): execution = workflow_context.execution assert execution.started_at <= execution.ended_at <= datetime.utcnow() assert execution.error is not None -assert execution.status == models.Execution.FAILED +assert execution.status == model.Execution.FAILED def test_two_tasks_execution_order(self, workflow_context, executor): @workflow @@ -236,7 +236,7 @@ class TestCancel(BaseTest): execution = workflow_context.execution assert execution.started_at <= execution.ended_at <= datetime.utcnow() assert execution.error is None -assert execution.status == models.Execution.CANCELLED +assert execution.status == model.Execution.CANCELLED def test_cancel_pending_execution(self, workflow_context, executor): @workflow @@ -247,7 +247,7 @@ class TestCancel(BaseTest): executor=executor) eng.cancel_execution() execution = workflow_context.execution -assert execution.status == models.Execution.CANCELLED +assert execution.status == model.Execution.CANCELLED class TestRetries(BaseTest): http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/6e1f1260/tests/orchestrator/workflows/executor/test_executor.py -- diff --git a/tests/orchestrator/workflows/executor/test_executor.py b/tests/orchestrator/workflows/executor/test_executor.py index 7a11524..ff4b8b2 100644 --- a/tests/orchestrator/workflows/executor/test_executor.py +++ b/tests/orchestrator/workflows/executor/test_executor.py @@ -21,6 +21,8 @@ from contextlib import contextmanager import pytest import retrying +from aria.storage import model + try: import celery as _celery app = _celery.Celery() @@ -30,7 +32,6 @@ except ImportError: app = None import aria -from aria.storage import models from aria.orchestrator import events from aria.orchestrator.workflows.executor import ( thread, @@ -82,7 +83,7 @@ class MockException(Exception): class MockTask(object): -INFINITE_RETRIES = models.Task.INFINITE_RETRIES +INFINITE_RETRIES = model.Task.INFINITE_RETRIES def __init__(self, func, inputs=None, ctx=None): self.states = [] @@ -99,7 +100,7 @@ class MockTask(object): self.max_attempts = 1 self.plugin_id = None -for state in models.Task.STATES: +for state in model.Task.STATES: setattr(self, state.upper(), state) @contextmanager http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/6e1f1260/tests/orchestrator/workflows/executor/test_process_executor.py -- diff --git a/tests/orchestrator/workflows/executor/test_process_executor.py b/tests/orchestrator/workflows/executor/test_process_executor.py index 364d354..2e4af1f 100644 --- a/tests/orchestrator/workflows/executor/test_process_executor.py +++ b/tests/orchestrator/workflows/executor/test_process_executor.py @@ -22,7 +22,7 @@ from contextlib import contextmanager import pytest from aria import application_model_storage -from aria.storage import models +from aria.storage import model as aria_model from aria.utils.plugin import create as create_plugin from aria.storage.sql_mapi import SQLAlchemyModelAPI from aria.orchestrator import events @@ -108,7 +108,7 @@ def mock_plugin(plugin_manager, tmpdir): class MockTask(object): -INFINITE_RETRIES = models.Task.INFINITE_RETRIES +INFINITE_RETRIES = aria_model.Task.INFINITE_RETRIES def __init__(self, plugin, operation): self.id = str(uuid.uuid4()) @@ -122,7 +122,7 @@ class MockTask(object): self.plugin_id = plugin.id self.plugin = plugin -for state in
[4/4] incubator-ariatosca git commit: Generifying ARIA models
Generifying ARIA models Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/6e1f1260 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/6e1f1260 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/6e1f1260 Branch: refs/heads/ARIA-39-Genericize-storage-models Commit: 6e1f1260f2e1ed10c4f44e2f4dd3dd165e58c9ba Parents: 5cf84ee Author: mxmrlvAuthored: Mon Dec 12 00:50:09 2016 +0200 Committer: mxmrlv Committed: Tue Dec 20 16:59:50 2016 +0200 -- aria/__init__.py| 25 +- aria/orchestrator/context/workflow.py | 10 +- aria/orchestrator/workflows/api/task.py | 10 +- aria/orchestrator/workflows/builtin/heal.py | 11 +- aria/orchestrator/workflows/core/engine.py | 17 +- aria/orchestrator/workflows/core/task.py| 23 +- aria/storage/__init__.py| 12 +- aria/storage/base_model.py | 677 +++ aria/storage/core.py| 2 +- aria/storage/model.py | 110 +++ aria/storage/models.py | 575 aria/storage/structure.py | 180 + aria/storage/structures.py | 244 --- aria/storage/type.py| 123 tests/mock/models.py| 49 +- tests/orchestrator/context/test_toolbelt.py | 8 +- .../orchestrator/workflows/builtin/test_heal.py | 4 +- .../orchestrator/workflows/core/test_engine.py | 10 +- .../workflows/executor/test_executor.py | 7 +- .../workflows/executor/test_process_executor.py | 6 +- tests/storage/__init__.py | 7 +- tests/storage/test_model_storage.py | 64 +- tests/storage/test_models.py| 195 +++--- 23 files changed, 1306 insertions(+), 1063 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/6e1f1260/aria/__init__.py -- diff --git a/aria/__init__.py b/aria/__init__.py index 0f7bec6..a39d58b 100644 --- a/aria/__init__.py +++ b/aria/__init__.py @@ -64,22 +64,21 @@ def application_model_storage(api, api_kwargs=None): Initiate model storage for the supplied storage driver """ models = [ -storage.models.Plugin, -storage.models.ProviderContext, +storage.model.Plugin, -storage.models.Blueprint, -storage.models.Deployment, -storage.models.DeploymentUpdate, -storage.models.DeploymentUpdateStep, -storage.models.DeploymentModification, +storage.model.Blueprint, +storage.model.Deployment, +storage.model.DeploymentUpdate, +storage.model.DeploymentUpdateStep, +storage.model.DeploymentModification, -storage.models.Node, -storage.models.NodeInstance, -storage.models.Relationship, -storage.models.RelationshipInstance, +storage.model.Node, +storage.model.NodeInstance, +storage.model.Relationship, +storage.model.RelationshipInstance, -storage.models.Execution, -storage.models.Task, +storage.model.Execution, +storage.model.Task, ] # if api not in _model_storage: return storage.ModelStorage(api, items=models, api_kwargs=api_kwargs or {}) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/6e1f1260/aria/orchestrator/context/workflow.py -- diff --git a/aria/orchestrator/context/workflow.py b/aria/orchestrator/context/workflow.py index e2e8e25..7f53a9c 100644 --- a/aria/orchestrator/context/workflow.py +++ b/aria/orchestrator/context/workflow.py @@ -46,8 +46,7 @@ class WorkflowContext(BaseContext): execution_cls = self.model.execution.model_cls now = datetime.utcnow() execution = self.model.execution.model_cls( -blueprint_id=self.blueprint.id, -deployment_id=self.deployment.id, +deployment=self.deployment, workflow_name=self._workflow_name, created_at=now, status=execution_cls.PENDING, @@ -75,9 +74,11 @@ class WorkflowContext(BaseContext): """ Iterator over nodes """ +key = 'deployment_{0}'.format(self.model.node_instance.model_cls.name_column_name()) + return self.model.node.iter( filters={ -'deployment_id': self.deployment.id +key: getattr(self.deployment, self.deployment.name_column_name()) } ) @@ -86,9
[1/2] incubator-ariatosca git commit: Generifying ARIA models [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-39-Genericize-storage-models 6e1f1260f -> b3b3c770b (forced update) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b3b3c770/tests/orchestrator/workflows/core/test_engine.py -- diff --git a/tests/orchestrator/workflows/core/test_engine.py b/tests/orchestrator/workflows/core/test_engine.py index baded7f..a6b55ba 100644 --- a/tests/orchestrator/workflows/core/test_engine.py +++ b/tests/orchestrator/workflows/core/test_engine.py @@ -23,7 +23,7 @@ from aria.orchestrator import ( workflow, operation, ) -from aria.storage import models +from aria.storage import model from aria.orchestrator.workflows import ( api, exceptions, @@ -146,7 +146,7 @@ class TestEngine(BaseTest): execution = workflow_context.execution assert execution.started_at <= execution.ended_at <= datetime.utcnow() assert execution.error is None -assert execution.status == models.Execution.TERMINATED +assert execution.status == model.Execution.TERMINATED def test_single_task_successful_execution(self, workflow_context, executor): @workflow @@ -175,7 +175,7 @@ class TestEngine(BaseTest): execution = workflow_context.execution assert execution.started_at <= execution.ended_at <= datetime.utcnow() assert execution.error is not None -assert execution.status == models.Execution.FAILED +assert execution.status == model.Execution.FAILED def test_two_tasks_execution_order(self, workflow_context, executor): @workflow @@ -236,7 +236,7 @@ class TestCancel(BaseTest): execution = workflow_context.execution assert execution.started_at <= execution.ended_at <= datetime.utcnow() assert execution.error is None -assert execution.status == models.Execution.CANCELLED +assert execution.status == model.Execution.CANCELLED def test_cancel_pending_execution(self, workflow_context, executor): @workflow @@ -247,7 +247,7 @@ class TestCancel(BaseTest): executor=executor) eng.cancel_execution() execution = workflow_context.execution -assert execution.status == models.Execution.CANCELLED +assert execution.status == model.Execution.CANCELLED class TestRetries(BaseTest): http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b3b3c770/tests/orchestrator/workflows/executor/test_executor.py -- diff --git a/tests/orchestrator/workflows/executor/test_executor.py b/tests/orchestrator/workflows/executor/test_executor.py index 7a11524..ff4b8b2 100644 --- a/tests/orchestrator/workflows/executor/test_executor.py +++ b/tests/orchestrator/workflows/executor/test_executor.py @@ -21,6 +21,8 @@ from contextlib import contextmanager import pytest import retrying +from aria.storage import model + try: import celery as _celery app = _celery.Celery() @@ -30,7 +32,6 @@ except ImportError: app = None import aria -from aria.storage import models from aria.orchestrator import events from aria.orchestrator.workflows.executor import ( thread, @@ -82,7 +83,7 @@ class MockException(Exception): class MockTask(object): -INFINITE_RETRIES = models.Task.INFINITE_RETRIES +INFINITE_RETRIES = model.Task.INFINITE_RETRIES def __init__(self, func, inputs=None, ctx=None): self.states = [] @@ -99,7 +100,7 @@ class MockTask(object): self.max_attempts = 1 self.plugin_id = None -for state in models.Task.STATES: +for state in model.Task.STATES: setattr(self, state.upper(), state) @contextmanager http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/b3b3c770/tests/orchestrator/workflows/executor/test_process_executor.py -- diff --git a/tests/orchestrator/workflows/executor/test_process_executor.py b/tests/orchestrator/workflows/executor/test_process_executor.py index 364d354..2e4af1f 100644 --- a/tests/orchestrator/workflows/executor/test_process_executor.py +++ b/tests/orchestrator/workflows/executor/test_process_executor.py @@ -22,7 +22,7 @@ from contextlib import contextmanager import pytest from aria import application_model_storage -from aria.storage import models +from aria.storage import model as aria_model from aria.utils.plugin import create as create_plugin from aria.storage.sql_mapi import SQLAlchemyModelAPI from aria.orchestrator import events @@ -108,7 +108,7 @@ def mock_plugin(plugin_manager, tmpdir): class MockTask(object): -INFINITE_RETRIES = models.Task.INFINITE_RETRIES +INFINITE_RETRIES = aria_model.Task.INFINITE_RETRIES def __init__(self, plugin, operation): self.id =
[1/4] incubator-ariatosca git commit: ARIA-31 Add registry mechanism for extensions [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-39-Genericize-storage-models 3cca6f5ed -> 6e1f1260f (forced update) ARIA-31 Add registry mechanism for extensions Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/04c9bd07 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/04c9bd07 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/04c9bd07 Branch: refs/heads/ARIA-39-Genericize-storage-models Commit: 04c9bd07916f957ddd88b933067266177a242a42 Parents: c6c92ae Author: Dan KilmanAuthored: Mon Dec 5 15:28:29 2016 +0200 Committer: Dan Kilman Committed: Sun Dec 11 19:26:28 2016 +0200 -- aria/__init__.py| 25 +-- aria/cli/commands.py| 9 +- aria/extension.py | 125 +++ aria/orchestrator/events.py | 36 + aria/orchestrator/events/__init__.py| 57 --- .../events/builtin_event_handler.py | 123 --- .../events/workflow_engine_event_handler.py | 74 - aria/orchestrator/workflows/__init__.py | 3 + aria/orchestrator/workflows/core/engine.py | 2 + .../workflows/core/events_handler.py| 113 ++ aria/orchestrator/workflows/events_logging.py | 65 aria/parser/__init__.py | 5 +- aria/parser/loading/__init__.py | 3 +- aria/parser/loading/uri.py | 5 +- aria/parser/presentation/__init__.py| 3 +- aria/parser/presentation/source.py | 7 +- aria/parser/specification.py| 6 +- aria/storage/structures.py | 4 +- aria/utils/plugin.py| 39 - aria/utils/threading.py | 7 +- extensions/aria_extension_tosca/__init__.py | 52 --- .../simple_v1_0/data_types.py | 5 +- requirements.txt| 1 + tests/orchestrator/conftest.py | 23 +++ tests/orchestrator/events/__init__.py | 14 -- .../events/test_builtin_event_handlers.py | 14 -- .../test_workflow_enginge_event_handlers.py | 0 .../workflows/executor/test_executor.py | 16 +- tests/test_extension.py | 156 +++ 29 files changed, 602 insertions(+), 390 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/04c9bd07/aria/__init__.py -- diff --git a/aria/__init__.py b/aria/__init__.py index b000397..0f7bec6 100644 --- a/aria/__init__.py +++ b/aria/__init__.py @@ -17,13 +17,18 @@ Aria top level package """ -import sys import pkgutil +try: +import pkg_resources +except ImportError: +pkg_resources = None + from .VERSION import version as __version__ from .orchestrator.decorators import workflow, operation from . import ( +extension, utils, parser, storage, @@ -41,19 +46,17 @@ _resource_storage = {} def install_aria_extensions(): """ -Iterates all Python packages with names beginning with :code:`aria_extension_` and calls -their :code:`install_aria_extension` function if they have it. +Iterates all Python packages with names beginning with :code:`aria_extension_` and all +:code:`aria_extension` entry points and loads them. +It then invokes all registered extension functions. """ - for loader, module_name, _ in pkgutil.iter_modules(): if module_name.startswith('aria_extension_'): -module = loader.find_module(module_name).load_module(module_name) - -if hasattr(module, 'install_aria_extension'): -module.install_aria_extension() - -# Loading the module has contaminated sys.modules, so we'll clean it up -del sys.modules[module_name] +loader.find_module(module_name).load_module(module_name) +if pkg_resources: +for entry_point in pkg_resources.iter_entry_points(group='aria_extension'): +entry_point.load() +extension.init() def application_model_storage(api, api_kwargs=None): http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/04c9bd07/aria/cli/commands.py -- diff --git a/aria/cli/commands.py b/aria/cli/commands.py index 3426bb0..141da07 100644 --- a/aria/cli/commands.py +++ b/aria/cli/commands.py @@ -28,13 +28,14 @@ from importlib import import_module from yaml import safe_load, YAMLError +from .. import extension
incubator-ariatosca git commit: lynting and reordering
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-39-Genericize-storage-models ee4209616 -> 3cca6f5ed lynting and reordering Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/3cca6f5e Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/3cca6f5e Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/3cca6f5e Branch: refs/heads/ARIA-39-Genericize-storage-models Commit: 3cca6f5ed22da936676a467e06b16c1f1c8a1ac2 Parents: ee42096 Author: mxmrlvAuthored: Tue Dec 20 16:28:24 2016 +0200 Committer: mxmrlv Committed: Tue Dec 20 16:28:24 2016 +0200 -- aria/orchestrator/context/workflow.py | 8 +-- aria/storage/base_model.py| 89 - aria/storage/model.py | 10 +-- aria/storage/structure.py | 41 tests/storage/test_model_storage.py | 4 +- tests/storage/test_models.py | 100 +++-- 6 files changed, 119 insertions(+), 133 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3cca6f5e/aria/orchestrator/context/workflow.py -- diff --git a/aria/orchestrator/context/workflow.py b/aria/orchestrator/context/workflow.py index feca33a..7f53a9c 100644 --- a/aria/orchestrator/context/workflow.py +++ b/aria/orchestrator/context/workflow.py @@ -74,11 +74,11 @@ class WorkflowContext(BaseContext): """ Iterator over nodes """ -key = 'deployment_{0}'.format(self.model.node_instance.model_cls.user_id_column()) +key = 'deployment_{0}'.format(self.model.node_instance.model_cls.name_column_name()) return self.model.node.iter( filters={ -key: getattr(self.deployment, self.deployment.user_id_column()) +key: getattr(self.deployment, self.deployment.name_column_name()) } ) @@ -87,10 +87,10 @@ class WorkflowContext(BaseContext): """ Iterator over node instances """ -key = 'deployment_{0}'.format(self.model.node_instance.model_cls.user_id_column()) +key = 'deployment_{0}'.format(self.model.node_instance.model_cls.name_column_name()) return self.model.node_instance.iter( filters={ -key: getattr(self.deployment, self.deployment.user_id_column()) +key: getattr(self.deployment, self.deployment.name_column_name()) } ) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/3cca6f5e/aria/storage/base_model.py -- diff --git a/aria/storage/base_model.py b/aria/storage/base_model.py index 352f121..92a1656 100644 --- a/aria/storage/base_model.py +++ b/aria/storage/base_model.py @@ -52,7 +52,7 @@ from sqlalchemy import ( orm, ) -from .structure import ModelBase +from .structure import ModelMixin from .type import ( List, @@ -74,10 +74,10 @@ __all__ = ( 'TaskBase' ) -#pylint: disable=no-self-argument +#pylint: disable=no-self-argument, abstract-method -class BlueprintBase(ModelBase): +class BlueprintBase(ModelMixin): """ Blueprint model representation. """ @@ -90,7 +90,7 @@ class BlueprintBase(ModelBase): description = Column(Text) -class DeploymentBase(ModelBase): +class DeploymentBase(ModelMixin): """ Deployment model representation. """ @@ -120,15 +120,14 @@ class DeploymentBase(ModelBase): @declared_attr def blueprint_name(cls): -return association_proxy('blueprint', cls.user_id_column()) +return association_proxy('blueprint', cls.name_column_name()) -class ExecutionBase(ModelBase): +class ExecutionBase(ModelMixin): """ Execution model representation. """ # Needed only for pylint. the id will be populated by sqlalcehmy and the proper column. -id = None __tablename__ = 'executions' _private_fields = ['deployment_fk'] @@ -189,7 +188,7 @@ class ExecutionBase(ModelBase): @declared_attr def deployment_name(cls): -return association_proxy('deployment', cls.user_id_column()) +return association_proxy('deployment', cls.name_column_name()) @declared_attr def blueprint_name(cls): @@ -198,12 +197,12 @@ class ExecutionBase(ModelBase): def __str__(self): return '<{0} id=`{1}` (status={2})>'.format( self.__class__.__name__, -self.id, +getattr(self, self.name_column_name()), self.status ) -class DeploymentUpdateBase(ModelBase): +class
incubator-ariatosca git commit: cleaned up relationship and foreign key creation [Forced Update!]
Repository: incubator-ariatosca Updated Branches: refs/heads/ARIA-39-Genericize-storage-models 58c845872 -> 17e02e5e2 (forced update) cleaned up relationship and foreign key creation Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/17e02e5e Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/17e02e5e Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/17e02e5e Branch: refs/heads/ARIA-39-Genericize-storage-models Commit: 17e02e5e2dbabb2c732e42fc0464ff31beec521b Parents: 24b55da Author: mxmrlvAuthored: Mon Dec 19 19:17:40 2016 +0200 Committer: mxmrlv Committed: Tue Dec 20 11:42:52 2016 +0200 -- aria/orchestrator/context/workflow.py | 7 +- aria/orchestrator/workflows/builtin/heal.py | 9 +- aria/storage/base_model.py | 188 --- aria/storage/core.py| 2 +- aria/storage/model.py | 6 +- aria/storage/structure.py | 84 +- tests/orchestrator/context/test_toolbelt.py | 2 +- tests/storage/test_models.py| 15 +- 8 files changed, 164 insertions(+), 149 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/17e02e5e/aria/orchestrator/context/workflow.py -- diff --git a/aria/orchestrator/context/workflow.py b/aria/orchestrator/context/workflow.py index 1365888..feca33a 100644 --- a/aria/orchestrator/context/workflow.py +++ b/aria/orchestrator/context/workflow.py @@ -74,9 +74,11 @@ class WorkflowContext(BaseContext): """ Iterator over nodes """ +key = 'deployment_{0}'.format(self.model.node_instance.model_cls.user_id_column()) + return self.model.node.iter( filters={ -'deployment_id': getattr(self.deployment, self.deployment.user_id_column()) +key: getattr(self.deployment, self.deployment.user_id_column()) } ) @@ -85,9 +87,10 @@ class WorkflowContext(BaseContext): """ Iterator over node instances """ +key = 'deployment_{0}'.format(self.model.node_instance.model_cls.user_id_column()) return self.model.node_instance.iter( filters={ -'deployment_id': getattr(self.deployment, self.deployment.user_id_column()) +key: getattr(self.deployment, self.deployment.user_id_column()) } ) http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/17e02e5e/aria/orchestrator/workflows/builtin/heal.py -- diff --git a/aria/orchestrator/workflows/builtin/heal.py b/aria/orchestrator/workflows/builtin/heal.py index dcf398c..406a42a 100644 --- a/aria/orchestrator/workflows/builtin/heal.py +++ b/aria/orchestrator/workflows/builtin/heal.py @@ -163,10 +163,11 @@ def heal_install(ctx, graph, failing_node_instances, targeted_node_instances): def _get_contained_subgraph(context, host_node_instance): -contained_instances = [node_instance - for node_instance in context.node_instances - if node_instance.host_id == host_node_instance.id and - node_instance.id != node_instance.host_id] +contained_instances = [ +node_instance +for node_instance in context.node_instances +if node_instance == host_node_instance and node_instance != node_instance +] result = [host_node_instance] if not contained_instances: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/17e02e5e/aria/storage/base_model.py -- diff --git a/aria/storage/base_model.py b/aria/storage/base_model.py index 1f1a80c..a1e610f 100644 --- a/aria/storage/base_model.py +++ b/aria/storage/base_model.py @@ -112,14 +112,14 @@ class DeploymentBase(ModelBase): @declared_attr def blueprint_fk(cls): -return cls.foreign_key('blueprints', nullable=False) +return cls.foreign_key(BlueprintBase, nullable=False) @declared_attr def blueprint(cls): -return cls.one_to_many_relationship('blueprint_fk', 'Blueprint') +return cls.one_to_many_relationship('blueprint_fk') @declared_attr -def blueprint_id(cls): +def blueprint_name(cls): return association_proxy('blueprint', cls.user_id_column()) @@ -175,21 +175,26 @@ class ExecutionBase(ModelBase): status = Column(Enum(*STATES, name='execution_status'), default=PENDING) workflow_name = Column(Text) -blueprint =