Add 'disabled' to WatchdogAction field
Image property hw_watchdog_action can have a 'disabled' value which is actually defined in the glance metadefs so someone using Horizon might pick that. Also, it's the default behavior in the libvirt driver. However, if you try to create a server with that set the create fails in nova-api because the enum field didn't have 'disabled' as a valid value. This adds it, bumps the ImageMetaProps version and adds tests. Change-Id: I4cec3e8b8527b909cc60893db26732a19263220d Closes-Bug: #1633200
This commit is contained in:
parent
12327ff595
commit
98d93196cd
|
@ -632,8 +632,9 @@ class WatchdogAction(BaseNovaEnum):
|
|||
PAUSE = "pause"
|
||||
POWEROFF = "poweroff"
|
||||
RESET = "reset"
|
||||
DISABLED = "disabled"
|
||||
|
||||
ALL = (NONE, PAUSE, POWEROFF, RESET)
|
||||
ALL = (NONE, PAUSE, POWEROFF, RESET, DISABLED)
|
||||
|
||||
|
||||
class MonitorMetricType(BaseNovaEnum):
|
||||
|
|
|
@ -164,12 +164,19 @@ class ImageMetaProps(base.NovaObject):
|
|||
# Version 1.13: added os_secure_boot field
|
||||
# Version 1.14: Added 'hw_pointer_model' field
|
||||
# Version 1.15: Added hw_rescue_bus and hw_rescue_device.
|
||||
VERSION = '1.15'
|
||||
# Version 1.16: WatchdogActionField supports 'disabled' enum.
|
||||
VERSION = '1.16'
|
||||
|
||||
def obj_make_compatible(self, primitive, target_version):
|
||||
super(ImageMetaProps, self).obj_make_compatible(primitive,
|
||||
target_version)
|
||||
target_version = versionutils.convert_version_to_tuple(target_version)
|
||||
if target_version < (1, 16) and 'hw_watchdog_action' in primitive:
|
||||
# Check to see if hw_watchdog_action was set to 'disabled' and if
|
||||
# so, remove it since not specifying it is the same behavior.
|
||||
if primitive['hw_watchdog_action'] == \
|
||||
fields.WatchdogAction.DISABLED:
|
||||
primitive.pop('hw_watchdog_action')
|
||||
if target_version < (1, 15):
|
||||
primitive.pop('hw_rescue_bus', None)
|
||||
primitive.pop('hw_rescue_device', None)
|
||||
|
|
|
@ -16,6 +16,7 @@ import datetime
|
|||
|
||||
from nova import exception
|
||||
from nova import objects
|
||||
from nova.objects import fields
|
||||
from nova import test
|
||||
|
||||
|
||||
|
@ -294,6 +295,7 @@ class TestImageMetaProps(test.NoDBTestCase):
|
|||
'os_secure_boot': 'required',
|
||||
'hw_rescue_bus': 'ide',
|
||||
'hw_rescue_device': 'disk',
|
||||
'hw_watchdog_action': fields.WatchdogAction.DISABLED,
|
||||
}
|
||||
|
||||
obj = objects.ImageMetaProps(**props)
|
||||
|
@ -306,6 +308,17 @@ class TestImageMetaProps(test.NoDBTestCase):
|
|||
self.assertRaises(exception.ObjectActionError,
|
||||
obj.obj_to_primitive, '1.0')
|
||||
|
||||
def test_obj_make_compatible_watchdog_action_not_disabled(self):
|
||||
"""Tests that we don't pop the hw_watchdog_action if the value is not
|
||||
'disabled'.
|
||||
"""
|
||||
obj = objects.ImageMetaProps(
|
||||
hw_watchdog_action=fields.WatchdogAction.PAUSE)
|
||||
primitive = obj.obj_to_primitive('1.0')
|
||||
self.assertIn('hw_watchdog_action', primitive['nova_object.data'])
|
||||
self.assertEqual(fields.WatchdogAction.PAUSE,
|
||||
primitive['nova_object.data']['hw_watchdog_action'])
|
||||
|
||||
def test_set_os_secure_boot(self):
|
||||
props = {'os_secure_boot': "required"}
|
||||
secure_props = objects.ImageMetaProps.from_dict(props)
|
||||
|
|
|
@ -1095,7 +1095,7 @@ object_data = {
|
|||
'HVSpec': '1.2-de06bcec472a2f04966b855a49c46b41',
|
||||
'IDEDeviceBus': '1.0-29d4c9f27ac44197f01b6ac1b7e16502',
|
||||
'ImageMeta': '1.8-642d1b2eb3e880a367f37d72dd76162d',
|
||||
'ImageMetaProps': '1.15-89dcdd30b2ec5995a45c8da73c9e1eb9',
|
||||
'ImageMetaProps': '1.16-3e5ad8e86f2ea36e565702162acc3e65',
|
||||
'Instance': '2.3-4f98ab23f4b0a25fabb1040c8f5edecc',
|
||||
'InstanceAction': '1.1-f9f293e526b66fca0d05c3b3a2d13914',
|
||||
'InstanceActionEvent': '1.1-e56a64fa4710e43ef7af2ad9d6028b33',
|
||||
|
|
Loading…
Reference in New Issue