Sophie

Sophie

distrib > Fedora > 16 > i386 > by-pkgid > 5c655bb31b7eacedb96e8b5da992c6ce > files > 14

openstack-nova-2011.3.1-11.fc16.src.rpm

From c24f7be3edcccdb9ebd9261265f00643b07b53df Mon Sep 17 00:00:00 2001
From: Mark McLoughlin <markmc@redhat.com>
Date: Sun, 18 Sep 2011 12:04:46 +0100
Subject: [PATCH] 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
---
 nova/tests/test_volume.py |    1 -
 nova/volume/driver.py     |  130 +++++++++++++++++++++-----------------------
 2 files changed, 62 insertions(+), 69 deletions(-)

diff --git a/nova/tests/test_volume.py b/nova/tests/test_volume.py
index 5aa4853..8a80aeb 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 781b1f2..67ea423 100644
--- a/nova/volume/driver.py
+++ b/nova/volume/driver.py
@@ -60,12 +60,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
@@ -328,7 +326,6 @@ class FakeAOEDriver(AOEDriver):
 
     def __init__(self, *args, **kwargs):
         super(FakeAOEDriver, self).__init__(execute=self.fake_execute,
-                                            sync_exec=self.fake_execute,
                                             *args, **kwargs)
 
     def check_for_setup_error(self):
@@ -369,39 +366,39 @@ class ISCSIDriver(VolumeDriver):
         iscsi_name = "%s%s" % (FLAGS.iscsi_target_prefix, volume['name'])
         volume_path = "/dev/%s/%s" % (FLAGS.volume_group, volume['name'])
         if FLAGS.iscsi_helper == 'tgtadm':
-            self._sync_exec('%s' % FLAGS.iscsi_helper, '--op', 'new',
-                            '--lld=iscsi', '--mode=target',
-                            "--tid=%s" % iscsi_target,
-                            "--targetname=%s" % iscsi_name,
-                            run_as_root=True,
-                            check_exit_code=False)
-            self._sync_exec('%s' % FLAGS.iscsi_helper, '--op', 'bind'
-                            '--lld=iscsi', '--mode=target',
-                            '--initiator-address=ALL',
-                            "--tid=%s" % iscsi_target,
-                            run_as_root=True,
-                            check_exit_code=False)
-            self._sync_exec('%s' % FLAGS.iscsi_helper, '--op', 'new',
-                             '--lld=iscsi', '--mode=logicalunit',
-                             "--tid=%s" % iscsi_target,
-                             '--lun=1',
-                             "--backing-store=%s,Type=fileio" % volume_path,
-                            run_as_root=True,
-                            check_exit_code=False)
+            self._execute('%s' % FLAGS.iscsi_helper, '--op', 'new',
+                          '--lld=iscsi', '--mode=target',
+                          "--tid=%s" % iscsi_target,
+                          "--targetname=%s" % iscsi_name,
+                          run_as_root=True,
+                          check_exit_code=False)
+            self._execute('%s' % FLAGS.iscsi_helper, '--op', 'bind'
+                          '--lld=iscsi', '--mode=target',
+                          '--initiator-address=ALL',
+                          "--tid=%s" % iscsi_target,
+                          run_as_root=True,
+                          check_exit_code=False)
+            self._execute('%s' % FLAGS.iscsi_helper, '--op', 'new',
+                          '--lld=iscsi', '--mode=logicalunit',
+                          "--tid=%s" % iscsi_target,
+                          '--lun=1',
+                          "--backing-store=%s,Type=fileio" % volume_path,
+                          run_as_root=True,
+                          check_exit_code=False)
         else:
-            self._sync_exec('%s' % FLAGS.iscsi_helper, '--op', 'new',
-                            "--tid=%s" % iscsi_target,
-                            '--params',
-                            "Name=%s" % iscsi_name,
-                            run_as_root=True,
-                            check_exit_code=False)
-            self._sync_exec('%s' % FLAGS.iscsi_helper, '--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('%s' % FLAGS.iscsi_helper, '--op', 'new',
+                          "--tid=%s" % iscsi_target,
+                          '--params',
+                          "Name=%s" % iscsi_name,
+                          run_as_root=True,
+                          check_exit_code=False)
+            self._execute('%s' % FLAGS.iscsi_helper, '--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."""
@@ -671,7 +668,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):
@@ -946,14 +942,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
@@ -971,11 +967,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
@@ -1056,12 +1052,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
@@ -1086,13 +1082,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")
@@ -1113,11 +1108,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 {}