diff options
| author | Ryu Ishimoto <ryu@midokura.jp> | 2011-07-22 22:12:15 +0900 |
|---|---|---|
| committer | Ryu Ishimoto <ryu@midokura.jp> | 2011-07-22 22:12:15 +0900 |
| commit | 93ffbbb234df486a1adb558a5228a7f23ea3451b (patch) | |
| tree | 5cb702f562cf9b311e51b7db30789de9770095ee | |
| parent | 0880f170318cfa5d12b10e237f641b27c646c8b2 (diff) | |
Added network_info to unfilter_instance to avoid exceptions when shutting down instances
| -rw-r--r-- | nova/compute/manager.py | 3 | ||||
| -rw-r--r-- | nova/tests/test_compute.py | 2 | ||||
| -rw-r--r-- | nova/virt/driver.py | 2 | ||||
| -rw-r--r-- | nova/virt/fake.py | 2 | ||||
| -rw-r--r-- | nova/virt/libvirt/connection.py | 8 | ||||
| -rw-r--r-- | nova/virt/libvirt/firewall.py | 11 | ||||
| -rw-r--r-- | nova/virt/xenapi_conn.py | 2 |
7 files changed, 17 insertions, 13 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py index aeecdecfa..da84b98cb 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -1314,8 +1314,9 @@ class ComputeManager(manager.SchedulerDependentManager): # Releasing vlan. # (not necessary in current implementation?) + network_info = self._get_instance_nw_info(ctxt, instance_ref) # Releasing security group ingress rule. - self.driver.unfilter_instance(instance_ref) + self.driver.unfilter_instance(instance_ref, network_info=network_info) # Database updating. i_name = instance_ref.name diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index 42520c9a6..b80813220 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -828,7 +828,7 @@ class ComputeTestCase(test.TestCase): for v in i_ref['volumes']: self.compute.volume_manager.remove_compute_volume(c, v['id']) self.mox.StubOutWithMock(self.compute.driver, 'unfilter_instance') - self.compute.driver.unfilter_instance(i_ref) + self.compute.driver.unfilter_instance(i_ref, network_info=[]) # executing self.mox.ReplayAll() diff --git a/nova/virt/driver.py b/nova/virt/driver.py index 2faff0a1e..5c3130dfc 100644 --- a/nova/virt/driver.py +++ b/nova/virt/driver.py @@ -224,7 +224,7 @@ class ComputeDriver(object): """ raise NotImplementedError() - def unfilter_instance(self, instance): + def unfilter_instance(self, instance, network_info=None): """Stop filtering instance""" raise NotImplementedError() diff --git a/nova/virt/fake.py b/nova/virt/fake.py index c5e9d89e4..26bc421c0 100644 --- a/nova/virt/fake.py +++ b/nova/virt/fake.py @@ -499,7 +499,7 @@ class FakeConnection(driver.ComputeDriver): """This method is supported only by libvirt.""" return - def unfilter_instance(self, instance_ref): + def unfilter_instance(self, instance_ref, network_info=None): """This method is supported only by libvirt.""" raise NotImplementedError('This method is supported only by libvirt.') diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py index 585cd74a3..d4f547ec4 100644 --- a/nova/virt/libvirt/connection.py +++ b/nova/virt/libvirt/connection.py @@ -333,7 +333,8 @@ class LibvirtConnection(driver.ComputeDriver): timer = utils.LoopingCall(_wait_for_destroy) timer.start(interval=0.5, now=True) - self.firewall_driver.unfilter_instance(instance) + self.firewall_driver.unfilter_instance(instance, + network_info=network_info) if cleanup: self._cleanup(instance) @@ -1569,9 +1570,10 @@ class LibvirtConnection(driver.ComputeDriver): timer.f = wait_for_live_migration timer.start(interval=0.5, now=True) - def unfilter_instance(self, instance_ref): + def unfilter_instance(self, instance_ref, network_info=None): """See comments of same method in firewall_driver.""" - self.firewall_driver.unfilter_instance(instance_ref) + self.firewall_driver.unfilter_instance(instance_ref, + network_info=network_info) def update_host_status(self): """See xenapi_conn.py implementation.""" diff --git a/nova/virt/libvirt/firewall.py b/nova/virt/libvirt/firewall.py index 379197398..9ce57b6c9 100644 --- a/nova/virt/libvirt/firewall.py +++ b/nova/virt/libvirt/firewall.py @@ -46,7 +46,7 @@ class FirewallDriver(object): At this point, the instance isn't running yet.""" raise NotImplementedError() - def unfilter_instance(self, instance): + def unfilter_instance(self, instance, network_info=None): """Stop filtering instance""" raise NotImplementedError() @@ -300,9 +300,10 @@ class NWFilterFirewall(FirewallDriver): # execute in a native thread and block current greenthread until done tpool.execute(self._conn.nwfilterDefineXML, xml) - def unfilter_instance(self, instance): + def unfilter_instance(self, instance, network_info=None): """Clear out the nwfilter rules.""" - network_info = netutils.get_network_info(instance) + if not network_info: + network_info = netutils.get_network_info(instance) instance_name = instance.name for (network, mapping) in network_info: nic_id = mapping['mac'].replace(':', '') @@ -542,11 +543,11 @@ class IptablesFirewallDriver(FirewallDriver): """No-op. Everything is done in prepare_instance_filter""" pass - def unfilter_instance(self, instance): + def unfilter_instance(self, instance, network_info=None): if self.instances.pop(instance['id'], None): self.remove_filters_for_instance(instance) self.iptables.apply() - self.nwfilter.unfilter_instance(instance) + self.nwfilter.unfilter_instance(instance, network_info) else: LOG.info(_('Attempted to unfilter instance %s which is not ' 'filtered'), instance['id']) diff --git a/nova/virt/xenapi_conn.py b/nova/virt/xenapi_conn.py index 102278e1c..03ed2ecbe 100644 --- a/nova/virt/xenapi_conn.py +++ b/nova/virt/xenapi_conn.py @@ -325,7 +325,7 @@ class XenAPIConnection(driver.ComputeDriver): """This method is supported only by libvirt.""" return - def unfilter_instance(self, instance_ref): + def unfilter_instance(self, instance_ref, network_info=None): """This method is supported only by libvirt.""" raise NotImplementedError('This method is supported only by libvirt.') |
