Skip to content

Commit

Permalink
virt/firewall: NoopFirewallDriver::instance_filter_exists must return…
Browse files Browse the repository at this point in the history
… True

Otherwise, virt.libvirt.connection.ensure_filtering_rules_for_instance()
results in infinite loop.
And eliminate NullFirewallDriver as it's same to NoopFirewallDriver.
This patch fixes bug 953781.

Change-Id: I7936b3c69e9269041defd1ef7e5dda2de1f96dab
  • Loading branch information
Isaku Yamahata committed Mar 13, 2012
1 parent 7778521 commit 7c50652
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 30 deletions.
32 changes: 2 additions & 30 deletions nova/tests/test_libvirt.py
Expand Up @@ -2091,34 +2091,6 @@ def tearDown(self):
except Exception:
pass

class NullFirewallDriver(base_firewall.FirewallDriver):
def __init__(self, get_connection, **kwargs):
pass

def prepare_instance_filter(self, instance, network_info):
pass

def unfilter_instance(self, instance, network_info):
pass

def apply_instance_filter(self, instance, network_info):
pass

def refresh_security_group_rules(self, security_group_id):
pass

def refresh_security_group_members(self, security_group_id):
pass

def refresh_provider_fw_rules(self):
pass

def setup_basic_filtering(self, instance, network_info):
pass

def instance_filter_exists(self, instance, network_info):
return True

def _create_instance(self, params=None):
"""Create a test instance"""
if not params:
Expand Down Expand Up @@ -2296,7 +2268,7 @@ def fake_execute(*args, **kwargs):
self.stubs.Set(self.libvirtconnection, '_create_new_domain',
fake_create_new_domain)
self.stubs.Set(utils, 'execute', fake_execute)
fw = self.NullFirewallDriver(None)
fw = base_firewall.NoopFirewallDriver()
self.stubs.Set(self.libvirtconnection, 'firewall_driver', fw)

ins_ref = self._create_instance()
Expand All @@ -2321,7 +2293,7 @@ def fake_create_new_domain(xml):

self.stubs.Set(self.libvirtconnection, 'plug_vifs', fake_plug_vifs)
self.stubs.Set(utils, 'execute', fake_execute)
fw = self.NullFirewallDriver(None)
fw = base_firewall.NoopFirewallDriver()
self.stubs.Set(self.libvirtconnection, 'firewall_driver', fw)
self.stubs.Set(self.libvirtconnection, '_create_new_domain',
fake_create_new_domain)
Expand Down
3 changes: 3 additions & 0 deletions nova/virt/firewall.py
Expand Up @@ -453,3 +453,6 @@ def _noop(*args, **kwargs):

def __getattr__(self, key):
return self._noop

def instance_filter_exists(self, instance, network_info):
return True

0 comments on commit 7c50652

Please sign in to comment.