Merge "Import images publicly when package is public"
This commit is contained in:
commit
f05dda723e
@ -329,6 +329,9 @@ class ImportPackageWizard(views.ModalFormMixin,
|
|||||||
dep_pkgs = self.storage.get_step_data('upload').get(
|
dep_pkgs = self.storage.get_step_data('upload').get(
|
||||||
'dependencies', [])
|
'dependencies', [])
|
||||||
|
|
||||||
|
installed_images = self.storage.get_step_data('upload').get(
|
||||||
|
'images', [])
|
||||||
|
|
||||||
redirect = reverse('horizon:murano:packages:index')
|
redirect = reverse('horizon:murano:packages:index')
|
||||||
dep_data = {'enabled': data['enabled'],
|
dep_data = {'enabled': data['enabled'],
|
||||||
'is_public': data['is_public']}
|
'is_public': data['is_public']}
|
||||||
@ -343,6 +346,20 @@ class ImportPackageWizard(views.ModalFormMixin,
|
|||||||
LOG.warning(msg)
|
LOG.warning(msg)
|
||||||
messages.warning(self.request, msg)
|
messages.warning(self.request, msg)
|
||||||
|
|
||||||
|
# Images have been imported as private images during the 'upload' step
|
||||||
|
# If the package is public, make the required images public
|
||||||
|
if data['is_public']:
|
||||||
|
glance_client = glance.glanceclient(self.request, version='1')
|
||||||
|
for img in installed_images:
|
||||||
|
try:
|
||||||
|
glance_client.images.update(img['id'], is_public=True)
|
||||||
|
LOG.debug('Success update for image {0}'.format(img['id']))
|
||||||
|
except Exception as e:
|
||||||
|
msg = _("Error {0} occurred while setting image {1}, {2} "
|
||||||
|
"public").format(e, img['name'], img['id'])
|
||||||
|
messages.error(self.request, msg)
|
||||||
|
LOG.exception(msg)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data['tags'] = [t.strip() for t in data['tags'].split(',')]
|
data['tags'] = [t.strip() for t in data['tags'].split(',')]
|
||||||
murano_client.packages.update(app_id, data)
|
murano_client.packages.update(app_id, data)
|
||||||
@ -441,6 +458,7 @@ class ImportPackageWizard(views.ModalFormMixin,
|
|||||||
"deployment after successful upload")\
|
"deployment after successful upload")\
|
||||||
.format(img['name'], img['id'],)
|
.format(img['name'], img['id'],)
|
||||||
LOG.info(log_msg)
|
LOG.info(log_msg)
|
||||||
|
step_data['images'].append(img)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg = _("Error {0} occurred while installing "
|
msg = _("Error {0} occurred while installing "
|
||||||
"images for {1}").format(e, name)
|
"images for {1}").format(e, name)
|
||||||
@ -451,6 +469,7 @@ class ImportPackageWizard(views.ModalFormMixin,
|
|||||||
glance_client = glance.glanceclient(self.request, version='1')
|
glance_client = glance.glanceclient(self.request, version='1')
|
||||||
original_package = reqs.pop(name)
|
original_package = reqs.pop(name)
|
||||||
step_data['dependencies'] = []
|
step_data['dependencies'] = []
|
||||||
|
step_data['images'] = []
|
||||||
for dep_name, dep_package in reqs.iteritems():
|
for dep_name, dep_package in reqs.iteritems():
|
||||||
_ensure_images(dep_name, dep_package)
|
_ensure_images(dep_name, dep_package)
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user