summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authortermie <github@anarkystic.com>2011-03-24 18:51:38 +0000
committerTarmac <>2011-03-24 18:51:38 +0000
commit0d42b309ac723d18e6795210bc8d8ca6d295de23 (patch)
tree1b322d6768213a38fc234b37f5d949dbacca53bb /nova
parentf743e5374d58ab2c45702932da7b702ebb060817 (diff)
parent3c0fcc47be08ac4f3d508fd46f3b95036899aaad (diff)
Fixes a bug that was causing tests to fail on OS X by ensuring that greenthread sleep is called during retry loops.
Diffstat (limited to 'nova')
-rw-r--r--nova/network/linux_net.py13
-rw-r--r--nova/tests/test_volume.py4
-rw-r--r--nova/utils.py9
3 files changed, 13 insertions, 13 deletions
diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py
index 796d6ba31..06b05366a 100644
--- a/nova/network/linux_net.py
+++ b/nova/network/linux_net.py
@@ -1,3 +1,5 @@
+# vim: tabstop=4 shiftwidth=4 softtabstop=4
+
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
@@ -210,10 +212,7 @@ class IptablesManager(object):
"""
def __init__(self, execute=None):
if not execute:
- if FLAGS.fake_network:
- self.execute = lambda *args, **kwargs: ('', '')
- else:
- self.execute = utils.execute
+ self.execute = _execute
else:
self.execute = execute
@@ -352,9 +351,6 @@ class IptablesManager(object):
return new_filter
-iptables_manager = IptablesManager()
-
-
def metadata_forward():
"""Create forwarding rule for metadata"""
iptables_manager.ipv4['nat'].add_rule("PREROUTING",
@@ -767,3 +763,6 @@ def _ip_bridge_cmd(action, params, device):
cmd.extend(params)
cmd.extend(['dev', device])
return cmd
+
+
+iptables_manager = IptablesManager()
diff --git a/nova/tests/test_volume.py b/nova/tests/test_volume.py
index 5d68ca2ae..d71b75f3f 100644
--- a/nova/tests/test_volume.py
+++ b/nova/tests/test_volume.py
@@ -356,8 +356,8 @@ class ISCSITestCase(DriverTestCase):
tid = db.volume_get_iscsi_target_num(self.context, volume_id_list[0])
self.mox.StubOutWithMock(self.volume.driver, '_execute')
self.volume.driver._execute("sudo", "ietadm", "--op", "show",
- "--tid=%(tid)d" % locals()
- ).AndRaise(exception.ProcessExecutionError())
+ "--tid=%(tid)d" % locals()).AndRaise(
+ exception.ProcessExecutionError())
self.mox.ReplayAll()
self.assertRaises(exception.ProcessExecutionError,
diff --git a/nova/utils.py b/nova/utils.py
index e4d8a70eb..2f568f739 100644
--- a/nova/utils.py
+++ b/nova/utils.py
@@ -171,10 +171,6 @@ def execute(*cmd, **kwargs):
stdout=stdout,
stderr=stderr,
cmd=' '.join(cmd))
- # NOTE(termie): this appears to be necessary to let the subprocess
- # call clean something up in between calls, without
- # it two execute calls in a row hangs the second one
- greenthread.sleep(0)
return result
except ProcessExecutionError:
if not attempts:
@@ -183,6 +179,11 @@ def execute(*cmd, **kwargs):
LOG.debug(_("%r failed. Retrying."), cmd)
if delay_on_retry:
greenthread.sleep(random.randint(20, 200) / 100.0)
+ finally:
+ # NOTE(termie): this appears to be necessary to let the subprocess
+ # call clean something up in between calls, without
+ # it two execute calls in a row hangs the second one
+ greenthread.sleep(0)
def ssh_execute(ssh, cmd, process_input=None,