diff options
author | Zuul <zuul@review.opendev.org> | 2022-03-11 17:31:19 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2022-03-11 17:31:19 +0000 |
commit | 1d1cfbc1af8ae67613d085849508e31faf14a7d7 (patch) | |
tree | f237bade9b0a55a15966f7e6f04d7a4766e8300c | |
parent | 910448b8b331798701d103598541f96afb37fac0 (diff) | |
parent | c62c16bd223a8da2262a3dadf1905ef3c2a7c88b (diff) | |
download | ironic-1d1cfbc1af8ae67613d085849508e31faf14a7d7.tar.gz |
Merge "Support img_type Glance property"
-rw-r--r-- | doc/source/install/configure-glance-images.rst | 40 | ||||
-rw-r--r-- | ironic/common/images.py | 4 | ||||
-rw-r--r-- | ironic/tests/unit/common/test_images.py | 14 | ||||
-rw-r--r-- | releasenotes/notes/image-type-ac259a90393bdd2c.yaml | 2 |
4 files changed, 44 insertions, 16 deletions
diff --git a/doc/source/install/configure-glance-images.rst b/doc/source/install/configure-glance-images.rst index 361a31a7b..7c7f2ee57 100644 --- a/doc/source/install/configure-glance-images.rst +++ b/doc/source/install/configure-glance-images.rst @@ -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 diff --git a/ironic/common/images.py b/ironic/common/images.py index 30eaed9e3..9f771ca29 100644 --- a/ironic/common/images.py +++ b/ironic/common/images.py @@ -607,6 +607,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: diff --git a/ironic/tests/unit/common/test_images.py b/ironic/tests/unit/common/test_images.py index f3fbbbf77..fe6b67ad3 100644 --- a/ironic/tests/unit/common/test_images.py +++ b/ironic/tests/unit/common/test_images.py @@ -244,6 +244,20 @@ class IronicImagesTestCase(base.TestCase): @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): mock_igi.return_value = True mock_gip.return_value = {} diff --git a/releasenotes/notes/image-type-ac259a90393bdd2c.yaml b/releasenotes/notes/image-type-ac259a90393bdd2c.yaml index 3d2dfd064..b693f060b 100644 --- a/releasenotes/notes/image-type-ac259a90393bdd2c.yaml +++ b/releasenotes/notes/image-type-ac259a90393bdd2c.yaml @@ -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``. |