Merge "Fix missing obj_make_compatible() for ImageMetaProps object"
This commit is contained in:
commit
b12e72ff23
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
|
from nova import exception
|
||||||
from nova import objects
|
from nova import objects
|
||||||
from nova.objects import base
|
from nova.objects import base
|
||||||
from nova.objects import fields
|
from nova.objects import fields
|
||||||
@ -135,6 +136,30 @@ class ImageMetaProps(base.NovaObject):
|
|||||||
# Version 1.7: added img_config_drive field
|
# Version 1.7: added img_config_drive field
|
||||||
VERSION = ImageMeta.VERSION
|
VERSION = ImageMeta.VERSION
|
||||||
|
|
||||||
|
def obj_make_compatible(self, primitive, target_version):
|
||||||
|
super(ImageMetaProps, self).obj_make_compatible(primitive,
|
||||||
|
target_version)
|
||||||
|
target_version = utils.convert_version_to_tuple(target_version)
|
||||||
|
if target_version < (1, 7):
|
||||||
|
primitive.pop('img_config_drive', None)
|
||||||
|
if target_version < (1, 5):
|
||||||
|
primitive.pop('os_admin_user', None)
|
||||||
|
if target_version < (1, 4):
|
||||||
|
primitive.pop('hw_vif_multiqueue_enabled', None)
|
||||||
|
if target_version < (1, 2):
|
||||||
|
primitive.pop('img_hv_type', None)
|
||||||
|
primitive.pop('img_hv_requested_version', None)
|
||||||
|
if target_version < (1, 1):
|
||||||
|
primitive.pop('os_require_quiesce', None)
|
||||||
|
|
||||||
|
if target_version < (1, 6):
|
||||||
|
bus = primitive.get('hw_disk_bus', None)
|
||||||
|
if bus in ('lxc', 'uml'):
|
||||||
|
raise exception.ObjectActionError(
|
||||||
|
action='obj_make_compatible',
|
||||||
|
reason='hw_disk_bus=%s not supported in version %s' % (
|
||||||
|
bus, target_version))
|
||||||
|
|
||||||
# Maximum number of NUMA nodes permitted for the guest topology
|
# Maximum number of NUMA nodes permitted for the guest topology
|
||||||
NUMA_NODES_MAX = 128
|
NUMA_NODES_MAX = 128
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
from nova import exception
|
||||||
from nova import objects
|
from nova import objects
|
||||||
from nova import test
|
from nova import test
|
||||||
|
|
||||||
@ -274,3 +275,23 @@ class TestImageMetaProps(test.NoDBTestCase):
|
|||||||
self.assertIsNone(virtprops.get("hw_numa_nodes"))
|
self.assertIsNone(virtprops.get("hw_numa_nodes"))
|
||||||
self.assertEqual([set([0, 1, 2, 3])],
|
self.assertEqual([set([0, 1, 2, 3])],
|
||||||
virtprops.hw_numa_cpus)
|
virtprops.hw_numa_cpus)
|
||||||
|
|
||||||
|
def test_obj_make_compatible(self):
|
||||||
|
props = {
|
||||||
|
'img_config_drive': 'mandatory',
|
||||||
|
'os_admin_user': 'root',
|
||||||
|
'hw_vif_multiqueue_enabled': True,
|
||||||
|
'img_hv_type': 'kvm',
|
||||||
|
'img_hv_requested_version': '>= 1.0',
|
||||||
|
'os_require_quiesce': True,
|
||||||
|
}
|
||||||
|
|
||||||
|
obj = objects.ImageMetaProps(**props)
|
||||||
|
primitive = obj.obj_to_primitive('1.0')
|
||||||
|
self.assertFalse(any([x in primitive['nova_object.data']
|
||||||
|
for x in props]))
|
||||||
|
|
||||||
|
for bus in ('lxc', 'uml'):
|
||||||
|
obj.hw_disk_bus = bus
|
||||||
|
self.assertRaises(exception.ObjectActionError,
|
||||||
|
obj.obj_to_primitive, '1.0')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user