diff options
| author | termie <github@anarkystic.com> | 2011-03-23 13:39:01 -0700 |
|---|---|---|
| committer | termie <github@anarkystic.com> | 2011-03-23 13:39:01 -0700 |
| commit | 3c0fcc47be08ac4f3d508fd46f3b95036899aaad (patch) | |
| tree | c6bc9be871d48403bad51320dd6a5acd529ccb2d | |
| parent | 6afe9f0576532b90ef2d5891f06b8bd04401db5b (diff) | |
| download | nova-3c0fcc47be08ac4f3d508fd46f3b95036899aaad.tar.gz nova-3c0fcc47be08ac4f3d508fd46f3b95036899aaad.tar.xz nova-3c0fcc47be08ac4f3d508fd46f3b95036899aaad.zip | |
fix utils.execute retries for osx
also some minor misc cleanups
| -rw-r--r-- | nova/network/linux_net.py | 13 | ||||
| -rw-r--r-- | nova/tests/test_volume.py | 4 | ||||
| -rw-r--r-- | nova/utils.py | 9 |
3 files changed, 13 insertions, 13 deletions
diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py index 0a273588f..46158bbc0 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. @@ -212,10 +214,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 @@ -361,9 +360,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", @@ -776,3 +772,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 499af2039..249470636 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -170,10 +170,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: @@ -182,6 +178,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, |
