ariatosca-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject incubator-ariatosca git commit: integrated operation configuration into service instantiation process; fixed plugin resolve method storage usage; fixed a bug in plugin.enabled implementation
Date Sat, 15 Apr 2017 15:22:32 GMT
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-48-aria-cli b579d1040 -> 59967548e


integrated operation configuration into service instantiation process; fixed plugin resolve
method storage usage; fixed a bug in plugin.enabled implementation


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/59967548
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/59967548
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/59967548

Branch: refs/heads/ARIA-48-aria-cli
Commit: 59967548e2eab2f9644537fea35d52b7ad563276
Parents: b579d10
Author: Ran Ziv <ran@gigaspaces.com>
Authored: Sat Apr 15 18:16:31 2017 +0300
Committer: Ran Ziv <ran@gigaspaces.com>
Committed: Sat Apr 15 18:16:31 2017 +0300

----------------------------------------------------------------------
 aria/core.py                                    | 10 +++-
 aria/modeling/service_template.py               | 49 +++++++++-----------
 .../execution_plugin/instantiation.py           |  2 +-
 aria/parser/consumption/__init__.py             |  2 +-
 aria/parser/consumption/modeling.py             |  3 +-
 5 files changed, 36 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/59967548/aria/core.py
----------------------------------------------------------------------
diff --git a/aria/core.py b/aria/core.py
index 3a89a16..365f39c 100644
--- a/aria/core.py
+++ b/aria/core.py
@@ -68,11 +68,19 @@ class Core(object):
 
         # creating an empty ConsumptionContext, initiating a threadlocal context
         context = consumption.ConsumptionContext()
+
         # setting no autoflush for the duration of instantiation - this helps avoid dependency
         # constraints as they're being set up
         with self.model_storage._all_api_kwargs['session'].no_autoflush:
-            service = service_template.instantiate(None, inputs)
+            service = service_template.instantiate(None, self.model_storage, inputs=inputs)
 
+        self.model_storage._all_api_kwargs['session'].flush()
+        consumption.ConsumerChain(
+            context,
+            (
+                consumption.FindHosts,
+                consumption.ConfigureOperations
+            )).consume()
         if context.validation.dump_issues():
             raise exceptions.InstantiationError('Failed to instantiate service template')
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/59967548/aria/modeling/service_template.py
----------------------------------------------------------------------
diff --git a/aria/modeling/service_template.py b/aria/modeling/service_template.py
index c2da22d..9a07b53 100644
--- a/aria/modeling/service_template.py
+++ b/aria/modeling/service_template.py
@@ -280,7 +280,7 @@ class ServiceTemplateBase(TemplateModelMixin):
             ('interface_types', formatting.as_raw(self.interface_types)),
             ('artifact_types', formatting.as_raw(self.artifact_types))))
 
-    def instantiate(self, container, inputs=None):  # pylint: disable=arguments-differ
+    def instantiate(self, container, model_storage, inputs=None):  # pylint: disable=arguments-differ
         from . import models
         context = ConsumptionContext.get_thread_local()
         now = datetime.now()
@@ -295,7 +295,7 @@ class ServiceTemplateBase(TemplateModelMixin):
 
         for plugin_specification in self.plugin_specifications.itervalues():
             if plugin_specification.enabled:
-                if plugin_specification.resolve():
+                if plugin_specification.resolve(model_storage):
                     plugin = plugin_specification.plugin
                     service.plugins[plugin.name] = plugin
                 else:
@@ -1864,16 +1864,22 @@ class OperationTemplateBase(TemplateModelMixin):
 
     def instantiate(self, container):
         from . import models
-        if self.plugin_specification and self.plugin_specification.enabled:
-            plugin = self.plugin_specification.plugin
-            implementation = self.implementation if plugin is not None else None
-            # "plugin" would be none if a match was not found. In that case, a validation
error
-            # should already have been reported in ServiceTemplateBase.instantiate, so we
will
-            # continue silently here
+        if self.plugin_specification:
+            if self.plugin_specification.enabled:
+                plugin = self.plugin_specification.plugin
+                implementation = self.implementation if plugin is not None else None
+                # "plugin" would be none if a match was not found. In that case, a validation
error
+                # should already have been reported in ServiceTemplateBase.instantiate, so
we will
+                # continue silently here
+            else:
+                # If the plugin is disabled, the operation should be disabled, too
+                plugin = None
+                implementation = None
         else:
