Remove compatibility method from FlavorPayload

There is no support today to backport a versioned notification to older
version. Therefore implementing the obj_make_compatible call on payload
objects are not necessary and actually dead code. This patch removes
the only obj_make_compatible call that was implemented on the payloads.

Change-Id: I27d85d67536867b05758456e9be11ef50eef6aaa
This commit is contained in:
Balazs Gibizer 2017-10-25 09:20:24 +02:00 committed by Matt Riedemann
parent f974e3c356
commit 8099c15de8
2 changed files with 0 additions and 46 deletions

View File

@ -10,8 +10,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_utils import versionutils
from nova.notifications.objects import base
from nova.objects import base as nova_base
from nova.objects import fields
@ -83,24 +81,3 @@ class FlavorPayload(base.NotificationPayloadBase):
flavor = flavor.obj_clone()
flavor._context = None
self.populate_schema(flavor=flavor)
def obj_make_compatible(self, primitive, target_version):
super(FlavorPayload, self).obj_make_compatible(primitive,
target_version)
target_version = versionutils.convert_version_to_tuple(target_version)
if target_version < (1, 1):
primitive.pop('name', None)
primitive.pop('swap', None)
primitive.pop('rxtx_factor', None)
primitive.pop('vcpu_weight', None)
primitive.pop('disabled', None)
primitive.pop('is_public', None)
if target_version < (1, 2):
primitive.pop('extra_specs', None)
primitive.pop('projects', None)
if target_version < (1, 3):
if 'projects' not in primitive or primitive['projects'] is None:
primitive['projects'] = []
if ('extra_specs' not in primitive or
primitive['extra_specs'] is None):
primitive['extra_specs'] = {}

View File

@ -145,26 +145,3 @@ class TestFlavorNotification(test.TestCase):
self.assertEqual(['foo'], flavor_obj.projects)
# Since projects is loaded we shouldn't try to lazy-load it.
self._verify_notification(flavor_obj, flavor, "DELETE")
def test_obj_make_compatible(self):
flavor = copy.deepcopy(fake_flavor)
flavorid = '1'
flavor['flavorid'] = flavorid
flavor['id'] = flavorid
flavor_obj = objects.Flavor(context=self.ctxt, **flavor)
flavor_payload = flavor_notification.FlavorPayload(flavor_obj)
primitive = flavor_payload.obj_to_primitive()
self.assertIn('name', primitive['nova_object.data'])
self.assertIn('swap', primitive['nova_object.data'])
self.assertIn('rxtx_factor', primitive['nova_object.data'])
self.assertIn('vcpu_weight', primitive['nova_object.data'])
self.assertIn('disabled', primitive['nova_object.data'])
self.assertIn('is_public', primitive['nova_object.data'])
flavor_payload.obj_make_compatible(primitive['nova_object.data'],
'1.0')
self.assertNotIn('name', primitive['nova_object.data'])
self.assertNotIn('swap', primitive['nova_object.data'])
self.assertNotIn('rxtx_factor', primitive['nova_object.data'])
self.assertNotIn('vcpu_weight', primitive['nova_object.data'])
self.assertNotIn('disabled', primitive['nova_object.data'])
self.assertNotIn('is_public', primitive['nova_object.data'])