ariatosca-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mxm...@apache.org
Subject incubator-ariatosca git commit: moved the model_storage to the instanatiation of a service only - no longer need to pass it to the topology
Date Thu, 03 Aug 2017 14:22:29 GMT
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-174-Refactor-instantiation-phase cb4c04692 -> f29602505


moved the model_storage to the instanatiation of a service only - no longer need to pass it
to the topology


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

Branch: refs/heads/ARIA-174-Refactor-instantiation-phase
Commit: f29602505fc3f865e37db3f97f16ff9a8f2b2825
Parents: cb4c046
Author: max-orlov <maxim@gigaspaces.com>
Authored: Thu Aug 3 17:22:24 2017 +0300
Committer: max-orlov <maxim@gigaspaces.com>
Committed: Thu Aug 3 17:22:24 2017 +0300

----------------------------------------------------------------------
 aria/core.py                                   |  5 ++--
 aria/orchestrator/topology/common.py           |  2 +-
 aria/orchestrator/topology/template_handler.py | 28 ++++++++++-----------
 aria/orchestrator/topology/topology.py         |  5 +---
 4 files changed, 19 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/f2960250/aria/core.py
----------------------------------------------------------------------
diff --git a/aria/core.py b/aria/core.py
index 30ca2d6..83d5f7a 100644
--- a/aria/core.py
+++ b/aria/core.py
@@ -74,8 +74,9 @@ class Core(object):
         # setting no autoflush for the duration of instantiation - this helps avoid dependency
         # constraints as they're being set up
         with storage_session.no_autoflush:
-            topology_ = topology.Topology(self.model_storage)
-            service = topology_.instantiate(service_template, inputs=inputs)
+            topology_ = topology.Topology()
+            service = topology_.instantiate(
+                service_template, inputs=inputs, model_storage=self.model_storage)
             topology_.coerce(service, report_issues=True)
 
             topology_.validate(service)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/f2960250/aria/orchestrator/topology/common.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/topology/common.py b/aria/orchestrator/topology/common.py
