diff options
author | Dmitry Tantsur <dtantsur@protonmail.com> | 2022-01-28 18:56:56 +0100 |
---|---|---|
committer | Dmitry Tantsur <dtantsur@protonmail.com> | 2022-01-28 18:56:56 +0100 |
commit | 374d5e5a3037a6b985933e734e902b2e05d805bb (patch) | |
tree | c887fd7f9bd1eb21439dc29cf19e9f0168c83b6a /ironic | |
parent | 365a4545fe6606b1fda8f1387e851641de25cec8 (diff) | |
download | ironic-374d5e5a3037a6b985933e734e902b2e05d805bb.tar.gz |
deploy_utils: only check glance for image properties kernel/ramdisk
Other image services cannot have them, not use making a network call.
Change-Id: I691ae5b67358ced5f0aa860b9ca6ccec58c897ad
Diffstat (limited to 'ironic')
-rw-r--r-- | ironic/drivers/modules/deploy_utils.py | 8 | ||||
-rw-r--r-- | ironic/tests/unit/drivers/modules/test_deploy_utils.py | 27 |
2 files changed, 3 insertions, 32 deletions
diff --git a/ironic/drivers/modules/deploy_utils.py b/ironic/drivers/modules/deploy_utils.py index f46250e2a..1aeda7acf 100644 --- a/ironic/drivers/modules/deploy_utils.py +++ b/ironic/drivers/modules/deploy_utils.py @@ -580,14 +580,10 @@ def validate_image_properties(task, deploy_info): boot_option = get_boot_option(task.node) if boot_option == 'kickstart': properties.append('stage2_id') - else: - properties = ['kernel', 'ramdisk'] - - if image_href: image_props = get_image_properties(task.context, image_href) else: - # Ramdisk deploy, no image_source is present - image_props = [] + properties = ['kernel', 'ramdisk'] + image_props = {} missing_props = [] for prop in properties: diff --git a/ironic/tests/unit/drivers/modules/test_deploy_utils.py b/ironic/tests/unit/drivers/modules/test_deploy_utils.py index bfa662fa8..c3ef5e204 100644 --- a/ironic/tests/unit/drivers/modules/test_deploy_utils.py +++ b/ironic/tests/unit/drivers/modules/test_deploy_utils.py @@ -1432,41 +1432,16 @@ class ValidateImagePropertiesTestCase(db_base.DbTestCase): utils.validate_image_properties, self.task, inst_info) - @mock.patch.object(image_service.HttpImageService, 'show', autospec=True) - def test_validate_image_properties_nonglance_image( - self, image_service_show_mock): + def test_validate_image_properties_nonglance_image(self): instance_info = { 'image_source': 'http://ubuntu', 'kernel': 'kernel_uuid', 'ramdisk': 'file://initrd', 'root_gb': 100, } - image_service_show_mock.return_value = {'size': 1, 'properties': {}} self.node.instance_info = instance_info inst_info = utils.get_image_instance_info(self.node) utils.validate_image_properties(self.task, inst_info) - image_service_show_mock.assert_called_once_with( - mock.ANY, instance_info['image_source']) - - @mock.patch.object(image_service.HttpImageService, 'show', autospec=True) - def test_validate_image_properties_nonglance_image_validation_fail( - self, img_service_show_mock): - instance_info = { - 'image_source': 'http://ubuntu', - 'kernel': 'kernel_uuid', - 'ramdisk': 'file://initrd', - 'root_gb': 100, - } - img_service_show_mock.side_effect = exception.ImageRefValidationFailed( - image_href='http://ubuntu', reason='HTTPError') - self.node.instance_info = instance_info - inst_info = utils.get_image_instance_info(self.node) - expected_error = ('Validation of image href http://ubuntu ' - 'failed, reason: HTTPError') - error = self.assertRaises(exception.InvalidParameterValue, - utils.validate_image_properties, - self.task, inst_info) - self.assertEqual(expected_error, str(error)) def test_validate_image_properties_boot_iso_conflict(self): instance_info = { |