From a8c64e3336420ec5ff446f2ac5dcaf742d6a0f73 Mon Sep 17 00:00:00 2001 From: Michael Still Date: Thu, 7 Jun 2012 10:55:13 +1000 Subject: [PATCH] instance_destroy now only takes a uuid. As requested in https://review.openstack.org/#/c/8218/. You'll get an exception if you pass a non-uuid in. Change-Id: I0e54eeba7ea65fa8f6640b47c47abf8c7b4f6b79 --- nova/tests/test_db_api.py | 2 +- nova/tests/test_libvirt.py | 18 +++++++++--------- nova/tests/test_volume.py | 4 ++-- nova/tests/test_xenapi.py | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/nova/tests/test_db_api.py b/nova/tests/test_db_api.py index 292288c6..33297590 100644 --- a/nova/tests/test_db_api.py +++ b/nova/tests/test_db_api.py @@ -70,7 +70,7 @@ class DbApiTestCase(test.TestCase): inst1 = db.instance_create(self.context, args1) args2 = {'reservation_id': 'b', 'image_ref': 1, 'host': 'host1'} inst2 = db.instance_create(self.context, args2) - db.instance_destroy(self.context.elevated(), inst1['id']) + db.instance_destroy(self.context.elevated(), inst1['uuid']) result = db.instance_get_all_by_filters(self.context.elevated(), {}) self.assertEqual(2, len(result)) self.assertIn(inst1.id, [result[0].id, result[1].id]) diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index ef2374fc..92c3dd52 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -1219,7 +1219,7 @@ class LibvirtConnTestCase(test.TestCase): self.flags(libvirt_type=libvirt_type) conn = connection.LibvirtDriver(True) self.assertEquals(conn.uri, testuri) - db.instance_destroy(user_context, instance_ref['id']) + db.instance_destroy(user_context, instance_ref['uuid']) @test.skip_if(missing_libvirt(), "Test requires libvirt") def test_ensure_filtering_rules_for_instance_timeout(self): @@ -1270,7 +1270,7 @@ class LibvirtConnTestCase(test.TestCase): self.assertEqual(29, fake_timer.counter, "Didn't wait the expected " "amount of time") - db.instance_destroy(self.context, instance_ref['id']) + db.instance_destroy(self.context, instance_ref['uuid']) @test.skip_if(missing_libvirt(), "Test requires libvirt") def test_live_migration_raises_exception(self): @@ -1323,7 +1323,7 @@ class LibvirtConnTestCase(test.TestCase): self.assertTrue(volume_ref['status'] == 'in-use') db.volume_destroy(self.context, volume_ref['id']) - db.instance_destroy(self.context, instance_ref['id']) + db.instance_destroy(self.context, instance_ref['uuid']) def test_pre_live_migration_works_correctly(self): """Confirms pre_block_migration works correctly.""" @@ -1369,7 +1369,7 @@ class LibvirtConnTestCase(test.TestCase): self.assertTrue(os.path.exists('%s/%s/' % (tmpdir, instance_ref.name))) - db.instance_destroy(self.context, instance_ref['id']) + db.instance_destroy(self.context, instance_ref['uuid']) @test.skip_if(missing_libvirt(), "Test requires libvirt") def test_get_instance_disk_info_works_correctly(self): @@ -1430,7 +1430,7 @@ class LibvirtConnTestCase(test.TestCase): self.assertEquals(info[1]['virt_disk_size'], 21474836480) self.assertEquals(info[1]['backing_file'], "file") - db.instance_destroy(self.context, instance_ref['id']) + db.instance_destroy(self.context, instance_ref['uuid']) @test.skip_if(missing_libvirt(), "Test requires libvirt") def test_spawn_with_network_info(self): @@ -1956,7 +1956,7 @@ class IptablesFirewallTestCase(test.TestCase): '-m multiport --dports 80:81 -s 192.168.10.0/24') self.assertTrue(len(filter(regex.match, self.out_rules)) > 0, "TCP port 80/81 acceptance rule wasn't added") - db.instance_destroy(admin_ctxt, instance_ref['id']) + db.instance_destroy(admin_ctxt, instance_ref['uuid']) def test_filters_for_instance_with_ip_v6(self): self.flags(use_ipv6=True) @@ -2026,7 +2026,7 @@ class IptablesFirewallTestCase(test.TestCase): # should undefine just the instance filter self.assertEqual(original_filter_count - len(fakefilter.filters), 1) - db.instance_destroy(admin_ctxt, instance_ref['id']) + db.instance_destroy(admin_ctxt, instance_ref['uuid']) def test_provider_firewall_rules(self): # setup basic instance data @@ -2229,7 +2229,7 @@ class NWFilterTestCase(test.TestCase): db.instance_remove_security_group(self.context, inst_uuid, self.security_group.id) self.teardown_security_group() - db.instance_destroy(context.get_admin_context(), instance_ref['id']) + db.instance_destroy(context.get_admin_context(), instance_ref['uuid']) def test_unfilter_instance_undefines_nwfilters(self): admin_ctxt = context.get_admin_context() @@ -2255,7 +2255,7 @@ class NWFilterTestCase(test.TestCase): self.fw.unfilter_instance(instance, network_info) self.assertEqual(original_filter_count - len(fakefilter.filters), 1) - db.instance_destroy(admin_ctxt, instance_ref['id']) + db.instance_destroy(admin_ctxt, instance_ref['uuid']) class LibvirtUtilsTestCase(test.TestCase): diff --git a/nova/tests/test_volume.py b/nova/tests/test_volume.py index c8135cc2..c8788f3a 100644 --- a/nova/tests/test_volume.py +++ b/nova/tests/test_volume.py @@ -59,7 +59,7 @@ class VolumeTestCase(test.TestCase): test_notifier.NOTIFICATIONS = [] def tearDown(self): - db.instance_destroy(self.context, self.instance_id) + db.instance_destroy(self.context, self.instance_uuid) super(VolumeTestCase, self).tearDown() @staticmethod @@ -239,7 +239,7 @@ class VolumeTestCase(test.TestCase): db.volume_get, self.context, volume_id) - db.instance_destroy(self.context, instance_id) + db.instance_destroy(self.context, instance_uuid) def test_concurrent_volumes_get_different_targets(self): """Ensure multiple concurrent volumes get different targets.""" diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index 62bed35a..37708995 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -1500,7 +1500,7 @@ class XenAPIDom0IptablesFirewallTestCase(test.TestCase): self.assertTrue(len(filter(regex.match, self._out_rules)) > 0, "TCP port 80/81 acceptance rule wasn't added") - db.instance_destroy(admin_ctxt, instance_ref['id']) + db.instance_destroy(admin_ctxt, instance_ref['uuid']) def test_filters_for_instance_with_ip_v6(self): self.flags(use_ipv6=True)