-            # If the plugin is disabled, the operation should be disabled, too
+            # using the execution plugin
             plugin = None
-            implementation = None
+            implementation = self.implementation
+
         operation = models.Operation(name=self.name,
                                      description=deepcopy_with_locators(self.description),
                                      relationship_edge=self.relationship_edge,
@@ -2119,25 +2125,16 @@ class PluginSpecificationBase(TemplateModelMixin):
     def coerce_values(self, container, report_issues):
         pass
 
-    def resolve(self):
+    def resolve(self, model_storage):
         # TODO: we are planning a separate "instantiation" module where this will be called
or
-        # moved to. There, we will probably have a context with a storage manager. Until
then,
-        # this is the only potentially available context, which of course will only be available
-        # if we're in a workflow.
-        from ..orchestrator import context
-        try:
-            workflow_context = context.workflow.current.get()
-            plugins = workflow_context.model.plugin.list()
-        except context.exceptions.ContextException:
-            plugins = None
-
+        # moved to.
+        plugins = model_storage.plugin.list()
         matching_plugins = []
-        if plugins:
-            for plugin in plugins:
-                # TODO: we need to use a version comparator
-                if (plugin.name == self.name) and \
+        for plugin in plugins:
+            # TODO: we need to use a version comparator
+            if (plugin.name == self.name) and \
                     ((self.version is None) or (plugin.package_version >= self.version)):
-                    matching_plugins.append(plugin)
+                matching_plugins.append(plugin)
         self.plugin = None
         if matching_plugins:
             # Return highest version of plugin

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/59967548/aria/orchestrator/execution_plugin/instantiation.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/execution_plugin/instantiation.py b/aria/orchestrator/execution_plugin/instantiation.py
index 960835c..7627a38 100644
--- a/aria/orchestrator/execution_plugin/instantiation.py
+++ b/aria/orchestrator/execution_plugin/instantiation.py
@@ -27,7 +27,7 @@ def configure_operation(operation):
     arguments = OrderedDict()
     arguments['script_path'] = operation.implementation
     arguments['process'] = _get_process(configuration.pop('process')) \
-        if 'process' in configuration else None
+        if 'process' in configuration else dict()
 
     host = None
     interface = operation.interface

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/59967548/aria/parser/consumption/__init__.py
----------------------------------------------------------------------
diff --git a/aria/parser/consumption/__init__.py b/aria/parser/consumption/__init__.py
index 7da8490..ff1b376 100644
--- a/aria/parser/consumption/__init__.py
+++ b/aria/parser/consumption/__init__.py
@@ -20,7 +20,7 @@ from .style import Style
 from .consumer import Consumer, ConsumerChain
 from .presentation import Read
 from .validation import Validate
-from .modeling import ServiceTemplate, Types, ServiceInstance
+from .modeling import ServiceTemplate, Types, ServiceInstance, FindHosts, ConfigureOperations
 from .inputs import Inputs
 
 __all__ = (

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/59967548/aria/parser/consumption/modeling.py
----------------------------------------------------------------------
diff --git a/aria/parser/consumption/modeling.py b/aria/parser/consumption/modeling.py
index 37787d6..771fd7f 100644
--- a/aria/parser/consumption/modeling.py
+++ b/aria/parser/consumption/modeling.py
@@ -106,7 +106,8 @@ class InstantiateServiceInstance(Consumer):
                                            'template')
             return
 
-        self.context.modeling.template.instantiate(None, dict(self.context.modeling.inputs))
+        self.context.modeling.template.instantiate(None, None,
+                                                   inputs=dict(self.context.modeling.inputs))
 
 
 class CoerceServiceInstanceValues(Consumer):


Mime
View raw message