Skip to content

Commit

Permalink
Add virtual size to image detail
Browse files Browse the repository at this point in the history
In Icehouse, Glance added a new field, 'virtual_size', to hold the
virtual size (as opposed to on-disk size) of sparsed or compressed
images. In most cases, this is far more valuable to know than the
on-disk size of an image; for instance, the official Fedora 21 QCOW2
image is only 150 Mb on disk, but is a 3 Gb image. This patch adds an
optional 'virtual size' field to the image detail view, and makes the
"Launch Instance" modal use virtual size if it's available.

Closes-Bug: 1420944
Change-Id: I072635781c56f81502586afd69fe6691bd264a92
  • Loading branch information
Chris St. Pierre committed Feb 11, 2015
1 parent 094cb67 commit b4005d0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Expand Up @@ -45,6 +45,10 @@ <h4>{% trans "Specs" %}</h4>
<dl class="dl-horizontal">
<dt>{% trans "Size" %}</dt>
<dd>{{ image.size|filesizeformat }}</dd>
{% if image.virtual_size %}
<dt>{% trans "Virtual Size" %}</dt>
<dd>{{ image.virtual_size|filesizeformat }}</dd>
{% endif %}
<dt>{% trans "Container Format" %}</dt>
<dd>{{ image.container_format|default:_("None")|upper }}</dd>
<dt>{% trans "Disk Format" %}</dt>
Expand Down
Expand Up @@ -426,7 +426,7 @@ def populate_image_id_choices(self, request, context):
context.get('project_id'),
self._images_cache)
for image in images:
image.bytes = image.size
image.bytes = image.virtual_size or image.size
image.volume_size = max(
image.min_disk, functions.bytes_to_gigabytes(image.bytes))
choices.append((image.id, image))
Expand Down
10 changes: 10 additions & 0 deletions openstack_dashboard/test/test_data/glance_data.py
Expand Up @@ -74,6 +74,7 @@ def data(TEST):
'disk_format': u'qcow2',
'status': "active",
'size': 20 * 1024 ** 3,
'virtual_size': None,
'min_disk': 0,
'owner': TEST.tenant.id,
'container_format': 'novaImage',
Expand All @@ -88,6 +89,7 @@ def data(TEST):
'name': 'private_image',
'status': "active",
'size': 10 * 1024 ** 2,
'virtual_size': 20 * 1024 ** 2,
'min_disk': 0,
'owner': TEST.tenant.id,
'container_format': 'aki',
Expand All @@ -102,6 +104,7 @@ def data(TEST):
'status': "active",
'owner': TEST.tenant.id,
'size': 2 * 1024 ** 3,
'virtual_size': None,
'min_disk': 30,
'container_format': 'novaImage',
'properties': {'image_type': u'image'},
Expand All @@ -115,6 +118,7 @@ def data(TEST):
'name': None,
'status': "active",
'size': 5 * 1024 ** 3,
'virtual_size': None,
'min_disk': 0,
'owner': TEST.tenant.id,
'container_format': 'novaImage',
Expand All @@ -128,6 +132,7 @@ def data(TEST):
'name': 'private_image 2',
'status': "active",
'size': 30 * 1024 ** 3,
'virtual_size': None,
'min_disk': 0,
'owner': TEST.tenant.id,
'container_format': 'aki',
Expand All @@ -140,6 +145,7 @@ def data(TEST):
'name': 'private_image 3',
'status': "active",
'size': 2 * 1024 ** 3,
'virtual_size': None,
'min_disk': 0,
'owner': TEST.tenant.id,
'container_format': 'aki',
Expand All @@ -153,6 +159,7 @@ def data(TEST):
'name': 'shared_image 1',
'status': "active",
'size': 8 * 1024 ** 3,
'virtual_size': None,
'min_disk': 0,
'owner': 'someothertenant',
'container_format': 'aki',
Expand All @@ -167,6 +174,7 @@ def data(TEST):
'name': 'official_image 1',
'status': "active",
'size': 2 * 1024 ** 3,
'virtual_size': None,
'min_disk': 0,
'owner': 'officialtenant',
'container_format': 'aki',
Expand All @@ -179,6 +187,7 @@ def data(TEST):
'name': 'multi_prop_image',
'status': "active",
'size': 20 * 1024 ** 3,
'virtual_size': None,
'min_disk': 0,
'owner': TEST.tenant.id,
'container_format': 'novaImage',
Expand All @@ -193,6 +202,7 @@ def data(TEST):
image_dict = {'id': 'c8756975-7a3b-4e43-b7f7-433576112849',
'status': "active",
'size': 8 * 1024 ** 3,
'virtual_size': None,
'min_disk': 0,
'owner': 'someothertenant',
'container_format': 'aki',
Expand Down

0 comments on commit b4005d0

Please sign in to comment.