def execute(self): token, tenant_id = self.environment.token, self.environment.tenant_id with package_loader.ApiPackageLoader(token, tenant_id) as pkg_loader: class_loader = package_class_loader.PackageClassLoader(pkg_loader) system_objects.register(class_loader, pkg_loader) exc = executor.MuranoDslExecutor(class_loader, self.environment) obj = exc.load(self.model) try: # Skip execution of action in case of no action is provided. # Model will be just loaded, cleaned-up and unloaded. # Most of the time this is used for deletion of environments. if self.action: self._invoke(exc) except Exception as e: if isinstance(e, dsl_exception.MuranoPlException): LOG.error('\n' + e.format(prefix=' ')) else: LOG.exception(e) reporter = status_reporter.StatusReporter() reporter.initialize(obj) reporter.report_error(obj, str(e)) return results_serializer.serialize(obj, exc)
def setUp(self): super(TestPackageCache, self).setUp() self.location = tempfile.mkdtemp() self.override_config('enable_packages_cache', True, 'engine') self.override_config('packages_cache', self.location, 'engine') self._patch_loader_client() self.loader = package_loader.ApiPackageLoader(None)
def setUp(self): super(TestPackageCache, self).setUp() self.location = tempfile.mkdtemp() CONF.set_override('enable_packages_cache', True, 'packages_opts') self.old_location = CONF.packages_opts.packages_cache CONF.set_override('packages_cache', self.location, 'packages_opts') self.murano_client = mock.MagicMock() package_loader.ApiPackageLoader.client = self.murano_client self.loader = package_loader.ApiPackageLoader(None)
def execute(self): self._create_trust() try: # pkg_loader = package_loader.DirectoryPackageLoader('./meta') # return self._execute(pkg_loader) murano_client_factory = lambda: \ self._environment.clients.get_murano_client(self._environment) with package_loader.ApiPackageLoader( murano_client_factory) as pkg_loader: return self._execute(pkg_loader) finally: if self._model['Objects'] is None: self._delete_trust()