ariatosca-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mxm...@apache.org
Subject incubator-ariatosca git commit: fixes
Date Thu, 30 Mar 2017 14:36:56 GMT
Repository: incubator-ariatosca
Updated Branches:
  refs/heads/minor_fixes_to_script_ctx_mechanism [created] 67aa92585


fixes


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

Branch: refs/heads/minor_fixes_to_script_ctx_mechanism
Commit: 67aa92585b2f201ced8871b946d02432955890fd
Parents: 718c78c
Author: max-orlov <maxim@gigaspaces.com>
Authored: Thu Mar 30 17:36:47 2017 +0300
Committer: max-orlov <maxim@gigaspaces.com>
Committed: Thu Mar 30 17:36:47 2017 +0300

----------------------------------------------------------------------
 aria/modeling/__init__.py                              |  2 ++
 aria/modeling/service_common.py                        |  4 ++++
 aria/modeling/utils.py                                 | 10 ++++++++++
 aria/orchestrator/context/common.py                    |  2 +-
 aria/orchestrator/execution_plugin/ctx_proxy/server.py |  3 ++-
 aria/orchestrator/workflows/executor/process.py        |  6 ++++--
 6 files changed, 23 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/67aa9258/aria/modeling/__init__.py
----------------------------------------------------------------------
diff --git a/aria/modeling/__init__.py b/aria/modeling/__init__.py
index 4dfc39d..4ac79e7 100644
--- a/aria/modeling/__init__.py
+++ b/aria/modeling/__init__.py
@@ -19,6 +19,7 @@ from . import (
     mixins,
     types,
     models,
+    utils,
     service_template as _service_template_bases,
     service_instance as _service_instance_bases,
     service_changes as _service_changes_bases,
@@ -45,4 +46,5 @@ __all__ = (
     'types',
     'models',
     'model_bases',
+    'utils'
 )

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/67aa9258/aria/modeling/service_common.py
----------------------------------------------------------------------
diff --git a/aria/modeling/service_common.py b/aria/modeling/service_common.py
index d6b1f33..85fe6df 100644
--- a/aria/modeling/service_common.py
+++ b/aria/modeling/service_common.py
@@ -61,6 +61,10 @@ class ParameterBase(TemplateModelMixin):
             ('value', self.value),
             ('description', self.description)))
 
+    @property
+    def __jsonify__(self):
+        return str(self.value)
+
     def instantiate(self, container):
         from . import models
         return models.Parameter(name=self.name,

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/67aa9258/aria/modeling/utils.py
----------------------------------------------------------------------
diff --git a/aria/modeling/utils.py b/aria/modeling/utils.py
index 44d7e10..e3ab96a 100644
--- a/aria/modeling/utils.py
+++ b/aria/modeling/utils.py
@@ -14,6 +14,7 @@
 # limitations under the License.
 
 from StringIO import StringIO
+from json import JSONEncoder
 
 from . import exceptions
 from ..parser.consumption import ConsumptionContext
@@ -24,6 +25,15 @@ from ..utils.console import puts
 from ..utils.conversion import convert_value_to_type
 
 
+class ModelJSONEncoder(JSONEncoder):
+    def default(self, o):
+        from .mixins import ModelMixin
+        if isinstance(o, ModelMixin):
+            return getattr(o, '__jsonify__', o.to_dict())
+        else:
+            return JSONEncoder.default(self, o)
+
+
 def create_inputs(inputs, template_inputs):
     """
     :param inputs: key-value dict

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/67aa9258/aria/orchestrator/context/common.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/context/common.py b/aria/orchestrator/context/common.py
index 06e283c..3861982 100644
--- a/aria/orchestrator/context/common.py
+++ b/aria/orchestrator/context/common.py
@@ -195,7 +195,7 @@ class BaseContext(object):
         try:
             return self.resource.service.read(entry_id=str(self.service.id), path=path)
         except exceptions.StorageError:
-            return self.resource.service.read(entry_id=str(self.service_template.id), path=path)
+            return self.resource.service_template.read(entry_id=str(self.service_template.id),
path=path)
 
     def get_resource_and_render(self, path=None, variables=None):
         """

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/67aa9258/aria/orchestrator/execution_plugin/ctx_proxy/server.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/execution_plugin/ctx_proxy/server.py b/aria/orchestrator/execution_plugin/ctx_proxy/server.py
index 817d064..52a5312 100644
--- a/aria/orchestrator/execution_plugin/ctx_proxy/server.py
+++ b/aria/orchestrator/execution_plugin/ctx_proxy/server.py
@@ -24,6 +24,7 @@ import StringIO
 import wsgiref.simple_server
 
 import bottle
+from aria import modeling
 
 from .. import exceptions
 
@@ -111,7 +112,7 @@ class CtxProxy(object):
             result = json.dumps({
                 'type': result_type,
                 'payload': payload
-            })
+            }, cls=modeling.utils.ModelJSONEncoder)
         except Exception as e:
             traceback_out = StringIO.StringIO()
             traceback.print_exc(file=traceback_out)

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/67aa9258/aria/orchestrator/workflows/executor/process.py
----------------------------------------------------------------------
diff --git a/aria/orchestrator/workflows/executor/process.py b/aria/orchestrator/workflows/executor/process.py
index 6397e88..da82bba 100644
--- a/aria/orchestrator/workflows/executor/process.py
+++ b/aria/orchestrator/workflows/executor/process.py
@@ -145,10 +145,12 @@ class ProcessExecutor(base.BaseExecutor):
             raise RuntimeError('Executor closed')
 
     def _create_arguments_dict(self, task):
+        operation_inputs = dict((k, v.value) for k, v in task.inputs.iteritems())
+        operation_inputs.update({'script_path': task.implementation})
         return {
             'task_id': task.id,
-            'implementation': task.implementation,
-            'operation_inputs': dict((k, v.value) for k, v in task.inputs.iteritems()),
+            'implementation': 'aria.orchestrator.execution_plugin.operations.run_script_locally',
+            'operation_inputs': operation_inputs,
             'port': self._server_port,
             'context': task.context.serialization_dict,
         }


Mime
View raw message