diff --git a/openstack_dashboard/dashboards/project/images/images/forms.py b/openstack_dashboard/dashboards/project/images/images/forms.py index fac38bf..44205dc 100644 --- a/openstack_dashboard/dashboards/project/images/images/forms.py +++ b/openstack_dashboard/dashboards/project/images/images/forms.py @@ -43,7 +43,7 @@ class ImageURLField(forms.URLField): default_validators = [validators.URLValidator(schemes=["http", "https"])] -def create_image_metadata(data): +def create_image_metadata(data, initial=None): """Use the given dict of image form data to generate the metadata used for creating the image in glance. """ @@ -53,7 +53,12 @@ def create_image_metadata(data): # we will just set that to be that here instead of bothering the user # with asking them for information we can already determine. disk_format = data['disk_format'] - if disk_format in ('ami', 'aki', 'ari',): + if initial and initial.has_key( + 'container_format') and disk_format == data.get( + 'disk_format', None): + # Try to re-use old container_format if disk_format does not change. + container_format = initial['container_format'] + elif disk_format in ('ami', 'aki', 'ari',): container_format = disk_format elif disk_format == 'docker': # To support docker containers we allow the user to specify @@ -344,7 +349,7 @@ class UpdateImageForm(forms.SelfHandlingForm): def handle(self, request, data): image_id = data['image_id'] error_updating = _('Unable to update image "%s".') - meta = create_image_metadata(data) + meta = create_image_metadata(data, initial=self.initial) # Ensure we do not delete properties that have already been # set on an image. meta['purge_props'] = False diff --git a/openstack_dashboard/dashboards/project/images/images/views.py b/openstack_dashboard/dashboards/project/images/images/views.py index 771f29d..cb96fa3 100644 --- a/openstack_dashboard/dashboards/project/images/images/views.py +++ b/openstack_dashboard/dashboards/project/images/images/views.py @@ -106,7 +106,8 @@ class UpdateView(forms.ModalFormView): 'minimum_ram': getattr(image, 'min_ram', None), 'minimum_disk': getattr(image, 'min_disk', None), 'public': getattr(image, 'is_public', None), - 'protected': getattr(image, 'protected', None)} + 'protected': getattr(image, 'protected', None), + 'container_format': getattr(image, 'container_format', None),} disk_format = getattr(image, 'disk_format', None) if (disk_format == 'raw' and getattr(image, 'container_format') == 'docker'):