index 96ceb31..02926ab 100644
--- a/aria/orchestrator/topology/common.py
+++ b/aria/orchestrator/topology/common.py
@@ -42,7 +42,7 @@ class TemplateHandlerBase(HandlerBase):
     Base handler for template based models
     """
 
-    def instantiate(self, instance_cls):
+    def instantiate(self, instance_cls, **kwargs):
         raise NotImplementedError
 
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/f2960250/aria/orchestrator/topology/template_handler.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/topology/template_handler.py b/aria/orchestrator/topology/template_handler.py
index 8f57ace..274abae 100644
--- a/aria/orchestrator/topology/template_handler.py
+++ b/aria/orchestrator/topology/template_handler.py
@@ -47,7 +47,7 @@ class ServiceTemplate(common.TemplateHandlerBase):
                      self._model.workflow_templates,
                      **kwargs)
 
-    def instantiate(self, instance_cls, inputs=None):                                   
           # pylint: disable=arguments-differ
+    def instantiate(self, instance_cls, inputs=None, model_storage=None):               
           # pylint: disable=arguments-differ
         now = datetime.now()
 
         modeling_utils.validate_no_undeclared_inputs(
@@ -64,9 +64,9 @@ class ServiceTemplate(common.TemplateHandlerBase):
         )
 
         for plugin_specification in self._model.plugin_specifications.itervalues():
-            if plugin_specification.enabled and self._topology._model_storage:
+            if plugin_specification.enabled and model_storage:
                 if self._resolve_plugin_specification(plugin_specification,
-                                                      self._topology.model_storage.plugin.list()):
+                                                      model_storage.plugin.list()):
                     plugin = plugin_specification.plugin
                     service.plugins[plugin.name] = plugin
                 else:
@@ -169,7 +169,7 @@ class ArtifactTemplate(common.TemplateHandlerBase):
     def coerce(self, **kwargs):
         self._topology.coerce(self._model.properties, **kwargs)
 
-    def instantiate(self, instance_cls):
+    def instantiate(self, instance_cls, **_):
         return instance_cls(
             name=self._model.name,
             type=self._model.type,
@@ -206,7 +206,7 @@ class CapabilityTemplate(common.TemplateHandlerBase):
     def coerce(self, **kwargs):
         self._topology.coerce(self._model.properties, **kwargs)
 
-    def instantiate(self, instance_cls):
+    def instantiate(self, instance_cls, **_):
         return instance_cls(name=self._model.name,
                             type=self._model.type,
                             min_occurrences=self._model.min_occurrences,
@@ -250,7 +250,7 @@ class RequirementTemplate(common.TemplateHandlerBase):
     def coerce(self, **kwargs):
         self._topology.coerce(self._model.relationship_template, **kwargs)
 
-    def instantiate(self, instance_cls):
+    def instantiate(self, instance_cls, **_):
         pass
 
     def validate(self, **kwargs):
@@ -276,7 +276,7 @@ class GroupTemplate(common.TemplateHandlerBase):
                      self._model.interface_templates,
                      **kwargs)
 
-    def instantiate(self, instance_cls):
+    def instantiate(self, instance_cls, **_):
         group = instance_cls(
             name=self._model.name,
             type=self._model.type,
@@ -312,7 +312,7 @@ class InterfaceTemplate(common.TemplateHandlerBase):
                      self._model.operation_templates,
                      **kwargs)
 
-    def instantiate(self, instance_cls):
+    def instantiate(self, instance_cls, **_):
         interface = instance_cls(
             name=self._model.name,
             type=self._model.type,
@@ -355,7 +355,7 @@ class NodeTemplate(common.TemplateHandlerBase):
                      self._model.requirement_templates,
                      **kwargs)
 
-    def instantiate(self, instance_cls):
+    def instantiate(self, instance_cls, **_):
         node = instance_cls(
             name=self._model._next_name,
             type=self._model.type,
@@ -405,7 +405,7 @@ class PolicyTemplate(common.TemplateHandlerBase):
     def coerce(self, **kwargs):
         self._topology.coerce(self._model.properties, **kwargs)
 
-    def instantiate(self, instance_cls):
+    def instantiate(self, instance_cls, **_):
         policy = instance_cls(
             name=self._model.name,
             type=self._model.type,
@@ -437,7 +437,7 @@ class SubstitutionTemplate(common.TemplateHandlerBase):
     def coerce(self, **kwargs):
         self._topology.coerce(self._model.mappings, **kwargs)
 
-    def instantiate(self, instance_cls):
+    def instantiate(self, instance_cls, **_):
         return instance_cls(node_type=self._model.node_type,
                             substitution_template=self._model)
 
@@ -462,7 +462,7 @@ class SubstitutionTemplateMapping(common.TemplateHandlerBase):
     def coerce(self, **_):
         pass
 
-    def instantiate(self, instance_cls):
+    def instantiate(self, instance_cls, **_):
         substitution_mapping = instance_cls(
             name=self._model.name,
             requirement_template=self._model.requirement_template)
@@ -516,7 +516,7 @@ class RelationshipTemplate(common.TemplateHandlerBase):
     def coerce(self, **kwargs):
         self._coerce(self._model.properties, self._model.interface_templates, **kwargs)
 
-    def instantiate(self, instance_cls):
+    def instantiate(self, instance_cls, **_):
         relationship = instance_cls(
             name=self._model.name,
             type=self._model.type,
@@ -566,7 +566,7 @@ class OperationTemplate(common.TemplateHandlerBase):
                      self._model.configurations,
                      **kwargs)
 
-    def instantiate(self, instance_cls):
+    def instantiate(self, instance_cls, **_):
         operation = instance_cls(
             name=self._model.name,
             description=utils.deepcopy_with_locators(self._model.description),

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/f2960250/aria/orchestrator/topology/topology.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/topology/topology.py b/aria/orchestrator/topology/topology.py
index 96ee4f9..b2b689d 100644
--- a/aria/orchestrator/topology/topology.py
+++ b/aria/orchestrator/topology/topology.py
@@ -49,11 +49,8 @@ class Topology(issue.ReporterMixin):
         models.Type: models.Type
     }
 
-    def __init__(self, model_storage=None, *args, **kwargs):
-        # TODO: model storage is required only for the list of plugins, can we get it
-        # somewhere else?
+    def __init__(self, *args, **kwargs):
         super(Topology, self).__init__(*args, **kwargs)
-        self._model_storage = model_storage
         self._models_to_handlers = dict(self._init_handlers(instance_handler),
                                         **self._init_handlers(template_handler))
 


Mime
View raw message