From 1ff47503a1df6a22b576dec1552068e8b6f10edd Mon Sep 17 00:00:00 2001 From: Alexander Tivelkov Date: Tue, 24 May 2016 21:26:36 +0300 Subject: [PATCH] Added package references to generated UIs Generated UIs of the non-muranoPL packages (HOT, cloudify_tosca and CSAR) reference the type of object model's object by class FQNs. However, when these packages are uploaded to glare, their class contents are not indexed since the client which uploads them has no knowledge of the generated classes. To workaround this issue it is proposed to reference objects not just by class FQNs but to include the package FQN and the version, so the engine does not have to rely on Glare's indexes. Change-Id: I6175e89b68bcdfc29d33ae3616d6ecba662f2509 Partial-bug: #1565805 --- .../murano_cloudify_plugin/cloudify_tosca_package.py | 10 ++++++++-- .../plugin/csar_package.py | 9 +++++++-- murano/packages/hot_package.py | 9 +++++++-- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/contrib/plugins/cloudify_plugin/murano_cloudify_plugin/cloudify_tosca_package.py b/contrib/plugins/cloudify_plugin/murano_cloudify_plugin/cloudify_tosca_package.py index 93c6c7f8d..178e7e489 100644 --- a/contrib/plugins/cloudify_plugin/murano_cloudify_plugin/cloudify_tosca_package.py +++ b/contrib/plugins/cloudify_plugin/murano_cloudify_plugin/cloudify_tosca_package.py @@ -143,7 +143,8 @@ class CloudifyToscaPackage(package_base.PackageBase): data = yaml.safe_load(blueprint) return data.get('inputs') or {}, data.get('outputs') or {} - def _generate_application_ui_section(self, inputs): + def _generate_application_ui_section(self, inputs, package_name=None, + package_version=None): section = { key: YAQL( '$.appConfiguration.' + key) for key in six.iterkeys(inputs) @@ -153,6 +154,10 @@ class CloudifyToscaPackage(package_base.PackageBase): 'type': self.full_name } }) + if package_name: + section['?']['package'] = package_name + if package_version: + section['?']['classVersion'] = package_version return section @staticmethod @@ -176,7 +181,8 @@ class CloudifyToscaPackage(package_base.PackageBase): inputs, outputs = self._get_inputs_outputs() ui = { 'Version': '2.2', - 'Application': self._generate_application_ui_section(inputs), + 'Application': self._generate_application_ui_section( + inputs, self.full_name, str(self.version)), 'Forms': self._generate_form_ui_section(inputs) } return yaml.dump(ui, Dumper=Dumper, default_style='"') diff --git a/contrib/plugins/murano_heat-translator_plugin/plugin/csar_package.py b/contrib/plugins/murano_heat-translator_plugin/plugin/csar_package.py index ff791dc19..696bc1802 100755 --- a/contrib/plugins/murano_heat-translator_plugin/plugin/csar_package.py +++ b/contrib/plugins/murano_heat-translator_plugin/plugin/csar_package.py @@ -497,12 +497,17 @@ class CSARPackage(package_base.PackageBase): return translated @staticmethod - def _generate_application_ui(groups, type_name): + def _generate_application_ui(groups, type_name, package_name=None, + package_version=None): app = { '?': { 'type': type_name } } + if package_name: + app['?']['package'] = package_name + if package_version: + app['?']['classVersion'] = package_version for i, record in enumerate(groups): section = app.setdefault('templateParameters', {}) @@ -525,7 +530,7 @@ class CSARPackage(package_base.PackageBase): translated = { 'Version': 2.2, 'Application': CSARPackage._generate_application_ui( - groups, self.full_name), + groups, self.full_name, self.full_name, str(self.version)), 'Forms': forms } return yaml.dump(translated, Dumper=Dumper, default_style='"') diff --git a/murano/packages/hot_package.py b/murano/packages/hot_package.py index 93830b7b8..ff32a0f3f 100644 --- a/murano/packages/hot_package.py +++ b/murano/packages/hot_package.py @@ -492,12 +492,17 @@ class HotPackage(package_base.PackageBase): return translated @staticmethod - def _generate_application_ui(groups, type_name): + def _generate_application_ui(groups, type_name, + package_name=None, package_version=None): app = { '?': { 'type': type_name } } + if package_name: + app['?']['package'] = package_name + if package_version: + app['?']['classVersion'] = package_version for i, record in enumerate(groups): if i == 0: section = app @@ -527,7 +532,7 @@ class HotPackage(package_base.PackageBase): translated = { 'Version': 2, 'Application': HotPackage._generate_application_ui( - groups, self.full_name), + groups, self.full_name, self.full_name, str(self.version)), 'Forms': forms }