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
This commit is contained in:
Dmitry Tantsur 2022-01-28 18:56:56 +01:00
parent 365a4545fe
commit 374d5e5a30
2 changed files with 3 additions and 32 deletions

View File

@ -580,14 +580,10 @@ def validate_image_properties(task, deploy_info):
boot_option = get_boot_option(task.node) boot_option = get_boot_option(task.node)
if boot_option == 'kickstart': if boot_option == 'kickstart':
properties.append('stage2_id') properties.append('stage2_id')
else:
properties = ['kernel', 'ramdisk']
if image_href:
image_props = get_image_properties(task.context, image_href) image_props = get_image_properties(task.context, image_href)
else: else:
# Ramdisk deploy, no image_source is present properties = ['kernel', 'ramdisk']
image_props = [] image_props = {}
missing_props = [] missing_props = []
for prop in properties: for prop in properties:

View File

@ -1432,41 +1432,16 @@ class ValidateImagePropertiesTestCase(db_base.DbTestCase):
utils.validate_image_properties, self.task, utils.validate_image_properties, self.task,
inst_info) inst_info)
@mock.patch.object(image_service.HttpImageService, 'show', autospec=True) def test_validate_image_properties_nonglance_image(self):
def test_validate_image_properties_nonglance_image(
self, image_service_show_mock):
instance_info = { instance_info = {
'image_source': 'http://ubuntu', 'image_source': 'http://ubuntu',
'kernel': 'kernel_uuid', 'kernel': 'kernel_uuid',
'ramdisk': 'file://initrd', 'ramdisk': 'file://initrd',
'root_gb': 100, 'root_gb': 100,
} }
image_service_show_mock.return_value = {'size': 1, 'properties': {}}
self.node.instance_info = instance_info self.node.instance_info = instance_info
inst_info = utils.get_image_instance_info(self.node) inst_info = utils.get_image_instance_info(self.node)
utils.validate_image_properties(self.task, inst_info) 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): def test_validate_image_properties_boot_iso_conflict(self):
instance_info = { instance_info = {