]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Removes exception instance creation on execute()
authorZhongyue Luo <zhongyue.nah@intel.com>
Mon, 19 Aug 2013 07:39:00 +0000 (15:39 +0800)
committerZhongyue Luo <zhongyue.nah@intel.com>
Tue, 27 Aug 2013 01:37:46 +0000 (09:37 +0800)
For every excption raised in utils.execute(), a new instance is created.
This patch removes this redundant step and directly uses exceptions
defined in Oslo.

Change-Id: I1425d7f1d69a8fde8fde29444fae4d12d045b730

25 files changed:
cinder/backup/drivers/ceph.py
cinder/backup/drivers/tsm.py
cinder/exception.py
cinder/tests/fake_utils.py
cinder/tests/test_backup_ceph.py
cinder/tests/test_backup_tsm.py
cinder/tests/test_glusterfs.py
cinder/tests/test_gpfs.py
cinder/tests/test_nfs.py
cinder/tests/test_sheepdog.py
cinder/tests/test_storwize_svc.py
cinder/tests/test_utils.py
cinder/utils.py
cinder/volume/driver.py
cinder/volume/drivers/gpfs.py
cinder/volume/drivers/lvm.py
cinder/volume/drivers/netapp/nfs.py
cinder/volume/drivers/nfs.py
cinder/volume/drivers/san/hp/hp_3par_common.py
cinder/volume/drivers/san/hp_lefthand.py
cinder/volume/drivers/san/san.py
cinder/volume/drivers/sheepdog.py
cinder/volume/drivers/storwize_svc.py
cinder/volume/flows/create_volume.py
cinder/volume/utils.py

index f63eb35a6149e0d1231b0687e214c40e74cda709..01a5ec21ff58e50596d7881661a48855a384e9d9 100644 (file)
@@ -49,6 +49,7 @@ import time
 from cinder.backup.driver import BackupDriver
 from cinder import exception
 from cinder.openstack.common import log as logging
+from cinder.openstack.common import processutils
 from cinder import units
 from cinder import utils
 import cinder.volume.drivers as drivers
@@ -383,8 +384,8 @@ class CephBackupDriver(BackupDriver):
         cmd.extend([path, '-'])
         try:
             out, err = self._execute(*cmd)
-        except (exception.ProcessExecutionError,
-                exception.UnknownArgumentError) as exc:
+        except (processutils.ProcessExecutionError,
+                processutils.UnknownArgumentError) as exc:
             LOG.info(_("rbd export-diff failed - %s") % (str(exc)))
             raise exception.BackupRBDOperationFailed("rbd export-diff failed")
 
@@ -392,8 +393,8 @@ class CephBackupDriver(BackupDriver):
         cmd.extend(['-', self._utf8("%s/%s" % (dest_pool, dest_name))])
         try:
             out, err = self._execute(*cmd, process_input=out)
-        except (exception.ProcessExecutionError,
-                exception.UnknownArgumentError) as exc:
+        except (processutils.ProcessExecutionError,
+                processutils.UnknownArgumentError) as exc:
             LOG.info(_("rbd import-diff failed - %s") % (str(exc)))
             raise exception.BackupRBDOperationFailed("rbd import-diff failed")
 
index 84f90f494a2c2643c7592d6559f94a1bd14c24ec..534c3a8a46c0ef939d79818556561f8191d5224c 100644 (file)
@@ -27,11 +27,13 @@ Cinder host for using TSM.
 import os
 import stat
 
+from oslo.config import cfg
+
 from cinder.backup.driver import BackupDriver
 from cinder import exception
 from cinder.openstack.common import log as logging
+from cinder.openstack.common import processutils
 from cinder import utils
-from oslo.config import cfg
 
 LOG = logging.getLogger(__name__)
 
@@ -79,7 +81,7 @@ class TSMBackupDriver(BackupDriver):
             utils.execute('ln', volume_path, backup_path,
                           run_as_root=True,
                           check_exit_code=True)
-        except exception.ProcessExecutionError as e:
+        except processutils.ProcessExecutionError as e:
             err = (_('backup: %(vol_id)s Failed to create device hardlink '
                      'from %(vpath)s to %(bpath)s.\n'
                      'stdout: %(out)s\n stderr: %(err)s')
@@ -254,7 +256,7 @@ class TSMBackupDriver(BackupDriver):
                           '-f',
                           hardlink_path,
                           run_as_root=True)
-        except exception.ProcessExecutionError as e:
+        except processutils.ProcessExecutionError as e:
             err = (_('backup: %(vol_id)s Failed to remove backup hardlink'
                      ' from %(vpath)s to %(bpath)s.\n'
                      'stdout: %(out)s\n stderr: %(err)s')
@@ -292,7 +294,7 @@ class TSMBackupDriver(BackupDriver):
                                                     volume_id)
         try:
             self._do_backup(backup_path, volume_id)
