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
This commit is contained in:
Alexander Tivelkov 2016-05-24 21:26:36 +03:00
parent 5bf21ed22b
commit 1ff47503a1
3 changed files with 22 additions and 6 deletions

View File

@ -143,7 +143,8 @@ class CloudifyToscaPackage(package_base.PackageBase):
data = yaml.safe_load(blueprint) data = yaml.safe_load(blueprint)
return data.get('inputs') or {}, data.get('outputs') or {} 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 = { section = {
key: YAQL( key: YAQL(
'$.appConfiguration.' + key) for key in six.iterkeys(inputs) '$.appConfiguration.' + key) for key in six.iterkeys(inputs)
@ -153,6 +154,10 @@ class CloudifyToscaPackage(package_base.PackageBase):
'type': self.full_name 'type': self.full_name
} }
}) })
if package_name:
section['?']['package'] = package_name
if package_version:
section['?']['classVersion'] = package_version
return section return section
@staticmethod @staticmethod
@ -176,7 +181,8 @@ class CloudifyToscaPackage(package_base.PackageBase):
inputs, outputs = self._get_inputs_outputs() inputs, outputs = self._get_inputs_outputs()
ui = { ui = {
'Version': '2.2', '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) 'Forms': self._generate_form_ui_section(inputs)
} }
return yaml.dump(ui, Dumper=Dumper, default_style='"') return yaml.dump(ui, Dumper=Dumper, default_style='"')

View File

@ -497,12 +497,17 @@ class CSARPackage(package_base.PackageBase):
return translated return translated
@staticmethod @staticmethod
def _generate_application_ui(groups, type_name): def _generate_application_ui(groups, type_name, package_name=None,
package_version=None):
app = { app = {
'?': { '?': {
'type': type_name 'type': type_name
} }
} }
if package_name:
app['?']['package'] = package_name
if package_version:
app['?']['classVersion'] = package_version
for i, record in enumerate(groups): for i, record in enumerate(groups):
section = app.setdefault('templateParameters', {}) section = app.setdefault('templateParameters', {})
@ -525,7 +530,7 @@ class CSARPackage(package_base.PackageBase):
translated = { translated = {
'Version': 2.2, 'Version': 2.2,
'Application': CSARPackage._generate_application_ui( 'Application': CSARPackage._generate_application_ui(
groups, self.full_name), groups, self.full_name, self.full_name, str(self.version)),
'Forms': forms 'Forms': forms
} }
return yaml.dump(translated, Dumper=Dumper, default_style='"') return yaml.dump(translated, Dumper=Dumper, default_style='"')

View File

@ -492,12 +492,17 @@ class HotPackage(package_base.PackageBase):
return translated return translated
@staticmethod @staticmethod
def _generate_application_ui(groups, type_name): def _generate_application_ui(groups, type_name,
package_name=None, package_version=None):
app = { app = {
'?': { '?': {
'type': type_name 'type': type_name
} }
} }
if package_name:
app['?']['package'] = package_name
if package_version:
app['?']['classVersion'] = package_version
for i, record in enumerate(groups): for i, record in enumerate(groups):
if i == 0: if i == 0:
section = app section = app
@ -527,7 +532,7 @@ class HotPackage(package_base.PackageBase):
translated = { translated = {
'Version': 2, 'Version': 2,
'Application': HotPackage._generate_application_ui( 'Application': HotPackage._generate_application_ui(
groups, self.full_name), groups, self.full_name, self.full_name, str(self.version)),
'Forms': forms 'Forms': forms
} }