Skip to content

Commit

Permalink
Merge "libvirt: remove hack from ensure_filtering_rules_for_instance"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Jul 2, 2014
2 parents 685c6cb + e3bbbdd commit aae8408
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 7 additions & 2 deletions nova/tests/virt/libvirt/test_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3898,6 +3898,9 @@ def sleep(self, t):

fake_timer = FakeTime()

def fake_sleep(t):
fake_timer.sleep(t)

# _fake_network_info must be called before create_fake_libvirt_mock(),
# as _fake_network_info calls importutils.import_class() and
# create_fake_libvirt_mock() mocks importutils.import_class().
Expand All @@ -3918,9 +3921,11 @@ def sleep(self, t):
self.stubs.Set(conn.firewall_driver,
'instance_filter_exists',
fake_none)
self.stubs.Set(greenthread,
'sleep',
fake_sleep)
conn.ensure_filtering_rules_for_instance(instance_ref,
network_info,
time_module=fake_timer)
network_info)
except exception.NovaException as e:
msg = ('The firewall filter for %s does not exist' %
instance_ref['name'])
Expand Down
8 changes: 2 additions & 6 deletions nova/virt/libvirt/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -4364,8 +4364,7 @@ def _cleanup_shared_storage_test_file(self, filename):
tmp_file = os.path.join(CONF.instances_path, filename)
os.remove(tmp_file)

def ensure_filtering_rules_for_instance(self, instance, network_info,
time_module=None):
def ensure_filtering_rules_for_instance(self, instance, network_info):
"""Ensure that an instance's filtering rules are enabled.
When migrating an instance, we need the filtering rules to
Expand All @@ -4376,9 +4375,6 @@ def ensure_filtering_rules_for_instance(self, instance, network_info,
that filtering rules exist for all running services.
"""

if not time_module:
time_module = greenthread

self.firewall_driver.setup_basic_filtering(instance, network_info)
self.firewall_driver.prepare_instance_filter(instance,
network_info)
Expand All @@ -4394,7 +4390,7 @@ def ensure_filtering_rules_for_instance(self, instance, network_info,
if len(timeout_count) == 0:
msg = _('The firewall filter for %s does not exist')
raise exception.NovaException(msg % instance.name)
time_module.sleep(1)
greenthread.sleep(1)

def filter_defer_apply_on(self):
self.firewall_driver.filter_defer_apply_on()
Expand Down

0 comments on commit aae8408

Please sign in to comment.