+ # Now let's hack the RequestSpec.is_bfv field to mimic migrating an
+ # old instance created before RequestSpec.is_bfv was set in the API,
+ # move the instance and verify that the RequestSpec.is_bfv is set
+ # and the instance still reports the same DISK_GB allocations as during
+ # the initial create.
+ ctxt = context.get_admin_context()
+ reqspec = objects.RequestSpec.get_by_instance_uuid(ctxt, server['id'])
+ del reqspec.is_bfv
+ reqspec.save()
+ reqspec = objects.RequestSpec.get_by_instance_uuid(ctxt, server['id'])
+ # Make sure it's not set.
+ self.assertNotIn('is_bfv', reqspec)
+ rebuild_image_ref = ( nova.tests.unit.image.fake.AUTO_DISK_CONFIG_ENABLED_IMAGE_UUID)
# Now rebuild the server with a different image.
osboxes@osboxes:~/git/nova$
{0} nova.tests.functional.test_servers.ServerRebuildTestCase.test_rebuild_with_new_image [8.071310s] ... ok
I made this change to try and test scenario #4 but the test still passed which was unexpected:
diff --git a/nova/ tests/functiona l/test_ servers. py b/nova/ tests/functiona l/test_ servers. py tests/functiona l/test_ servers. py tests/functiona l/test_ servers. py stCase( integrated_ helpers. _IntegratedTest Base, rp_uuid] ['resources' ]
assertFlavorM atchesAllocatio n(flavor, allocs)
index 67c0fe9..c73d6a2 100644
--- a/nova/
+++ b/nova/
@@ -1409,6 +1409,19 @@ class ServerRebuildTe
allocs = allocs[
+ # Now let's hack the RequestSpec.is_bfv field to mimic migrating an get_admin_ context( ) RequestSpec. get_by_ instance_ uuid(ctxt, server['id']) RequestSpec. get_by_ instance_ uuid(ctxt, server['id']) n('is_bfv' , reqspec)
rebuild_ image_ref = (
nova. tests.unit. image.fake. AUTO_DISK_ CONFIG_ ENABLED_ IMAGE_UUID) osboxes: ~/git/nova$
+ # old instance created before RequestSpec.is_bfv was set in the API,
+ # move the instance and verify that the RequestSpec.is_bfv is set
+ # and the instance still reports the same DISK_GB allocations as during
+ # the initial create.
+ ctxt = context.
+ reqspec = objects.
+ del reqspec.is_bfv
+ reqspec.save()
+ reqspec = objects.
+ # Make sure it's not set.
+ self.assertNotI
+
# Now rebuild the server with a different image.
osboxes@
{0} nova.tests. functional. test_servers. ServerRebuildTe stCase. test_rebuild_ with_new_ image [8.071310s] ... ok