diff options
author | Kieran Spear <kispear@gmail.com> | 2013-12-05 16:37:20 +1100 |
---|---|---|
committer | Julie Pichon <jpichon@redhat.com> | 2014-05-22 11:54:43 +0100 |
commit | 4d0fff19753a3088a91d6fddec57c0a3b5077990 (patch) | |
tree | af91dd4929636f9651fce3b011206d31cef89c73 | |
parent | d933ad09a271f0a4215b2dfd393e110cdc69fcf5 (diff) | |
download | horizon-4d0fff19753a3088a91d6fddec57c0a3b5077990.tar.gz |
Fix display of images in Rebuild Instance
The image list in Rebuild Instance is constructed from (id, name)
pairs. As the name is a string, the transform function is never called
unless image name is None. In that case it crashes the view.
This change:
- Builds the image list with (id, image) so the correct thing
is passed to the transform
- Corrects the size/name attributes
- Handles None display name (displays id instead)
- Set the name of one of the public images in glance_data.py to
None so errors like these are picked up in the future.
Change-Id: I0d1f8594cccc404c0dd6f254b70d23789817dd06
Closes-bug: #1258349
(cherry picked from commit c720b4f90e59ad76ef846c8ba5b6b6d91883ee66)
-rw-r--r-- | openstack_dashboard/dashboards/project/instances/forms.py | 6 | ||||
-rw-r--r-- | openstack_dashboard/test/test_data/glance_data.py | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/openstack_dashboard/dashboards/project/instances/forms.py b/openstack_dashboard/dashboards/project/instances/forms.py index 5da688431..b8afdf779 100644 --- a/openstack_dashboard/dashboards/project/instances/forms.py +++ b/openstack_dashboard/dashboards/project/instances/forms.py @@ -31,8 +31,8 @@ from openstack_dashboard.dashboards.project.images_and_snapshots import utils def _image_choice_title(img): - gb = filesizeformat(img.bytes) - return '%s (%s)' % (img.display_name, gb) + gb = filesizeformat(img.size) + return '%s (%s)' % (img.name or img.id, gb) class RebuildInstanceForm(forms.SelfHandlingForm): @@ -56,7 +56,7 @@ class RebuildInstanceForm(forms.SelfHandlingForm): self.fields['instance_id'].initial = instance_id images = utils.get_available_images(request, request.user.tenant_id) - choices = [(image.id, image.name) for image in images] + choices = [(image.id, image) for image in images] if choices: choices.insert(0, ("", _("Select Image"))) else: diff --git a/openstack_dashboard/test/test_data/glance_data.py b/openstack_dashboard/test/test_data/glance_data.py index 166094fe7..0973e0ba2 100644 --- a/openstack_dashboard/test/test_data/glance_data.py +++ b/openstack_dashboard/test/test_data/glance_data.py @@ -87,7 +87,7 @@ def data(TEST): protected_image = images.Image(images.ImageManager(None), image_dict) image_dict = {'id': '278905a6-4b52-4d1e-98f9-8c57bb25ba32', - 'name': 'public_image 2', + 'name': None, 'status': "active", 'size': 5 * 1024 ** 3, 'owner': TEST.tenant.id, |