Commit fd294c27 by Szabolcs Gelencser Committed by Szabolcs Gelencsér

Add image sharing compatibility for mitaka

parent ce649c0d
...@@ -343,7 +343,7 @@ class TemplateDetail(LoginRequiredMixin, GraphMixin, SuccessMessageMixin, Update ...@@ -343,7 +343,7 @@ class TemplateDetail(LoginRequiredMixin, GraphMixin, SuccessMessageMixin, Update
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
template = self.get_object() template = self.get_object()
openstack_api.glance.image_update(self.request, template.image_id, visibility="shared") template.make_it_shared(self.request)
context = super(TemplateDetail, self).get_context_data(**kwargs) context = super(TemplateDetail, self).get_context_data(**kwargs)
# context['acl'] = AclUpdateView.get_acl_data( # context['acl'] = AclUpdateView.get_acl_data(
# template, self.request.user, 'dashboard.views.template-acl') # template, self.request.user, 'dashboard.views.template-acl')
......
...@@ -595,7 +595,7 @@ class AclUpdateView(LoginRequiredMixin, View, SingleObjectMixin): ...@@ -595,7 +595,7 @@ class AclUpdateView(LoginRequiredMixin, View, SingleObjectMixin):
self.template = self.get_object() self.template = self.get_object()
self.glance = self.__get_glance_admin_client(self.request.user.tenant_id) self.glance = self.__get_glance_admin_client(self.request.user.tenant_id)
openstack_api.glance.image_update(request, self.template.image_id, visibility="shared") self.template.make_it_shared(request)
self.__handle_removes_from_db() self.__handle_removes_from_db()
self.__handle_assignments() self.__handle_assignments()
self.__cleanup_assigned_members_of_snapshot() self.__cleanup_assigned_members_of_snapshot()
......
...@@ -215,6 +215,11 @@ class InstanceTemplate(TimeStampedModel): ...@@ -215,6 +215,11 @@ class InstanceTemplate(TimeStampedModel):
# TODO: what is this? # TODO: what is this?
return 'template.%d' % self.pk return 'template.%d' % self.pk
def make_it_shared(self, request):
try:
openstack_api.glance.image_update(request, self.image_id, visibility="shared")
except:
pass # prior API 2.5 image became shared by adding members
class Instance(OperatedMixin, TimeStampedModel): class Instance(OperatedMixin, TimeStampedModel):
"""Virtual machine instance. """Virtual machine instance.
......
...@@ -531,7 +531,7 @@ class SaveAsTemplateOperation(InstanceOperation): ...@@ -531,7 +531,7 @@ class SaveAsTemplateOperation(InstanceOperation):
with_shutdown=True, clone=False, task=None, **kwargs): with_shutdown=True, clone=False, task=None, **kwargs):
template_image_id = openstack_api.nova.snapshot_create(request, self.instance.id, name) template_image_id = openstack_api.nova.snapshot_create(request, self.instance.id, name)
openstack_api.glance.image_update(request, template_image_id, visibility="shared") template.make_it_shared(request)
template = InstanceTemplate( template = InstanceTemplate(
name=name, name=name,
image_id=template_image_id, image_id=template_image_id,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment