diff --git a/nova/objects/resource_provider.py b/nova/objects/resource_provider.py index 7ffbffef9cba..278f156445e6 100644 --- a/nova/objects/resource_provider.py +++ b/nova/objects/resource_provider.py @@ -2082,8 +2082,7 @@ class AllocationList(base.ObjectListBase, base.NovaObject): resource_class_id=rc_id, consumer_id=consumer_id, used=alloc.used) - result = context.session.execute(ins_stmt) - alloc.id = result.lastrowid + context.session.execute(ins_stmt) # Generation checking happens here. If the inventory for this resource # provider changed out from under us, this will raise a diff --git a/nova/tests/functional/db/test_resource_provider.py b/nova/tests/functional/db/test_resource_provider.py index 2293b8a5180f..a12d5e5b8f21 100644 --- a/nova/tests/functional/db/test_resource_provider.py +++ b/nova/tests/functional/db/test_resource_provider.py @@ -1217,7 +1217,6 @@ class TestAllocation(ResourceProviderBaseCase): disk_allocation.used) self.assertEqual(DISK_ALLOCATION['consumer_id'], disk_allocation.consumer_id) - self.assertIsInstance(disk_allocation.id, int) allocations = rp_obj.AllocationList.get_all_by_resource_provider( self.ctx, resource_provider) diff --git a/nova/tests/unit/objects/test_resource_provider.py b/nova/tests/unit/objects/test_resource_provider.py index 15cf72899ee9..674124dbbac0 100644 --- a/nova/tests/unit/objects/test_resource_provider.py +++ b/nova/tests/unit/objects/test_resource_provider.py @@ -352,9 +352,13 @@ class TestAllocation(test_objects._LocalTest): used=8) alloc_list = resource_provider.AllocationList(self.context, objects=[obj]) - self.assertNotIn("id", obj) alloc_list.create_all() - self.assertIn("id", obj) + + rp_al = resource_provider.AllocationList + saved_allocations = rp_al.get_all_by_resource_provider( + self.context, rp) + self.assertEqual(1, len(saved_allocations)) + self.assertEqual(obj.used, saved_allocations[0].used) def test_create_with_id_fails(self): rp = resource_provider.ResourceProvider(context=self.context,