Add virtual size to image detail
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
This commit is contained in:
parent
094cb67846
commit
b4005d0871
@ -45,6 +45,10 @@
|
||||
<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>
|
||||
|
@ -426,7 +426,7 @@ class SetInstanceDetailsAction(workflows.Action):
|
||||
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))
|
||||
|
@ -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',
|
||||
@ -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',
|
||||
@ -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'},
|
||||
@ -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',
|
||||
@ -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',
|
||||
@ -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',
|
||||
@ -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',
|
||||
@ -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',
|
||||
@ -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',
|
||||
@ -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',
|
||||
|
Loading…
Reference in New Issue
Block a user