Merge "Remap custom named Image attributes when unsetting"
This commit is contained in:
@@ -55,6 +55,19 @@ DISK_CHOICES = [
|
|||||||
"iso",
|
"iso",
|
||||||
"ploop",
|
"ploop",
|
||||||
]
|
]
|
||||||
|
# A list of openstacksdk Image object attributes (values) that named
|
||||||
|
# differently from actual properties stored by Glance (keys).
|
||||||
|
IMAGE_ATTRIBUTES_CUSTOM_NAMES = {
|
||||||
|
'os_hidden': 'is_hidden',
|
||||||
|
'protected': 'is_protected',
|
||||||
|
'os_hash_algo': 'hash_algo',
|
||||||
|
'os_hash_value': 'hash_value',
|
||||||
|
'img_config_drive': 'needs_config_drive',
|
||||||
|
'os_secure_boot': 'needs_secure_boot',
|
||||||
|
'hw_vif_multiqueue_enabled': 'is_hw_vif_multiqueue_enabled',
|
||||||
|
'hw_boot_menu': 'is_hw_boot_menu_enabled',
|
||||||
|
'auto_disk_config': 'has_auto_disk_config',
|
||||||
|
}
|
||||||
MEMBER_STATUS_CHOICES = ["accepted", "pending", "rejected", "all"]
|
MEMBER_STATUS_CHOICES = ["accepted", "pending", "rejected", "all"]
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
@@ -1478,6 +1491,11 @@ class UnsetImage(command.Command):
|
|||||||
)
|
)
|
||||||
new_props.pop(k, None)
|
new_props.pop(k, None)
|
||||||
kwargs['properties'] = new_props
|
kwargs['properties'] = new_props
|
||||||
|
elif (
|
||||||
|
k in IMAGE_ATTRIBUTES_CUSTOM_NAMES
|
||||||
|
and IMAGE_ATTRIBUTES_CUSTOM_NAMES[k] in image
|
||||||
|
):
|
||||||
|
delattr(image, IMAGE_ATTRIBUTES_CUSTOM_NAMES[k])
|
||||||
else:
|
else:
|
||||||
LOG.error(
|
LOG.error(
|
||||||
_(
|
_(
|
||||||
|
@@ -1779,6 +1779,7 @@ class TestImageUnset(TestImage):
|
|||||||
attrs['hw_rng_model'] = 'virtio'
|
attrs['hw_rng_model'] = 'virtio'
|
||||||
attrs['prop'] = 'test'
|
attrs['prop'] = 'test'
|
||||||
attrs['prop2'] = 'fake'
|
attrs['prop2'] = 'fake'
|
||||||
|
attrs['os_secure_boot'] = 'required'
|
||||||
self.image = image_fakes.create_one_image(attrs)
|
self.image = image_fakes.create_one_image(attrs)
|
||||||
|
|
||||||
self.image_client.find_image.return_value = self.image
|
self.image_client.find_image.return_value = self.image
|
||||||
@@ -1822,11 +1823,18 @@ class TestImageUnset(TestImage):
|
|||||||
'hw_rng_model',
|
'hw_rng_model',
|
||||||
'--property',
|
'--property',
|
||||||
'prop',
|
'prop',
|
||||||
|
'--property',
|
||||||
|
'os_secure_boot',
|
||||||
self.image.id,
|
self.image.id,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# openstacksdk translates 'os_secure_boot' property to
|
||||||
|
# 'needs_secure_boot' Image attribute. This is true for
|
||||||
|
# all IMAGE_ATTRIBUTES_CUSTOM_NAMES keys
|
||||||
|
self.assertEqual(self.image.needs_secure_boot, 'required')
|
||||||
|
self.assertFalse(hasattr(self.image, 'os_secure_boot'))
|
||||||
verifylist = [
|
verifylist = [
|
||||||
('properties', ['hw_rng_model', 'prop']),
|
('properties', ['hw_rng_model', 'prop', 'os_secure_boot']),
|
||||||
('image', self.image.id),
|
('image', self.image.id),
|
||||||
]
|
]
|
||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
Reference in New Issue
Block a user