Merge "[ovo]Add igb value to hw_vif_model image property"

This commit is contained in:
Zuul
2024-10-29 17:05:55 +00:00
committed by Gerrit Code Review
8 changed files with 33 additions and 7 deletions

View File

@@ -4,5 +4,5 @@
"hw_architecture": "x86_64"
},
"nova_object.name": "ImageMetaPropsPayload",
"nova_object.version": "1.14"
"nova_object.version": "1.15"
}

View File

@@ -148,6 +148,7 @@ VIF_MODEL_E1000E = 'e1000e'
VIF_MODEL_NETFRONT = 'netfront'
VIF_MODEL_SPAPR_VLAN = 'spapr-vlan'
VIF_MODEL_LAN9118 = 'lan9118'
VIF_MODEL_IGB = 'igb'
VIF_MODEL_SRIOV = 'sriov'
VIF_MODEL_VMXNET = 'vmxnet'
@@ -166,6 +167,7 @@ VIF_MODEL_ALL = (
VIF_MODEL_SRIOV,
VIF_MODEL_VMXNET,
VIF_MODEL_VMXNET3,
VIF_MODEL_IGB,
)
# these types have been leaked to guests in network_data.json

View File

@@ -132,7 +132,8 @@ class ImageMetaPropsPayload(base.NotificationPayloadBase):
# Version 1.12: Added 'hw_viommu_model' field
# Version 1.13: Added 'hw_virtio_packed_ring' field
# Version 1.14: Added 'hw_firmware_stateless' field
VERSION = '1.14'
# Version 1.15: Added igb value to 'hw_vif_model' enum
VERSION = '1.15'
# NOTE(efried): This logic currently relies on all of the fields of
# ImageMetaProps being initialized with no arguments. See the docstring.

View File

@@ -16,6 +16,7 @@ import copy
from oslo_utils import versionutils
from nova.network import model as network_model
from nova import objects
from nova.objects import base
from nova.objects import fields
@@ -196,14 +197,19 @@ class ImageMetaProps(base.NovaObject):
# 'hw_maxphysaddr_bits' field
# Version 1.37: Added 'hw_ephemeral_encryption_secret_uuid' field
# Version 1.38: Added 'hw_firmware_stateless' field
# Version 1.39: Added igb value to 'hw_vif_model' enum
# NOTE(efried): When bumping this version, the version of
# ImageMetaPropsPayload must also be bumped. See its docstring for details.
VERSION = '1.38'
VERSION = '1.39'
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, 39):
base.raise_on_too_new_values(
target_version, primitive,
'hw_vif_model', (network_model.VIF_MODEL_IGB,))
if target_version < (1, 38):
primitive.pop('hw_firmware_stateless', None)
if target_version < (1, 37):

View File

@@ -1238,7 +1238,7 @@ class TestInstanceNotificationSample(
'nova_object.data': {},
'nova_object.name': 'ImageMetaPropsPayload',
'nova_object.namespace': 'nova',
'nova_object.version': '1.14',
'nova_object.version': '1.15',
},
'image.size': 58145823,
'image.tags': [],
@@ -1334,7 +1334,7 @@ class TestInstanceNotificationSample(
'nova_object.data': {},
'nova_object.name': 'ImageMetaPropsPayload',
'nova_object.namespace': 'nova',
'nova_object.version': '1.14',
'nova_object.version': '1.15',
},
'image.size': 58145823,
'image.tags': [],

View File

@@ -385,7 +385,7 @@ notification_object_data = {
# ImageMetaProps, so when you see a fail here for that reason, you must
# *also* bump the version of ImageMetaPropsPayload. See its docstring for
# more information.
'ImageMetaPropsPayload': '1.14-af9efd17cd034596be792fa25f24e83d',
'ImageMetaPropsPayload': '1.15-a3d7a75fedbf373bcab2d9d6ece249df',
'InstanceActionNotification': '1.0-a73147b93b520ff0061865849d3dfa56',
'InstanceActionPayload': '1.8-b948818df6ec562e4eb4b23e515e451b',
'InstanceActionRebuildNotification':

View File

@@ -17,6 +17,7 @@ import datetime
from oslo_utils.fixture import uuidsentinel as uuids
from nova import exception
from nova.network import model as network_model
from nova import objects
from nova.objects import fields
from nova import test
@@ -608,3 +609,19 @@ class TestImageMetaProps(test.NoDBTestCase):
self.assertNotIn(
'hw_firmware_stateless',
primitive['nova_object.data'])
def test_obj_make_compatible_vif_model_igb(self):
obj = objects.ImageMetaProps(hw_vif_model=network_model.VIF_MODEL_IGB)
primitive = obj.obj_to_primitive('1.39')
self.assertIn(
'hw_vif_model',
primitive['nova_object.data'])
self.assertEqual(
network_model.VIF_MODEL_IGB,
primitive['nova_object.data']['hw_vif_model'])
ex = self.assertRaises(
exception.ObjectActionError, obj.obj_to_primitive, '1.38')
self.assertIn(
'hw_vif_model=igb not supported in version (1, 38)', str(ex))

View File

@@ -1105,7 +1105,7 @@ object_data = {
'HyperVLiveMigrateData': '1.4-e265780e6acfa631476c8170e8d6fce0',
'IDEDeviceBus': '1.0-29d4c9f27ac44197f01b6ac1b7e16502',
'ImageMeta': '1.8-642d1b2eb3e880a367f37d72dd76162d',
'ImageMetaProps': '1.38-1f4f4f1b60413aa543e446d716cfbc20',
'ImageMetaProps': '1.39-b0fb2690fa477480e42a1469769cb9fc',
'Instance': '2.8-2727dba5e4a078e6cc848c1f94f7eb24',
'InstanceAction': '1.2-9a5abc87fdd3af46f45731960651efb5',
'InstanceActionEvent': '1.4-5b1f361bd81989f8bb2c20bb7e8a4cb4',