-        except exception.ProcessExecutionError as e:
+        except processutils.ProcessExecutionError as e:
             err = (_('backup: %(vol_id)s Failed to run dsmc '
                      'on %(bpath)s.\n'
                      'stdout: %(out)s\n stderr: %(err)s')
@@ -346,7 +348,7 @@ class TSMBackupDriver(BackupDriver):
 
         try:
             self._do_restore(restore_path, volume_id)
-        except exception.ProcessExecutionError as e:
+        except processutils.ProcessExecutionError as e:
             err = (_('restore: %(vol_id)s Failed to run dsmc '
                      'on %(bpath)s.\n'
                      'stdout: %(out)s\n stderr: %(err)s')
@@ -407,7 +409,7 @@ class TSMBackupDriver(BackupDriver):
                                      run_as_root=True,
                                      check_exit_code=False)
 
-        except exception.ProcessExecutionError as e:
+        except processutils.ProcessExecutionError as e:
             err = (_('delete: %(vol_id)s Failed to run dsmc with '
                      'stdout: %(out)s\n stderr: %(err)s')
                    % {'vol_id': volume_id,
index b7888242df1dfe03da7f4a86e5f4b2868d9cd442..cca4aa2c2ead7e80119a2a9e7ca5395985a96cbb 100644 (file)
@@ -53,14 +53,6 @@ class ConvertedException(webob.exc.WSGIHTTPException):
         super(ConvertedException, self).__init__()
 
 
-class ProcessExecutionError(processutils.ProcessExecutionError):
-    pass
-
-
-class UnknownArgumentError(processutils.UnknownArgumentError):
-    pass
-
-
 class Error(Exception):
     pass
 
index f4da47d788ef1a037058d684cebbb0ab79a1d261..fd44d67714a1565801de158db0d09e419479e838 100644 (file)
@@ -22,6 +22,7 @@ from eventlet import greenthread
 
 from cinder import exception
 from cinder.openstack.common import log as logging
+from cinder.openstack.common import processutils
 from cinder import utils
 
 LOG = logging.getLogger(__name__)
@@ -92,7 +93,7 @@ def fake_execute(*cmd_parts, **kwargs):
                                   attempts=attempts,
                                   run_as_root=run_as_root,
                                   check_exit_code=check_exit_code)
-        except exception.ProcessExecutionError as e:
+        except processutils.ProcessExecutionError as e:
             LOG.debug(_('Faked command raised an exception %s'), e)
             raise
 
index 2dd69ace113354ae315284466b3f6badf5326a24..51de25158541cd12ba18e6a2f173ffeb0800f73b 100644 (file)
@@ -26,6 +26,7 @@ from cinder import context
 from cinder import db
 from cinder import exception
 from cinder.openstack.common import log as logging
+from cinder.openstack.common import processutils
 from cinder import test
 from cinder.tests.backup.fake_rados import mock_rados
 from cinder.tests.backup.fake_rados import mock_rbd
@@ -46,7 +47,7 @@ class BackupCephTestCase(test.TestCase):
         return db.backup_create(self.ctxt, backup)['id']
 
     def fake_execute_w_exception(*args, **kwargs):
-        raise exception.ProcessExecutionError()
+        raise processutils.ProcessExecutionError()
 
     def time_inc(self):
         self.counter += 1
index f7a74252e0318f13b7a5e01f35719cf3353ade73..37d528fcf7c987741fee79792049b2e75dc9983c 100644 (file)
@@ -26,6 +26,7 @@ from cinder import context
 from cinder import db
 from cinder import exception
 from cinder.openstack.common import log as logging
+from cinder.openstack.common import processutils as putils
 from cinder import test
 from cinder import utils
 
@@ -143,10 +144,10 @@ class TSMBackupSimulator:
 
         kwargs = self._cmd_to_dict(cmd)
         if kwargs['cmd'] != 'dsmc' or kwargs['type'] not in cmd_switch:
-            raise exception.ProcessExecutionError(exit_code=1,
-                                                  stdout='',
-                                                  stderr='Not dsmc command',
-                                                  cmd=' '.join(cmd))
+            raise putils.ProcessExecutionError(exit_code=1,
+                                               stdout='',
+                                               stderr='Not dsmc command',
+                                               cmd=' '.join(cmd))
         out, err, ret = cmd_switch[kwargs['type']](**kwargs)
         return (out, err, ret)
 
@@ -178,10 +179,10 @@ class TSMBackupSimulator:
                 err = ''
                 ret = 0
         else:
-            raise exception.ProcessExecutionError(exit_code=1,
-                                                  stdout='',
-                                                  stderr='Unsupported command',
-                                                  cmd=' '.join(cmd))
+            raise putils.ProcessExecutionError(exit_code=1,
+                                               stdout='',
+                                               stderr='Unsupported command',
+                                               cmd=' '.join(cmd))
         return (out, err, ret)
 
     def error_injection(self, cmd, error):
@@ -195,7 +196,7 @@ def fake_exec(*cmd, **kwargs):
 
     out, err, ret = SIM.exec_cmd(cmd)
     if ret and check_exit_code:
-        raise exception.ProcessExecutionError(
+        raise putils.ProcessExecutionError(
             exit_code=-1,
             stdout=out,
             stderr=err,
index 2715172ccf237b9567ee5ae8a674a2d58d12ee38..39c9da5af234abc750ee3232331c1a5acbaf1077 100644 (file)
@@ -28,7 +28,7 @@ import json
 
 from cinder import context
 from cinder import exception
-from cinder.exception import ProcessExecutionError
+from cinder.openstack.common import processutils as putils
 from cinder import test
 from cinder import units
 from cinder.volume import configuration as conf
@@ -129,7 +129,7 @@ class GlusterFsDriverTestCase(test.TestCase):
         drv._execute('mkdir', '-p', self.TEST_MNT_POINT)
         drv._execute('mount', '-t', 'glusterfs', self.TEST_EXPORT1,
                      self.TEST_MNT_POINT, run_as_root=True).\
-            AndRaise(ProcessExecutionError(
+            AndRaise(putils.ProcessExecutionError(
                      stderr='is busy or already mounted'))
 
         mox.ReplayAll()
@@ -155,12 +155,12 @@ class GlusterFsDriverTestCase(test.TestCase):
             self.TEST_EXPORT1,
             self.TEST_MNT_POINT,
             run_as_root=True). \
-            AndRaise(ProcessExecutionError(stderr='is busy or '
-                                                  'already mounted'))
+            AndRaise(putils.ProcessExecutionError(stderr='is busy or '
+                                                         'already mounted'))
 
         mox.ReplayAll()
 
-        self.assertRaises(ProcessExecutionError, drv._mount_glusterfs,
+        self.assertRaises(putils.ProcessExecutionError, drv._mount_glusterfs,
                           self.TEST_EXPORT1, self.TEST_MNT_POINT,
                           ensure=False)
 
index f486380c8ea8c893d7f765a72b1763938d6462b3..398092b3c89f8129f63cb716bbbe131745a2da03 100644 (file)
@@ -25,6 +25,7 @@ from cinder import exception
 from cinder.image import image_utils
 from cinder.openstack.common import importutils
 from cinder.openstack.common import log as logging
+from cinder.openstack.common import processutils
 from cinder import test
 from cinder import utils
 from cinder.volume import configuration as conf
@@ -476,7 +477,7 @@ class GPFSDriverTestCase(test.TestCase):
         pass
 
     def _fake_is_not_gpfs_path(self, path):
-        raise(exception.ProcessExecutionError('invalid gpfs path'))
+        raise(processutils.ProcessExecutionError('invalid gpfs path'))
 
     def _fake_convert_image(self, source, dest, out_format):
         utils.execute('cp', source, dest)
index 0609550a574e7e7a3e83f972d338fba838b89540..f971749d6c0ad10e152f17dddc1055f09e261837 100644 (file)
@@ -29,7 +29,7 @@ from mox import stubout
 
 from cinder import context
 from cinder import exception
-from cinder.exception import ProcessExecutionError
+from cinder.openstack.common import processutils as putils
 from cinder import test
 from cinder import units
 
@@ -228,7 +228,7 @@ class NfsDriverTestCase(test.TestCase):
         drv._execute('mkdir', '-p', self.TEST_MNT_POINT)
         drv._execute('mount', '-t', 'nfs', self.TEST_NFS_EXPORT1,
                      self.TEST_MNT_POINT, run_as_root=True).\
-            AndRaise(ProcessExecutionError(
+            AndRaise(putils.ProcessExecutionError(
                      stderr='is busy or already mounted'))
 
         mox.ReplayAll()
@@ -250,12 +250,12 @@ class NfsDriverTestCase(test.TestCase):
             '-t',
             'nfs',
             self.TEST_NFS_EXPORT1, self.TEST_MNT_POINT, run_as_root=True).\
-            AndRaise(ProcessExecutionError(stderr='is busy or '
-                                                  'already mounted'))
+            AndRaise(putils.ProcessExecutionError(stderr='is busy or '
+                                                         'already mounted'))
 
         mox.ReplayAll()
 
-        self.assertRaises(ProcessExecutionError, drv._mount_nfs,
+        self.assertRaises(putils.ProcessExecutionError, drv._mount_nfs,
                           self.TEST_NFS_EXPORT1, self.TEST_MNT_POINT,
                           ensure=False)
 
index b410266570d86312a4feaf4c1daadca90de753e3..51428399d7ea7d3ac5c0305279a2db6f23ab91de 100644 (file)
@@ -22,6 +22,7 @@ import tempfile
 
 from cinder import exception
 from cinder.image import image_utils
+from cinder.openstack.common import processutils
 from cinder import test
 from cinder import units
 from cinder.volume.drivers.sheepdog import SheepdogDriver
@@ -79,7 +80,7 @@ class SheepdogTestCase(test.TestCase):
 
     def test_update_volume_stats_error(self):
         def fake_stats(*args):
-            raise exception.ProcessExecutionError()
+            raise processutils.ProcessExecutionError()
         self.stubs.Set(self.driver, '_execute', fake_stats)
         expected = dict(
             volume_backend_name='sheepdog',
index b2a4949e5cf1bd2eb1b6db06011a4630596816fe..1836db9b741361ee81498378fb3832a01487e27f 100644 (file)
@@ -33,6 +33,7 @@ from cinder import context
 from cinder import exception
 from cinder.openstack.common import excutils
 from cinder.openstack.common import log as logging
+from cinder.openstack.common import processutils
 from cinder import test
 from cinder import units
 from cinder import utils
@@ -1229,10 +1230,10 @@ port_speed!N/A
             out, err = ('', 'ERROR: Unsupported command')
 
         if (check_exit_code) and (len(err) != 0):
-            raise exception.ProcessExecutionError(exit_code=1,
-                                                  stdout=out,
-                                                  stderr=err,
-                                                  cmd=' '.join(cmd))
+            raise processutils.ProcessExecutionError(exit_code=1,
+                                                     stdout=out,
+                                                     stderr=err,
+                                                     cmd=' '.join(cmd))
 
         return (out, err)
 
@@ -1257,7 +1258,7 @@ class StorwizeSVCFakeDriver(storwize_svc.StorwizeSVCDriver):
             LOG.debug(_('CLI output:\n stdout: %(stdout)s\n stderr: '
                         '%(stderr)s') % {'stdout': stdout, 'stderr': stderr})
 
-        except exception.ProcessExecutionError as e:
+        except processutils.ProcessExecutionError as e:
             with excutils.save_and_reraise_exception():
                 LOG.debug(_('CLI Exception output:\n stdout: %(out)s\n '
                             'stderr: %(err)s') % {'out': e.stdout,
@@ -1441,10 +1442,10 @@ class StorwizeSVCDriverTestCase(test.TestCase):
         return attrs
 
     def _fail_prepare_fc_map(self, fc_map_id, source, target):
-        raise exception.ProcessExecutionError(exit_code=1,
-                                              stdout='',
-                                              stderr='unit-test-fail',
-                                              cmd='prestartfcmap id')
+        raise processutils.ProcessExecutionError(exit_code=1,
+                                                 stdout='',
+                                                 stderr='unit-test-fail',
+                                                 cmd='prestartfcmap id')
 
     def test_storwize_svc_snapshots(self):
         vol1 = self._generate_vol_info(None, None)
@@ -1462,18 +1463,18 @@ class StorwizeSVCDriverTestCase(test.TestCase):
         # Test prestartfcmap, startfcmap, and rmfcmap failing
         orig = self.driver._call_prepare_fc_map
         self.driver._call_prepare_fc_map = self._fail_prepare_fc_map
-        self.assertRaises(exception.ProcessExecutionError,
+        self.assertRaises(processutils.ProcessExecutionError,
                           self.driver.create_snapshot, snap1)
         self.driver._call_prepare_fc_map = orig
 
         if self.USESIM:
             self.sim.error_injection('lsfcmap', 'speed_up')
             self.sim.error_injection('startfcmap', 'bad_id')
-            self.assertRaises(exception.ProcessExecutionError,
+            self.assertRaises(processutils.ProcessExecutionError,
                               self.driver.create_snapshot, snap1)
             self._assert_vol_exists(snap1['name'], False)
             self.sim.error_injection('prestartfcmap', 'bad_id')
-            self.assertRaises(exception.ProcessExecutionError,
+            self.assertRaises(processutils.ProcessExecutionError,
                               self.driver.create_snapshot, snap1)
             self._assert_vol_exists(snap1['name'], False)
 
@@ -1512,7 +1513,7 @@ class StorwizeSVCDriverTestCase(test.TestCase):
         # Fail the snapshot
         orig = self.driver._call_prepare_fc_map
         self.driver._call_prepare_fc_map = self._fail_prepare_fc_map
-        self.assertRaises(exception.ProcessExecutionError,
+        self.assertRaises(processutils.ProcessExecutionError,
                           self.driver.create_volume_from_snapshot,
                           vol2, snap1)
         self.driver._call_prepare_fc_map = orig
@@ -1574,7 +1575,7 @@ class StorwizeSVCDriverTestCase(test.TestCase):
         self.assertEqual(attributes['mdisk_grp_name'], pool)
 
         # Try to create the volume again (should fail)
-        self.assertRaises(exception.ProcessExecutionError,
+        self.assertRaises(processutils.ProcessExecutionError,
                           self.driver.create_volume,
                           volume)
 
@@ -1637,7 +1638,7 @@ class StorwizeSVCDriverTestCase(test.TestCase):
                         self.assertNotEqual(attrs[k], v)
                     else:
                         self.assertEqual(attrs[k], v)
-                except exception.ProcessExecutionError as e:
+                except processutils.ProcessExecutionError as e:
                     if 'CMMVC7050E' not in e.stderr:
                         raise
 
@@ -1753,7 +1754,7 @@ class StorwizeSVCDriverTestCase(test.TestCase):
             self.driver.initialize_connection(volume1, self._connector)
 
             # Try to delete the 1st volume (should fail because it is mapped)
-            self.assertRaises(exception.ProcessExecutionError,
+            self.assertRaises(processutils.ProcessExecutionError,
                               self.driver.delete_volume,
                               volume1)
 
@@ -1892,7 +1893,7 @@ class StorwizeSVCDriverTestCase(test.TestCase):
         if self.USESIM and False:
             snap = self._generate_vol_info(master['name'], master['id'])
             self.sim.error_injection('startfcmap', 'bad_id')
-            self.assertRaises(exception.ProcessExecutionError,
+            self.assertRaises(processutils.ProcessExecutionError,
                               self.driver.create_snapshot, snap)
             self._assert_vol_exists(snap['name'], False)
 
@@ -1915,7 +1916,7 @@ class StorwizeSVCDriverTestCase(test.TestCase):
             volfs = self._generate_vol_info(None, None)
             self.sim.error_injection('startfcmap', 'bad_id')
             self.sim.error_injection('lsfcmap', 'speed_up')
-            self.assertRaises(exception.ProcessExecutionError,
+            self.assertRaises(processutils.ProcessExecutionError,
                               self.driver.create_volume_from_snapshot,
                               volfs, snap)
             self._assert_vol_exists(volfs['name'], False)
@@ -1942,7 +1943,7 @@ class StorwizeSVCDriverTestCase(test.TestCase):
             clone = self._generate_vol_info(None, None)
             self.sim.error_injection('startfcmap', 'bad_id')
             self.sim.error_injection('lsfcmap', 'speed_up')
-            self.assertRaises(exception.ProcessExecutionError,
+            self.assertRaises(processutils.ProcessExecutionError,
                               self.driver.create_cloned_volume,
                               clone, volfs)
             self._assert_vol_exists(clone['name'], False)
index 7a6c4b4bec031537fa8c1079ea96e1c49118ad55..db97ec3b8321e983bbbfe196ac80ddb19c5b0bd0 100644 (file)
@@ -69,7 +69,7 @@ exit 1
 ''')
             fp.close()
             os.chmod(tmpfilename, 0o755)
-            self.assertRaises(exception.ProcessExecutionError,
+            self.assertRaises(putils.ProcessExecutionError,
                               utils.execute,
                               tmpfilename, tmpfilename2, attempts=10,
                               process_input='foo',
@@ -88,14 +88,14 @@ exit 1
             os.unlink(tmpfilename2)
 
     def test_unknown_kwargs_raises_error(self):
-        self.assertRaises(exception.UnknownArgumentError,
+        self.assertRaises(putils.UnknownArgumentError,
                           utils.execute,
                           '/usr/bin/env', 'true',
                           this_is_not_a_valid_kwarg=True)
 
     def test_check_exit_code_boolean(self):
         utils.execute('/usr/bin/env', 'false', check_exit_code=False)
-        self.assertRaises(exception.ProcessExecutionError,
+        self.assertRaises(putils.ProcessExecutionError,
                           utils.execute,
                           '/usr/bin/env', 'false', check_exit_code=True)
 
@@ -359,7 +359,7 @@ class GenericUtilsTestCase(test.TestCase):
     def test_read_file_as_root(self):
         def fake_execute(*args, **kwargs):
             if args[1] == 'bad':
-                raise exception.ProcessExecutionError
+                raise putils.ProcessExecutionError
             return 'fakecontents', None
 
         self.stubs.Set(utils, 'execute', fake_execute)
index 84741bf9acafef83798d2dd77d67e022b0ef207e..3a3ba2fe02bb172545ffd25fcbbbdf2a6a8a6d01 100644 (file)
@@ -140,18 +140,7 @@ def execute(*cmd, **kwargs):
     """Convenience wrapper around oslo's execute() method."""
     if 'run_as_root' in kwargs and not 'root_helper' in kwargs:
         kwargs['root_helper'] = get_root_helper()
-    try:
-        (stdout, stderr) = processutils.execute(*cmd, **kwargs)
-    except processutils.ProcessExecutionError as ex:
-        raise exception.ProcessExecutionError(
-            exit_code=ex.exit_code,
-            stderr=ex.stderr,
-            stdout=ex.stdout,
-            cmd=ex.cmd,
-            description=ex.description)
-    except processutils.UnknownArgumentError as ex:
-        raise exception.UnknownArgumentError(ex.message)
-    return (stdout, stderr)
+    return processutils.execute(*cmd, **kwargs)
 
 
 def check_ssh_injection(cmd_list):
@@ -836,7 +825,7 @@ def read_file_as_root(file_path):
     try:
         out, _err = execute('cat', file_path, run_as_root=True)
         return out
-    except exception.ProcessExecutionError:
+    except processutils.ProcessExecutionError:
         raise exception.FileNotFound(file_path=file_path)
 
 
index af21dbbf93d3db604574355ce092df57305161bc..941e342a48c7ae04b6b2bd23b855621a8877cd40 100644 (file)
@@ -31,6 +31,7 @@ from cinder.image import image_utils
 from cinder.openstack.common import excutils
 from cinder.openstack.common import fileutils
 from cinder.openstack.common import log as logging
+from cinder.openstack.common import processutils
 from cinder import utils
 from cinder.volume import rpcapi as volume_rpcapi
 from cinder.volume import utils as volume_utils
@@ -134,7 +135,7 @@ class VolumeDriver(object):
             try:
                 self._execute(*command, **kwargs)
                 return True
-            except exception.ProcessExecutionError as ex:
+            except processutils.ProcessExecutionError as ex:
                 tries = tries + 1
 
                 if tries >= self.configuration.num_shell_tries or\
@@ -814,7 +815,7 @@ class ISERDriver(ISCSIDriver):
         out, info = None, None
         try:
             out, info = self._execute(*cmd, run_as_root=True)
-        except exception.ProcessExecutionError as e:
+        except processutils.ProcessExecutionError as e:
             LOG.error(_("Failed to access the device on the path "
                         "%(path)s: %(error)s.") %
                       {"path": path, "error": e.stderr})
@@ -834,7 +835,7 @@ class ISERDriver(ISCSIDriver):
         # code "inspired by" nova/virt/libvirt/volume.py
         try:
             self._run_iscsiadm(iser_properties, ())
-        except exception.ProcessExecutionError as exc:
+        except processutils.ProcessExecutionError as exc:
             # iscsiadm returns 21 for "No records found" after version 2.0-871
             if exc.exit_code in [21, 255]:
                 self._run_iscsiadm(iser_properties, ('--op', 'new'))
@@ -873,7 +874,7 @@ class ISERDriver(ISCSIDriver):
             try:
                 self._run_iscsiadm(iser_properties, ("--login",),
                                    check_exit_code=[0, 255])
-            except exception.ProcessExecutionError as err:
+            except processutils.ProcessExecutionError as err:
                 if err.exit_code in [15]:
                     self._iscsiadm_update(iser_properties,
                                           "node.startup",
index b83973d20123e56f8fc09e0b841adacbab50e553..9b156f0e53d08416aef35719f9eea4b03f296a70 100644 (file)
@@ -29,6 +29,7 @@ from cinder import exception
 from cinder.image import image_utils
 from cinder.openstack.common import fileutils
 from cinder.openstack.common import log as logging
+from cinder.openstack.common import processutils
 from cinder import units
 from cinder.volume import driver
 
@@ -189,7 +190,7 @@ class GPFSDriver(driver.VolumeDriver):
             try:
                 # check that configured directories are on GPFS
                 self._is_gpfs_path(directory)
-            except exception.ProcessExecutionError:
+            except processutils.ProcessExecutionError:
                 msg = (_('%s is not on GPFS. Perhaps GPFS not mounted.') %
                        directory)
                 LOG.error(msg)
@@ -460,7 +461,7 @@ class GPFSDriver(driver.VolumeDriver):
         image_path = os.path.join(self.configuration.gpfs_images_dir, image_id)
         try:
             self._is_gpfs_path(image_path)
-        except exception.ProcessExecutionError:
+        except processutils.ProcessExecutionError:
             reason = 'image file not in GPFS'
             return False, reason, None
 
@@ -561,7 +562,7 @@ class GPFSDriver(driver.VolumeDriver):
         cmd.append(path)
         try:
             self._execute(*cmd, run_as_root=True)
-        except exception.ProcessExecutionError as exc:
+        except processutils.ProcessExecutionError as exc:
             exception_message = (_("mkfs failed on volume %(vol)s, "
                                    "error message was: %(err)s")
                                  % {'vol': volume['name'], 'err': exc.stderr})
index 6e6ace6256c7db38917985849a536381eff34f61..2c0bdc23b3e4951f9823a99a370ef1c78f60c1f0 100644 (file)
@@ -33,6 +33,7 @@ from cinder import exception
 from cinder.image import image_utils
 from cinder.openstack.common import fileutils
 from cinder.openstack.common import log as logging
+from cinder.openstack.common import processutils
 from cinder import utils
 from cinder.volume import driver
 from cinder.volume import utils as volutils
@@ -109,7 +110,7 @@ class LVMVolumeDriver(driver.VolumeDriver):
             if self.vg.get_volume(pool_name) is None:
                 try:
                     self.vg.create_thin_pool(pool_name)
-                except exception.ProcessExecutionError as exc:
+                except processutils.ProcessExecutionError as exc:
                     exception_message = ("Failed to create thin pool, "
                                          "error message was: %s"
                                          % exc.stderr)
@@ -481,7 +482,7 @@ class LVMISCSIDriver(LVMVolumeDriver, driver.ISCSIDriver):
 
         try:
             (out, err) = self._execute('readlink', old_name)
-        except exception.ProcessExecutionError:
+        except processutils.ProcessExecutionError:
             link_path = '/dev/%s/%s' % (self.configuration.volume_group,
                                         old_name)
             LOG.debug(_('Symbolic link %s not found') % link_path)
index 05ce1796dfe3735f60683eda2d9ec73f1057bf30..35c64f2351959bd5aa0b44435ce66177f1ed01c7 100644 (file)
@@ -24,6 +24,7 @@ import time
 
 from cinder import exception
 from cinder.openstack.common import log as logging
+from cinder.openstack.common import processutils
 from cinder.volume.drivers.netapp.api import NaApiError
 from cinder.volume.drivers.netapp.api import NaElement
 from cinder.volume.drivers.netapp.api import NaServer
@@ -136,7 +137,7 @@ class NetAppNFSDriver(nfs.NfsDriver):
         try:
             self._try_execute('ls', self._get_volume_path(nfs_mount,
                                                           volume_name))
-        except exception.ProcessExecutionError:
+        except processutils.ProcessExecutionError:
             # If the volume isn't present
             return True
         return False
@@ -150,7 +151,7 @@ class NetAppNFSDriver(nfs.NfsDriver):
             try:
                 self._execute(*command, **kwargs)
                 return True
-            except exception.ProcessExecutionError:
+            except processutils.ProcessExecutionError:
                 tries = tries + 1
                 if tries >= self.configuration.num_shell_tries:
                     raise
index 14f598ac0ba96b91d85f3477f3f373caf0246abc..1fd65a8a62c76e805e9495f06b6926df9428cba7 100644 (file)
@@ -24,6 +24,7 @@ from oslo.config import cfg
 from cinder import exception
 from cinder.image import image_utils
 from cinder.openstack.common import log as logging
+from cinder.openstack.common import processutils
 from cinder import units
 from cinder.volume import driver
 
@@ -333,7 +334,7 @@ class RemoteFsDriver(driver.VolumeDriver):
         """
         try:
             self._execute(*cmd, run_as_root=True)
-        except exception.ProcessExecutionError as exc:
+        except processutils.ProcessExecutionError as exc:
             if ensure and 'already mounted' in exc.stderr:
                 LOG.warn(_("%s is already mounted"), share)
             else:
index 15350a28c89ed9b891886ce7d0d8fe7b5feb7ddf..3b944fb904b1af2fcc3a45b9a619e08d92497697 100644 (file)
@@ -57,6 +57,7 @@ from cinder import context
 from cinder import exception
 from cinder.openstack.common import excutils
 from cinder.openstack.common import log as logging
+from cinder.openstack.common import processutils
 from cinder import utils
 from cinder.volume import volume_types
 
@@ -314,10 +315,10 @@ exit
         if exit_status != -1:
             LOG.debug(_('Result was %s') % exit_status)
             if check_exit_code and exit_status != 0:
-                raise exception.ProcessExecutionError(exit_code=exit_status,
-                                                      stdout=stdout,
-                                                      stderr=stderr,
-                                                      cmd=cmd)
+                raise processutils.ProcessExecutionError(exit_code=exit_status,
+                                                         stdout=stdout,
+                                                         stderr=stderr,
+                                                         cmd=cmd)
         channel.close()
         return (stdout, stderr)
 
index c02dd7692d7936f514354513cdbcfc253e226db3..8e22662d9e7016488e3b4e82a5b6eee90ccbbef0 100644 (file)
@@ -21,6 +21,7 @@ from lxml import etree
 
 from cinder import exception
 from cinder.openstack.common import log as logging
+from cinder.openstack.common import processutils
 from cinder.volume.drivers.san.san import SanISCSIDriver
 
 
@@ -228,7 +229,7 @@ class HpSanISCSIDriver(SanISCSIDriver):
         cliq_args['prompt'] = 'false'  # Don't confirm
         try:
             volume_info = self._cliq_get_volume_info(volume['name'])
-        except exception.ProcessExecutionError:
+        except processutils.ProcessExecutionError:
             LOG.error("Volume did not exist. It will not be deleted")
             return
         self._cliq_run_xml("deleteVolume", cliq_args)
index 59d3b596e42f50086bccb50e7b8cd7d00500a201..ce3c1fdb4a3645c6a57c7f2678610a705624a4b5 100644 (file)
@@ -134,13 +134,13 @@ class SanDriver(driver.VolumeDriver):
                         last_exception = e
                         greenthread.sleep(random.randint(20, 500) / 100.0)
                 try:
-                    raise exception.ProcessExecutionError(
+                    raise processutils.ProcessExecutionError(
                         exit_code=last_exception.exit_code,
                         stdout=last_exception.stdout,
                         stderr=last_exception.stderr,
                         cmd=last_exception.cmd)
                 except AttributeError:
-                    raise exception.ProcessExecutionError(
+                    raise processutils.ProcessExecutionError(
                         exit_code=-1,
                         stdout="",
                         stderr="Error running SSH command",
index 92033c3244b8092156be8803c61a6d44cf917946..28b07ba45b05cb80aa4eb3f300360c90b254ec6f 100644 (file)
@@ -27,6 +27,7 @@ from oslo.config import cfg
 from cinder import exception
 from cinder.image import image_utils
 from cinder.openstack.common import log as logging
+from cinder.openstack.common import processutils
 from cinder import units
 from cinder.volume import driver
 
@@ -59,7 +60,7 @@ class SheepdogDriver(driver.VolumeDriver):
                 raise exception.VolumeBackendAPIException(
                     data=exception_message)
 
-        except exception.ProcessExecutionError:
+        except processutils.ProcessExecutionError:
             exception_message = _("Sheepdog is not working")
             raise exception.VolumeBackendAPIException(data=exception_message)
 
@@ -173,7 +174,7 @@ class SheepdogDriver(driver.VolumeDriver):
             used = float(m.group(2))
             stats['total_capacity_gb'] = total / (1024 ** 3)
             stats['free_capacity_gb'] = (total - used) / (1024 ** 3)
-        except exception.ProcessExecutionError:
+        except processutils.ProcessExecutionError:
             LOG.exception(_('error refreshing volume stats'))
 
         self._stats = stats
index a6350796e558949706ea99a74cec50aa535b4180..4e92eb2c72cbc7cb20fa8de305ed8dcb95fba638 100644 (file)
@@ -51,6 +51,7 @@ from cinder import context
 from cinder import exception
 from cinder.openstack.common import excutils
 from cinder.openstack.common import log as logging
+from cinder.openstack.common import processutils
 from cinder.openstack.common import strutils
 from cinder import utils
 from cinder.volume.drivers.san import san
@@ -211,7 +212,7 @@ class StorwizeSVCDriver(san.SanDriver):
                             'license_compression_capacity') and value != '0':
                     self._compression_enabled = True
                     break
-        except exception.ProcessExecutionError:
+        except processutils.ProcessExecutionError:
             LOG.exception(_('Failed to get license information.'))
 
         # Get the available I/O groups
@@ -1055,7 +1056,7 @@ class StorwizeSVCDriver(san.SanDriver):
     def _call_prepare_fc_map(self, fc_map_id, source, target):
         try:
             out, err = self._run_ssh(['svctask', 'prestartfcmap', fc_map_id])
-        except exception.ProcessExecutionError as e:
+        except processutils.ProcessExecutionError as e:
             with excutils.save_and_reraise_exception():
                 LOG.error(_('_prepare_fc_map: Failed to prepare FlashCopy '
                             'from %(source)s to %(target)s.\n'
@@ -1113,7 +1114,7 @@ class StorwizeSVCDriver(san.SanDriver):
     def _start_fc_map(self, fc_map_id, source, target):
         try:
             out, err = self._run_ssh(['svctask', 'startfcmap', fc_map_id])
-        except exception.ProcessExecutionError as e:
+        except processutils.ProcessExecutionError as e:
             with excutils.save_and_reraise_exception():
                 LOG.error(_('_start_fc_map: Failed to start FlashCopy '
                             'from %(source)s to %(target)s.\n'
@@ -1527,7 +1528,7 @@ class StorwizeSVCDriver(san.SanDriver):
 
         try:
             out, err = self._run_ssh(ssh_cmd)
-        except exception.ProcessExecutionError as e:
+        except processutils.ProcessExecutionError as e:
             # Didn't get details from the storage, return None
             LOG.error(_('CLI Exception output:\n command: %(cmd)s\n '
                         'stdout: %(out)s\n stderr: %(err)s') %
index 22ebb33254e3ee24af1d59bbce0a2a36cc2b4d7a..7bafa569be619a5df361c767188193e27e8b127d 100644 (file)
@@ -34,6 +34,7 @@ from cinder import utils
 from cinder.openstack.common import excutils
 from cinder.openstack.common import log as logging
 from cinder.openstack.common.notifier import api as notifier
+from cinder.openstack.common import processutils
 from cinder.openstack.common import timeutils
 from cinder.volume.flows import base
 from cinder.volume import utils as volume_utils
@@ -1299,7 +1300,7 @@ class CreateVolumeFromSpecTask(base.CinderTask):
                    'image_location': image_location})
         try:
             copy_image_to_volume(context, volume_ref, image_service, image_id)
-        except exception.ProcessExecutionError as ex:
+        except processutils.ProcessExecutionError as ex:
             LOG.error(_("Failed to copy image %(image_id)s to volume: "
                         "%(volume_id)s, error: %(error)s") %
                       {'volume_id': volume_id,
index 41a2e19ec3effad7945580954b900baa6b2a06cd..97b94f28e6053e8149dd275fdcee54c707a85eb5 100644 (file)
@@ -27,6 +27,7 @@ from cinder.brick.local_dev import lvm as brick_lvm
 from cinder import exception
 from cinder.openstack.common import log as logging
 from cinder.openstack.common.notifier import api as notifier_api
+from cinder.openstack.common import processutils
 from cinder.openstack.common import strutils
 from cinder.openstack.common import timeutils
 from cinder import units
@@ -177,7 +178,7 @@ def copy_volume(srcstr, deststr, size_in_m, sync=False,
     try:
         execute('dd', 'count=0', 'if=%s' % srcstr, 'of=%s' % deststr,
                 *extra_flags, run_as_root=True)
-    except exception.ProcessExecutionError:
+    except processutils.ProcessExecutionError:
         extra_flags = []
 
     # If the volume is being unprovisioned then