diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-09-14 15:07:52 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-09-14 15:07:52 +0000 |
| commit | f252719056e6ebc9fea3eebc2ab3852eb7ddee84 (patch) | |
| tree | 49b79b525ce142972bf0df95ec7811e5a79c5ba4 /nova | |
| parent | cea105a22d1c9d66a3a0b6649e84737c795f743c (diff) | |
| parent | 4d2b9edd8656719f7a09063c0f5125d05c358931 (diff) | |
| download | nova-f252719056e6ebc9fea3eebc2ab3852eb7ddee84.tar.gz nova-f252719056e6ebc9fea3eebc2ab3852eb7ddee84.tar.xz nova-f252719056e6ebc9fea3eebc2ab3852eb7ddee84.zip | |
Merge "libvirt: Cleanup L2 and L3 rules when confirm vm resize"
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/tests/test_libvirt.py | 49 | ||||
| -rw-r--r-- | nova/virt/libvirt/driver.py | 7 |
2 files changed, 54 insertions, 2 deletions
diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index ede5afd31..d0b89f78f 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -3807,6 +3807,55 @@ class LibvirtDriverTestCase(test.TestCase): self.libvirtconnection.finish_revert_migration(ins_ref, None) + def test_confirm_migration(self): + ins_ref = self._create_instance() + + self.mox.StubOutWithMock(self.libvirtconnection, "_cleanup_resize") + self.libvirtconnection._cleanup_resize(ins_ref, + _fake_network_info(self.stubs, 1)) + + self.mox.ReplayAll() + self.libvirtconnection.confirm_migration("migration_ref", ins_ref, + _fake_network_info(self.stubs, 1)) + + def test_cleanup_resize_same_host(self): + ins_ref = self._create_instance({'host': FLAGS.host}) + + def fake_os_path_exists(path): + return True + + def fake_shutil_rmtree(target): + pass + + self.stubs.Set(os.path, 'exists', fake_os_path_exists) + self.stubs.Set(shutil, 'rmtree', fake_shutil_rmtree) + + self.mox.ReplayAll() + self.libvirtconnection._cleanup_resize(ins_ref, + _fake_network_info(self.stubs, 1)) + + def test_cleanup_resize_not_same_host(self): + host = 'not' + FLAGS.host + ins_ref = self._create_instance({'host': host}) + + def fake_os_path_exists(path): + return True + + def fake_shutil_rmtree(target): + pass + + def fake_unfilter_instance(instance, network_info): + pass + + self.stubs.Set(os.path, 'exists', fake_os_path_exists) + self.stubs.Set(shutil, 'rmtree', fake_shutil_rmtree) + self.stubs.Set(self.libvirtconnection.firewall_driver, + 'unfilter_instance', fake_unfilter_instance) + + self.mox.ReplayAll() + self.libvirtconnection._cleanup_resize(ins_ref, + _fake_network_info(self.stubs, 1)) + class LibvirtNonblockingTestCase(test.TestCase): """Test libvirt_nonblocking option""" diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 9e8f95e09..9b6e6e9b4 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -594,12 +594,15 @@ class LibvirtDriver(driver.ComputeDriver): 'host': FLAGS.host } - def _cleanup_resize(self, instance): + def _cleanup_resize(self, instance, network_info): target = os.path.join(FLAGS.instances_path, instance['name'] + "_resize") if os.path.exists(target): shutil.rmtree(target) + if instance['host'] != FLAGS.host: + self.firewall_driver.unfilter_instance(instance, network_info) + def volume_driver_method(self, method_name, connection_info, *args, **kwargs): driver_type = connection_info.get('driver_volume_type') @@ -2889,7 +2892,7 @@ class LibvirtDriver(driver.ComputeDriver): def confirm_migration(self, migration, instance, network_info): """Confirms a resize, destroying the source VM""" - self._cleanup_resize(instance) + self._cleanup_resize(instance, network_info) def get_diagnostics(self, instance): def get_io_devices(xml_doc): |
