Exemple #1
0
 def _execute(self, name, object_id, *args, **kwargs):
     obj = self.executor.object_store.get(object_id)
     try:
         final_args = []
         final_kwargs = {}
         for arg in args:
             if isinstance(arg, object_model.Object):
                 arg = object_model.build_model(arg)
             final_args.append(arg)
         for name, arg in kwargs.iteritems():
             if isinstance(arg, object_model.Object):
                 arg = object_model.build_model(arg)
             final_kwargs[name] = arg
         runtime_version = obj.type.package.runtime_version
         yaql_engine = yaql_integration.choose_yaql_engine(runtime_version)
         return dsl.to_mutable(
             obj.type.invoke(name, self.executor, obj, tuple(final_args), final_kwargs), yaql_engine
         )
     except dsl_exception.MuranoPlException as e:
         if not self.preserve_exception:
             original_exception = getattr(e, "original_exception", None)
             if original_exception and not isinstance(original_exception, dsl_exception.MuranoPlException):
                 exc_traceback = getattr(e, "original_traceback", None) or sys.exc_info()[2]
                 raise type(original_exception), original_exception, exc_traceback
         raise
Exemple #2
0
 def _execute(self, name, object_id, *args, **kwargs):
     obj = self.executor.object_store.get(object_id)
     try:
         final_args = []
         final_kwargs = {}
         for arg in args:
             if isinstance(arg, object_model.Object):
                 arg = object_model.build_model(arg)
             final_args.append(arg)
         for name, arg in six.iteritems(kwargs):
             if isinstance(arg, object_model.Object):
                 arg = object_model.build_model(arg)
             final_kwargs[name] = arg
         runtime_version = obj.type.package.runtime_version
         yaql_engine = yaql_integration.choose_yaql_engine(runtime_version)
         return dsl.to_mutable(obj.type.invoke(
             name, self.executor, obj, tuple(final_args), final_kwargs),
             yaql_engine)
     except dsl_exception.MuranoPlException as e:
         if not self.preserve_exception:
             original_exception = getattr(e, 'original_exception', None)
             if original_exception and not isinstance(
                     original_exception, dsl_exception.MuranoPlException):
                 exc_traceback = getattr(
                     e, 'original_traceback', None) or sys.exc_info()[2]
                 six.reraise(
                     type(original_exception),
                     original_exception,
                     exc_traceback)
         raise
Exemple #3
0
 def _execute(self, name, obj, *args, **kwargs):
     try:
         final_args = []
         final_kwargs = {}
         for arg in args:
             if isinstance(arg, object_model.Object):
                 arg = object_model.build_model(arg)
             final_args.append(arg)
         for name, arg in kwargs.items():
             if isinstance(arg, object_model.Object):
                 arg = object_model.build_model(arg)
             final_kwargs[name] = arg
         cls = obj if isinstance(obj, dsl_types.MuranoType) else obj.type
         runtime_version = cls.package.runtime_version
         yaql_engine = yaql_integration.choose_yaql_engine(runtime_version)
         with helpers.with_object_store(self.executor.object_store):
             return dsl.to_mutable(
                 cls.invoke(name, obj, tuple(final_args), final_kwargs),
                 yaql_engine)
     except dsl_exception.MuranoPlException as e:
         if not self.preserve_exception:
             original_exception = getattr(e, 'original_exception', None)
             if original_exception and not isinstance(
                     original_exception, dsl_exception.MuranoPlException):
                 exc_traceback = getattr(e, 'original_traceback',
                                         None) or sys.exc_info()[2]
                 utils.reraise(type(original_exception), original_exception,
                               exc_traceback)
         raise
Exemple #4
0
 def __init__(self, model, package_loader, functions):
     if isinstance(model, six.string_types):
         model = om.Object(model)
     model = om.build_model(model)
     if 'Objects' not in model:
         model = {'Objects': model}
     self.executor = executor.MuranoDslExecutor(
         package_loader, TestMockContextManager(functions),
         execution_session.ExecutionSession())
     self._root = self.executor.load(model).object
 def __init__(self, model, package_loader, functions):
     if isinstance(model, six.string_types):
         model = om.Object(model)
     model = om.build_model(model)
     if 'Objects' not in model:
         model = {'Objects': model}
     self.executor = executor.MuranoDslExecutor(
         package_loader, TestMockContextManager(functions),
         execution_session.ExecutionSession())
     self._root = self.executor.load(model).object
Exemple #6
0
    def __init__(self, model, class_loader):
        if isinstance(model, types.StringTypes):
            model = object_model.Object(model)
        model = object_model.build_model(model)
        if 'Objects' not in model:
            model = {'Objects': model}

        self.executor = executor.MuranoDslExecutor(
            class_loader, environment.Environment())
        self._root = self.executor.load(model)
Exemple #7
0
    def __init__(self, model, package_loader, functions):
        if isinstance(model, types.StringTypes):
            model = object_model.Object(model)
        model = object_model.build_model(model)
        if "Objects" not in model:
            model = {"Objects": model}

        self.executor = executor.MuranoDslExecutor(
            package_loader, TestContextManager(functions), environment.Environment()
        )
        self._root = self.executor.load(model).object
Exemple #8
0
    def __init__(self, model, package_loader, functions):
        if isinstance(model, types.StringTypes):
            model = object_model.Object(model)
        model = object_model.build_model(model)
        if 'Objects' not in model:
            model = {'Objects': model}

        self.executor = executor.MuranoDslExecutor(
            package_loader, TestContextManager(functions),
            environment.Environment())
        self._root = self.executor.load(model).object
Exemple #9
0
 def _execute(self, name, object_id, *args, **kwargs):
     obj = self.executor.object_store.get(object_id)
     try:
         final_args = []
         for arg in args:
             if isinstance(arg, object_model.Object):
                 arg = object_model.build_model(arg)
             final_args.append(arg)
         for name, arg in kwargs.iteritems():
             if isinstance(arg, object_model.Object):
                 arg = object_model.build_model(arg)
             final_args.append({name: arg})
         return obj.type.invoke(name, self.executor, obj, tuple(final_args))
     except dsl_exception.MuranoPlException as e:
         if not self.preserve_exception:
             original_exception = getattr(e, 'original_exception', None)
             if original_exception and not isinstance(
                     original_exception, dsl_exception.MuranoPlException):
                 exc_traceback = getattr(
                     e, 'original_traceback', None) or sys.exc_info()[2]
                 raise type(original_exception), original_exception, \
                     exc_traceback
         raise
Exemple #10
0
    def __init__(self, model, package_loader, functions):
        if isinstance(model, str):
            model = object_model.Object(model)
        model = object_model.build_model(model)
        if 'Objects' not in model:
            model = {'Objects': model}

        self.executor = executor.MuranoDslExecutor(
            package_loader, TestContextManager(functions),
            execution_session.ExecutionSession())
        self._root = self.executor.load(model)
        if self._root:
            self._root = self._root.object
        if 'ObjectsCopy' in model:
            self.executor.object_store.cleanup()