diff options
| author | Mark McLoughlin <markmc@redhat.com> | 2011-09-18 12:04:46 +0100 |
|---|---|---|
| committer | Mark McLoughlin <markmc@redhat.com> | 2011-10-13 07:34:40 +0100 |
| commit | 2522a4438b1bc6799845f733894bc1d64b2a755f (patch) | |
| tree | e0b2433b84aa203e8aa336e3b13e0f8015b04317 | |
| parent | 1d0a030e676cb33733ca1bd6b384ca9a682aa5dc (diff) | |
| download | nova-2522a4438b1bc6799845f733894bc1d64b2a755f.tar.gz nova-2522a4438b1bc6799845f733894bc1d64b2a755f.tar.xz nova-2522a4438b1bc6799845f733894bc1d64b2a755f.zip | |
Remove VolumeDriver.sync_exec method (lp:819997)
We always use the same functions for sync_exec and execute.
The execute method is always synchronous, so the distinction doesn't
appear to make sense.
Finally, it looks like it would make sense for execute to ever be
async, so the distinction isn't even serving a useful documentation
purpose.
Change-Id: I86d491cfbf8be73672df7cfdf22e465627a86034
| -rw-r--r-- | nova/tests/test_volume.py | 1 | ||||
| -rw-r--r-- | nova/volume/driver.py | 91 |
2 files changed, 43 insertions, 49 deletions
diff --git a/nova/tests/test_volume.py b/nova/tests/test_volume.py index 88a73f550..d1b11aaf8 100644 --- a/nova/tests/test_volume.py +++ b/nova/tests/test_volume.py @@ -271,7 +271,6 @@ class DriverTestCase(test.TestCase): """Fake _execute.""" return self.output, None self.volume.driver._execute = _fake_execute - self.volume.driver._sync_execute = _fake_execute log = logging.getLogger() self.stream = cStringIO.StringIO() diff --git a/nova/volume/driver.py b/nova/volume/driver.py index 2692f5e9c..f1e30dc94 100644 --- a/nova/volume/driver.py +++ b/nova/volume/driver.py @@ -52,12 +52,10 @@ flags.DEFINE_string('rbd_pool', 'rbd', class VolumeDriver(object): """Executes commands relating to Volumes.""" - def __init__(self, execute=utils.execute, - sync_exec=utils.execute, *args, **kwargs): + def __init__(self, execute=utils.execute, *args, **kwargs): # NOTE(vish): db is set by Manager self.db = None self._execute = execute - self._sync_exec = sync_exec def _try_execute(self, *command, **kwargs): # NOTE(vish): Volume commands can partially fail due to timing, but @@ -238,19 +236,19 @@ class ISCSIDriver(VolumeDriver): iscsi_name = "%s%s" % (FLAGS.iscsi_target_prefix, volume['name']) volume_path = "/dev/%s/%s" % (FLAGS.volume_group, volume['name']) - self._sync_exec('ietadm', '--op', 'new', - "--tid=%s" % iscsi_target, - '--params', - "Name=%s" % iscsi_name, - run_as_root=True, - check_exit_code=False) - self._sync_exec('ietadm', '--op', 'new', - "--tid=%s" % iscsi_target, - '--lun=0', - '--params', - "Path=%s,Type=fileio" % volume_path, - run_as_root=True, - check_exit_code=False) + self._execute('ietadm', '--op', 'new', + "--tid=%s" % iscsi_target, + '--params', + "Name=%s" % iscsi_name, + run_as_root=True, + check_exit_code=False) + self._execute('ietadm', '--op', 'new', + "--tid=%s" % iscsi_target, + '--lun=0', + '--params', + "Path=%s,Type=fileio" % volume_path, + run_as_root=True, + check_exit_code=False) def _ensure_iscsi_targets(self, context, host): """Ensure that target ids have been created in datastore.""" @@ -439,7 +437,6 @@ class FakeISCSIDriver(ISCSIDriver): """Logs calls instead of executing.""" def __init__(self, *args, **kwargs): super(FakeISCSIDriver, self).__init__(execute=self.fake_execute, - sync_exec=self.fake_execute, *args, **kwargs) def check_for_setup_error(self): @@ -718,14 +715,14 @@ class ZadaraBEDriver(ISCSIDriver): break try: - self._sync_exec('/var/lib/zadara/bin/zadara_sncfg', - 'create_qospart', - '--qos', qosstr, - '--pname', volume['name'], - '--psize', sizestr, - '--vsaid', vsa_id, - run_as_root=True, - check_exit_code=0) + self._execute('/var/lib/zadara/bin/zadara_sncfg', + 'create_qospart', + '--qos', qosstr, + '--pname', volume['name'], + '--psize', sizestr, + '--vsaid', vsa_id, + run_as_root=True, + check_exit_code=0) except exception.ProcessExecutionError: LOG.debug(_("VSA BE create_volume for %s failed"), volume['name']) raise @@ -743,11 +740,11 @@ class ZadaraBEDriver(ISCSIDriver): return try: - self._sync_exec('/var/lib/zadara/bin/zadara_sncfg', - 'delete_partition', - '--pname', volume['name'], - run_as_root=True, - check_exit_code=0) + self._execute('/var/lib/zadara/bin/zadara_sncfg', + 'delete_partition', + '--pname', volume['name'], + run_as_root=True, + check_exit_code=0) except exception.ProcessExecutionError: LOG.debug(_("VSA BE delete_volume for %s failed"), volume['name']) return @@ -883,12 +880,12 @@ class ZadaraBEDriver(ISCSIDriver): return try: - self._sync_exec('/var/lib/zadara/bin/zadara_sncfg', - 'remove_export', - '--pname', volume['name'], - '--tid', iscsi_target, - run_as_root=True, - check_exit_code=0) + self._execute('/var/lib/zadara/bin/zadara_sncfg', + 'remove_export', + '--pname', volume['name'], + '--tid', iscsi_target, + run_as_root=True, + check_exit_code=0) except exception.ProcessExecutionError: LOG.debug(_("VSA BE remove_export for %s failed"), volume['name']) return @@ -913,13 +910,12 @@ class ZadaraBEDriver(ISCSIDriver): Common logic that asks zadara_sncfg to setup iSCSI target/lun for this volume """ - (out, err) = self._sync_exec( - '/var/lib/zadara/bin/zadara_sncfg', - 'create_export', - '--pname', volume['name'], - '--tid', iscsi_target, - run_as_root=True, - check_exit_code=0) + (out, err) = self._execute('/var/lib/zadara/bin/zadara_sncfg', + 'create_export', + '--pname', volume['name'], + '--tid', iscsi_target, + run_as_root=True, + check_exit_code=0) result_xml = ElementTree.fromstring(out) response_node = result_xml.find("Sn") @@ -940,11 +936,10 @@ class ZadaraBEDriver(ISCSIDriver): def _get_qosgroup_summary(self): """gets the list of qosgroups from Zadara BE""" try: - (out, err) = self._sync_exec( - '/var/lib/zadara/bin/zadara_sncfg', - 'get_qosgroups_xml', - run_as_root=True, - check_exit_code=0) + (out, err) = self._execute('/var/lib/zadara/bin/zadara_sncfg', + 'get_qosgroups_xml', + run_as_root=True, + check_exit_code=0) except exception.ProcessExecutionError: LOG.debug(_("Failed to retrieve QoS info")) return {} |
