Support img_type Glance property
Follow-up to change I4ce5f7a2317d952f976194d2022328f4afbb0258. Change-Id: I36673c801d426ea9cb204ca52b6fb6f719eb396a Depends-On: https://review.opendev.org/c/openstack/glance/+/826684
This commit is contained in:
parent
a813c769e8
commit
c62c16bd22
@ -12,9 +12,30 @@ Add images to the Image service
|
||||
and note the image UUIDs in the Image service for each one as it is
|
||||
generated.
|
||||
|
||||
For *partition images*:
|
||||
- For *whole disk images* just upload the image:
|
||||
|
||||
- Add the kernel and ramdisk images to the Image service:
|
||||
.. code-block:: console
|
||||
|
||||
$ openstack image create my-whole-disk-image --public \
|
||||
--disk-format qcow2 --container-format bare \
|
||||
--file my-whole-disk-image.qcow2
|
||||
|
||||
.. warning::
|
||||
The kernel/ramdisk pair must not be set for whole disk images,
|
||||
otherwise they'll be mistaken for partition images.
|
||||
|
||||
- For *partition images* to be used only with *local boot* (the default)
|
||||
the ``img_type`` property must be set:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ openstack image create my-image --public \
|
||||
--disk-format qcow2 --container-format bare \
|
||||
--property img_type=partition --file my-image.qcow2
|
||||
|
||||
- For *partition images* to be used with both *local* and *network* boot:
|
||||
|
||||
Add the kernel and ramdisk images to the Image service:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
@ -30,7 +51,7 @@ Add images to the Image service
|
||||
|
||||
Store the image UUID obtained from the above step as ``MY_INITRD_UUID``.
|
||||
|
||||
- Add the *my-image* to the Image service which is going to be the OS
|
||||
Add the *my-image* to the Image service which is going to be the OS
|
||||
that the user is going to run. Also associate the above created
|
||||
images with this OS image. These two operations can be done by
|
||||
executing the following command:
|
||||
@ -42,19 +63,6 @@ Add images to the Image service
|
||||
kernel_id=$MY_VMLINUZ_UUID --property \
|
||||
ramdisk_id=$MY_INITRD_UUID --file my-image.qcow2
|
||||
|
||||
For *whole disk images*, skip uploading and configuring kernel and ramdisk
|
||||
images completely, proceed directly to uploading the main image:
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
$ openstack image create my-whole-disk-image --public \
|
||||
--disk-format qcow2 --container-format bare \
|
||||
--file my-whole-disk-image.qcow2
|
||||
|
||||
.. warning::
|
||||
The kernel/initramfs pair must not be set for whole disk images,
|
||||
otherwise they'll be mistaken for partition images.
|
||||
|
||||
#. Build or download the deploy images
|
||||
|
||||
The deploy images are used initially for preparing the server (creating disk
|
||||
|
@ -600,6 +600,10 @@ def is_whole_disk_image(ctx, instance_info):
|
||||
except Exception:
|
||||
return
|
||||
|
||||
image_type = iproperties.get('img_type')
|
||||
if image_type:
|
||||
return image_type != IMAGE_TYPE_PARTITION
|
||||
|
||||
is_whole_disk_image = (not iproperties.get('kernel_id')
|
||||
and not iproperties.get('ramdisk_id'))
|
||||
else:
|
||||
|
@ -242,6 +242,20 @@ class IronicImagesTestCase(base.TestCase):
|
||||
mock_igi.assert_called_once_with(image_source)
|
||||
mock_gip.assert_called_once_with('context', image_source)
|
||||
|
||||
@mock.patch.object(images, 'get_image_properties', autospec=True)
|
||||
@mock.patch.object(glance_utils, 'is_glance_image', autospec=True)
|
||||
def test_is_whole_disk_image_partition_image_with_type(self, mock_igi,
|
||||
mock_gip):
|
||||
mock_igi.return_value = True
|
||||
mock_gip.return_value = {'img_type': images.IMAGE_TYPE_PARTITION}
|
||||
instance_info = {'image_source': 'glance://partition_image'}
|
||||
image_source = instance_info['image_source']
|
||||
is_whole_disk_image = images.is_whole_disk_image('context',
|
||||
instance_info)
|
||||
self.assertFalse(is_whole_disk_image)
|
||||
mock_igi.assert_called_once_with(image_source)
|
||||
mock_gip.assert_called_once_with('context', image_source)
|
||||
|
||||
@mock.patch.object(images, 'get_image_properties', autospec=True)
|
||||
@mock.patch.object(glance_utils, 'is_glance_image', autospec=True)
|
||||
def test_is_whole_disk_image_whole_disk_image(self, mock_igi, mock_gip):
|
||||
|
@ -7,3 +7,5 @@ features:
|
||||
|
||||
Adding ``kernel`` and ``ramdisk`` is no longer necessary for partition
|
||||
images if ``image_type`` is set to ``partition`` and local boot is used.
|
||||
|
||||
The corresponding Image service property is called ``img_type``.
|
||||
|
Loading…
Reference in New Issue
Block a user