Merge "Do not set allocation.id in AllocationList.create_all()" into stable/pike
This commit is contained in:
commit
3e80588f5a
|
@ -1850,8 +1850,7 @@ class AllocationList(base.ObjectListBase, base.NovaObject):
|
|||
resource_class_id=rc_id,
|
||||
consumer_id=alloc.consumer_id,
|
||||
used=alloc.used)
|
||||
result = conn.execute(ins_stmt)
|
||||
alloc.id = result.lastrowid
|
||||
conn.execute(ins_stmt)
|
||||
|
||||
# Generation checking happens here. If the inventory for
|
||||
# this resource provider changed out from under us,
|
||||
|
|
|
@ -841,7 +841,6 @@ class TestAllocation(ResourceProviderBaseCase):
|
|||
disk_allocation.used)
|
||||
self.assertEqual(DISK_ALLOCATION['consumer_id'],
|
||||
disk_allocation.consumer_id)
|
||||
self.assertIsInstance(disk_allocation.id, int)
|
||||
|
||||
allocations = objects.AllocationList.get_all_by_resource_provider_uuid(
|
||||
self.ctx, resource_provider.uuid)
|
||||
|
@ -997,12 +996,13 @@ class TestAllocation(ResourceProviderBaseCase):
|
|||
allocations = objects.AllocationList.get_all_by_resource_provider_uuid(
|
||||
self.ctx, rp.uuid)
|
||||
self.assertEqual(1, len(allocations))
|
||||
objects.Allocation._destroy(self.ctx, allocation.id)
|
||||
allocation_id = allocations[0].id
|
||||
objects.Allocation._destroy(self.ctx, allocation_id)
|
||||
allocations = objects.AllocationList.get_all_by_resource_provider_uuid(
|
||||
self.ctx, rp.uuid)
|
||||
self.assertEqual(0, len(allocations))
|
||||
self.assertRaises(exception.NotFound, objects.Allocation._destroy,
|
||||
self.ctx, allocation.id)
|
||||
self.ctx, allocation_id)
|
||||
|
||||
def test_get_allocations_from_db(self):
|
||||
rp, allocation = self._make_allocation()
|
||||
|
|
|
@ -513,9 +513,13 @@ class TestAllocation(test_objects._LocalTest):
|
|||
consumer_id=uuids.fake_instance,
|
||||
used=8)
|
||||
alloc_list = objects.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_uuid(
|
||||
self.context, rp.uuid)
|
||||
self.assertEqual(1, len(saved_allocations))
|
||||
self.assertEqual(obj.used, saved_allocations[0].used)
|
||||
|
||||
def test_create_with_id_fails(self):
|
||||
rp = objects.ResourceProvider(context=self.context,
|
||||
|
|
Loading…
Reference in New Issue