From 4454b7c4456ff13c2b0eee6e3c665621bbd4ad26 Mon Sep 17 00:00:00 2001 From: "Walter A. Boring IV" Date: Wed, 8 May 2019 17:52:27 +0000 Subject: [PATCH] move sheepdog exception This patch moves the sheepdog exception to the sheepdog driver Change-Id: Ib1875c5ee99d6159ead7be620e75c5f2a8a5a164 --- cinder/exception.py | 13 --- .../unit/volume/drivers/test_sheepdog.py | 100 +++++++++--------- cinder/volume/drivers/sheepdog.py | 44 +++++--- 3 files changed, 78 insertions(+), 79 deletions(-) diff --git a/cinder/exception.py b/cinder/exception.py index 0232e26c2e3..25852b57fdc 100644 --- a/cinder/exception.py +++ b/cinder/exception.py @@ -1274,19 +1274,6 @@ class DotHillDriverNotSupported(VolumeDriverException): message = _("The Dot Hill driver is no longer supported.") -# Sheepdog -class SheepdogError(VolumeBackendAPIException): - message = _("An error has occurred in SheepdogDriver. " - "(Reason: %(reason)s)") - - -class SheepdogCmdError(SheepdogError): - message = _("(Command: %(cmd)s) " - "(Return Code: %(exit_code)s) " - "(Stdout: %(stdout)s) " - "(Stderr: %(stderr)s)") - - class MetadataAbsent(CinderException): message = _("There is no metadata in DB object.") diff --git a/cinder/tests/unit/volume/drivers/test_sheepdog.py b/cinder/tests/unit/volume/drivers/test_sheepdog.py index 4b5d7ca730a..0e7ea499e46 100644 --- a/cinder/tests/unit/volume/drivers/test_sheepdog.py +++ b/cinder/tests/unit/volume/drivers/test_sheepdog.py @@ -445,7 +445,7 @@ class SheepdogClientTestCase(test.TestCase): {'addr': SHEEP_ADDR, 'port': SHEEP_PORT}) fake_execute.side_effect = processutils.ProcessExecutionError( cmd=cmd, exit_code=exit_code, stdout=stdout, stderr=stderr) - ex = self.assertRaises(exception.SheepdogError, + ex = self.assertRaises(sheepdog.SheepdogError, self.client._run_dog, *args) self.assertEqual(expected_reason, ex.kwargs['reason']) @@ -461,7 +461,7 @@ class SheepdogClientTestCase(test.TestCase): 'addr: %(addr)s, port: %(port)s'), {'addr': SHEEP_ADDR, 'port': SHEEP_PORT}) fake_execute.return_value = (stdout, stderr) - ex = self.assertRaises(exception.SheepdogError, + ex = self.assertRaises(sheepdog.SheepdogError, self.client._run_dog, *args) self.assertEqual(expected_reason, ex.kwargs['reason']) @@ -477,7 +477,7 @@ class SheepdogClientTestCase(test.TestCase): cmd=cmd, exit_code=exit_code, stdout=stdout, stderr=stderr) fake_execute.side_effect = processutils.ProcessExecutionError( cmd=cmd, exit_code=exit_code, stdout=stdout, stderr=stderr) - ex = self.assertRaises(exception.SheepdogCmdError, + ex = self.assertRaises(sheepdog.SheepdogCmdError, self.client._run_dog, *args) self.assertEqual(expected_msg, ex.msg) @@ -529,7 +529,7 @@ class SheepdogClientTestCase(test.TestCase): {'addr': SHEEP_ADDR, 'port': SHEEP_PORT}) fake_execute.side_effect = processutils.ProcessExecutionError( cmd=cmd, exit_code=exit_code, stdout=stdout, stderr=stderr) - ex = self.assertRaises(exception.SheepdogError, + ex = self.assertRaises(sheepdog.SheepdogError, self.client._run_qemu_img, *args) self.assertEqual(expected_reason, ex.kwargs['reason']) @@ -546,7 +546,7 @@ class SheepdogClientTestCase(test.TestCase): cmd=cmd, exit_code=exit_code, stdout=stdout, stderr=stderr) fake_execute.side_effect = processutils.ProcessExecutionError( cmd=cmd, exit_code=exit_code, stdout=stdout, stderr=stderr) - ex = self.assertRaises(exception.SheepdogCmdError, + ex = self.assertRaises(sheepdog.SheepdogCmdError, self.client._run_qemu_img, *args) self.assertEqual(expected_msg, ex.msg) @@ -585,7 +585,7 @@ class SheepdogClientTestCase(test.TestCase): 'You should probably perform ' '"dog cluster format".') fake_execute.return_value = (stdout, stderr) - ex = self.assertRaises(exception.SheepdogError, + ex = self.assertRaises(sheepdog.SheepdogError, self.client.check_cluster_status) self.assertEqual(expected_reason, ex.kwargs['reason']) @@ -598,7 +598,7 @@ class SheepdogClientTestCase(test.TestCase): expected_reason = _('Waiting for all nodes to join cluster. ' 'Ensure all sheep daemons are running.') fake_execute.return_value = (stdout, stderr) - ex = self.assertRaises(exception.SheepdogError, + ex = self.assertRaises(sheepdog.SheepdogError, self.client.check_cluster_status) self.assertEqual(expected_reason, ex.kwargs['reason']) @@ -610,7 +610,7 @@ class SheepdogClientTestCase(test.TestCase): stderr = '' expected_reason = _('Invalid sheepdog cluster status.') fake_execute.return_value = (stdout, stderr) - ex = self.assertRaises(exception.SheepdogError, + ex = self.assertRaises(sheepdog.SheepdogError, self.client.check_cluster_status) self.assertEqual(expected_reason, ex.kwargs['reason']) @@ -626,9 +626,9 @@ class SheepdogClientTestCase(test.TestCase): exit_code=exit_code, stdout=stdout, stderr=stderr) - fake_execute.side_effect = exception.SheepdogCmdError( + fake_execute.side_effect = sheepdog.SheepdogCmdError( cmd=cmd, exit_code=exit_code, stdout=stdout, stderr=stderr) - ex = self.assertRaises(exception.SheepdogCmdError, + ex = self.assertRaises(sheepdog.SheepdogCmdError, self.client.check_cluster_status) self.assertEqual(expected_msg, ex.msg) @@ -649,10 +649,10 @@ class SheepdogClientTestCase(test.TestCase): {'vdiname': self._vdiname}) expected_msg = self.test_data.sheepdog_cmd_error( cmd=cmd, exit_code=exit_code, stdout=stdout, stderr=stderr) - fake_execute.side_effect = exception.SheepdogCmdError( + fake_execute.side_effect = sheepdog.SheepdogCmdError( cmd=cmd, exit_code=exit_code, stdout=stdout.replace('\n', '\\n'), stderr=stderr.replace('\n', '\\n')) - ex = self.assertRaises(exception.SheepdogCmdError, self.client.create, + ex = self.assertRaises(sheepdog.SheepdogCmdError, self.client.create, self._vdiname, self._vdisize) self.assertTrue(fake_logger.error.called) self.assertEqual(expected_msg, ex.msg) @@ -666,10 +666,10 @@ class SheepdogClientTestCase(test.TestCase): stderr = 'stderr_dummy' expected_msg = self.test_data.sheepdog_cmd_error( cmd=cmd, exit_code=exit_code, stdout=stdout, stderr=stderr) - fake_execute.side_effect = exception.SheepdogCmdError( + fake_execute.side_effect = sheepdog.SheepdogCmdError( cmd=cmd, exit_code=exit_code, stdout=stdout.replace('\n', '\\n'), stderr=stderr.replace('\n', '\\n')) - ex = self.assertRaises(exception.SheepdogCmdError, self.client.create, + ex = self.assertRaises(sheepdog.SheepdogCmdError, self.client.create, self._vdiname, self._vdisize) self.assertTrue(fake_logger.error.called) self.assertEqual(expected_msg, ex.msg) @@ -702,10 +702,10 @@ class SheepdogClientTestCase(test.TestCase): exit_code=exit_code, stdout=stdout, stderr=stderr) - fake_execute.side_effect = exception.SheepdogCmdError( + fake_execute.side_effect = sheepdog.SheepdogCmdError( cmd=cmd, exit_code=exit_code, stdout=stdout.replace('\n', '\\n'), stderr=stderr.replace('\n', '\\n')) - ex = self.assertRaises(exception.SheepdogCmdError, + ex = self.assertRaises(sheepdog.SheepdogCmdError, self.client.delete, self._vdiname) self.assertTrue(fake_logger.error.called) self.assertEqual(expected_msg, ex.msg) @@ -731,10 +731,10 @@ class SheepdogClientTestCase(test.TestCase): exit_code=exit_code, stdout=stdout, stderr=stderr) - fake_execute.side_effect = exception.SheepdogCmdError( + fake_execute.side_effect = sheepdog.SheepdogCmdError( cmd=cmd, exit_code=exit_code, stdout=stdout.replace('\n', '\\n'), stderr=stderr.replace('\n', '\\n')) - ex = self.assertRaises(exception.SheepdogCmdError, + ex = self.assertRaises(sheepdog.SheepdogCmdError, self.client.create_snapshot, *args) self.assertTrue(fake_logger.error.called) self.assertEqual(expected_msg, ex.msg) @@ -752,10 +752,10 @@ class SheepdogClientTestCase(test.TestCase): exit_code=exit_code, stdout=stdout, stderr=stderr) - fake_execute.side_effect = exception.SheepdogCmdError( + fake_execute.side_effect = sheepdog.SheepdogCmdError( cmd=cmd, exit_code=exit_code, stdout=stdout.replace('\n', '\\n'), stderr=stderr.replace('\n', '\\n')) - ex = self.assertRaises(exception.SheepdogCmdError, + ex = self.assertRaises(sheepdog.SheepdogCmdError, self.client.create_snapshot, *args) self.assertTrue(fake_logger.error.called) self.assertEqual(expected_msg, ex.msg) @@ -772,10 +772,10 @@ class SheepdogClientTestCase(test.TestCase): exit_code=exit_code, stdout=stdout, stderr=stderr) - fake_execute.side_effect = exception.SheepdogCmdError( + fake_execute.side_effect = sheepdog.SheepdogCmdError( cmd=cmd, exit_code=exit_code, stdout=stdout.replace('\n', '\\n'), stderr=stderr.replace('\n', '\\n')) - ex = self.assertRaises(exception.SheepdogCmdError, + ex = self.assertRaises(sheepdog.SheepdogCmdError, self.client.create_snapshot, *args) self.assertTrue(fake_logger.error.called) self.assertEqual(expected_msg, ex.msg) @@ -822,10 +822,10 @@ class SheepdogClientTestCase(test.TestCase): exit_code=exit_code, stdout=stdout, stderr=stderr) - fake_execute.side_effect = exception.SheepdogCmdError( + fake_execute.side_effect = sheepdog.SheepdogCmdError( cmd=cmd, exit_code=exit_code, stdout=stdout.replace('\n', '\\n'), stderr=stderr.replace('\n', '\\n')) - ex = self.assertRaises(exception.SheepdogCmdError, + ex = self.assertRaises(sheepdog.SheepdogCmdError, self.client.delete_snapshot, *args) self.assertTrue(fake_logger.error.called) self.assertEqual(expected_msg, ex.msg) @@ -856,10 +856,10 @@ class SheepdogClientTestCase(test.TestCase): exit_code=exit_code, stdout=stdout, stderr=stderr) - fake_execute.side_effect = exception.SheepdogCmdError( + fake_execute.side_effect = sheepdog.SheepdogCmdError( cmd=cmd, exit_code=exit_code, stdout=stdout.replace('\n', '\\n'), stderr=stderr.replace('\n', '\\n')) - ex = self.assertRaises(exception.SheepdogCmdError, self.client.clone, + ex = self.assertRaises(sheepdog.SheepdogCmdError, self.client.clone, *args) self.assertTrue(fake_logger.error.called) self.assertEqual(expected_msg, ex.msg) @@ -877,10 +877,10 @@ class SheepdogClientTestCase(test.TestCase): exit_code=exit_code, stdout=stdout, stderr=stderr) - fake_execute.side_effect = exception.SheepdogCmdError( + fake_execute.side_effect = sheepdog.SheepdogCmdError( cmd=cmd, exit_code=exit_code, stdout=stdout.replace('\n', '\\n'), stderr=stderr.replace('\n', '\\n')) - ex = self.assertRaises(exception.SheepdogCmdError, self.client.clone, + ex = self.assertRaises(sheepdog.SheepdogCmdError, self.client.clone, *args) self.assertTrue(fake_logger.error.called) self.assertEqual(expected_msg, ex.msg) @@ -898,10 +898,10 @@ class SheepdogClientTestCase(test.TestCase): exit_code=exit_code, stdout=stdout, stderr=stderr) - fake_execute.side_effect = exception.SheepdogCmdError( + fake_execute.side_effect = sheepdog.SheepdogCmdError( cmd=cmd, exit_code=exit_code, stdout=stdout.replace('\n', '\\n'), stderr=stderr.replace('\n', '\\n')) - ex = self.assertRaises(exception.SheepdogCmdError, self.client.clone, + ex = self.assertRaises(sheepdog.SheepdogCmdError, self.client.clone, *args) self.assertTrue(fake_logger.error.called) self.assertEqual(expected_msg, ex.msg) @@ -919,10 +919,10 @@ class SheepdogClientTestCase(test.TestCase): exit_code=exit_code, stdout=stdout, stderr=stderr) - fake_execute.side_effect = exception.SheepdogCmdError( + fake_execute.side_effect = sheepdog.SheepdogCmdError( cmd=cmd, exit_code=exit_code, stdout=stdout.replace('\n', '\\n'), stderr=stderr.replace('\n', '\\n')) - ex = self.assertRaises(exception.SheepdogCmdError, self.client.clone, + ex = self.assertRaises(sheepdog.SheepdogCmdError, self.client.clone, *args) self.assertTrue(fake_logger.error.called) self.assertEqual(expected_msg, ex.msg) @@ -940,10 +940,10 @@ class SheepdogClientTestCase(test.TestCase): exit_code=exit_code, stdout=stdout, stderr=stderr) - fake_execute.side_effect = exception.SheepdogCmdError( + fake_execute.side_effect = sheepdog.SheepdogCmdError( cmd=cmd, exit_code=exit_code, stdout=stdout.replace('\n', '\\n'), stderr=stderr.replace('\n', '\\n')) - ex = self.assertRaises(exception.SheepdogCmdError, self.client.clone, + ex = self.assertRaises(sheepdog.SheepdogCmdError, self.client.clone, *args) self.assertTrue(fake_logger.error.called) self.assertEqual(expected_msg, ex.msg) @@ -967,10 +967,10 @@ class SheepdogClientTestCase(test.TestCase): exit_code=exit_code, stdout=stdout, stderr=stderr) - fake_execute.side_effect = exception.SheepdogCmdError( + fake_execute.side_effect = sheepdog.SheepdogCmdError( cmd=cmd, exit_code=exit_code, stdout=stdout.replace('\n', '\\n'), stderr=stderr.replace('\n', '\\n')) - ex = self.assertRaises(exception.SheepdogCmdError, + ex = self.assertRaises(sheepdog.SheepdogCmdError, self.client.resize, self._vdiname, 1) self.assertTrue(fake_logger.error.called) self.assertEqual(expected_msg, ex.msg) @@ -986,10 +986,10 @@ class SheepdogClientTestCase(test.TestCase): exit_code=exit_code, stdout=stdout, stderr=stderr) - fake_execute.side_effect = exception.SheepdogCmdError( + fake_execute.side_effect = sheepdog.SheepdogCmdError( cmd=cmd, exit_code=exit_code, stdout=stdout.replace('\n', '\\n'), stderr=stderr.replace('\n', '\\n')) - ex = self.assertRaises(exception.SheepdogCmdError, + ex = self.assertRaises(sheepdog.SheepdogCmdError, self.client.resize, self._vdiname, 1) self.assertTrue(fake_logger.error.called) self.assertEqual(expected_msg, ex.msg) @@ -1005,10 +1005,10 @@ class SheepdogClientTestCase(test.TestCase): exit_code=exit_code, stdout=stdout, stderr=stderr) - fake_execute.side_effect = exception.SheepdogCmdError( + fake_execute.side_effect = sheepdog.SheepdogCmdError( cmd=cmd, exit_code=exit_code, stdout=stdout.replace('\n', '\\n'), stderr=stderr.replace('\n', '\\n')) - ex = self.assertRaises(exception.SheepdogCmdError, + ex = self.assertRaises(sheepdog.SheepdogCmdError, self.client.resize, self._vdiname, 5120) self.assertTrue(fake_logger.error.called) self.assertEqual(expected_msg, ex.msg) @@ -1024,10 +1024,10 @@ class SheepdogClientTestCase(test.TestCase): exit_code=exit_code, stdout=stdout, stderr=stderr) - fake_execute.side_effect = exception.SheepdogCmdError( + fake_execute.side_effect = sheepdog.SheepdogCmdError( cmd=cmd, exit_code=exit_code, stdout=stdout.replace('\n', '\\n'), stderr=stderr.replace('\n', '\\n')) - ex = self.assertRaises(exception.SheepdogCmdError, + ex = self.assertRaises(sheepdog.SheepdogCmdError, self.client.resize, self._vdiname, 10) self.assertTrue(fake_logger.error.called) self.assertEqual(expected_msg, ex.msg) @@ -1050,10 +1050,10 @@ class SheepdogClientTestCase(test.TestCase): exit_code=exit_code, stdout=stdout, stderr=stderr) - fake_execute.side_effect = exception.SheepdogCmdError( + fake_execute.side_effect = sheepdog.SheepdogCmdError( cmd=cmd, exit_code=exit_code, stdout=stdout.replace('\n', '\\n'), stderr=stderr.replace('\n', '\\n')) - ex = self.assertRaises(exception.SheepdogCmdError, + ex = self.assertRaises(sheepdog.SheepdogCmdError, self.client.get_volume_stats) self.assertTrue(fake_logger.error.called) self.assertEqual(expected_msg, ex.msg) @@ -1077,10 +1077,10 @@ class SheepdogClientTestCase(test.TestCase): exit_code=exit_code, stdout=stdout, stderr=stderr) - fake_execute.side_effect = exception.SheepdogCmdError( + fake_execute.side_effect = sheepdog.SheepdogCmdError( cmd=cmd, exit_code=exit_code, stdout=stdout.replace('\n', '\\n'), stderr=stderr.replace('\n', '\\n')) - ex = self.assertRaises(exception.SheepdogCmdError, + ex = self.assertRaises(sheepdog.SheepdogCmdError, self.client.get_vdi_info, self._vdiname) self.assertTrue(fake_logger.error.called) self.assertEqual(expected_msg, ex.msg) @@ -1103,10 +1103,10 @@ class SheepdogClientTestCase(test.TestCase): exit_code=exit_code, stdout=stdout, stderr=stderr) - fake_execute.side_effect = exception.SheepdogCmdError( + fake_execute.side_effect = sheepdog.SheepdogCmdError( cmd=cmd, exit_code=exit_code, stdout=stdout.replace('\n', '\\n'), stderr=stderr.replace('\n', '\\n')) - ex = self.assertRaises(exception.SheepdogCmdError, + ex = self.assertRaises(sheepdog.SheepdogCmdError, self.client.update_node_list) self.assertTrue(fake_logger.error.called) self.assertEqual(expected_msg, ex.msg) @@ -1283,9 +1283,9 @@ class SheepdogDriverTestCase(test.TestCase): cloned_vol = self.test_data.TEST_CLONED_VOLUME snapshot_name = 'tmp-snap-%s-%s' % (src_vol.name, cloned_vol.id) - fake_clone.side_effect = exception.SheepdogCmdError( + fake_clone.side_effect = sheepdog.SheepdogCmdError( cmd='dummy', exit_code=1, stdout='dummy', stderr='dummy') - self.assertRaises(exception.SheepdogCmdError, + self.assertRaises(sheepdog.SheepdogCmdError, self.driver.create_cloned_volume, cloned_vol, src_vol) fake_delete_snapshot.assert_called_once_with(src_vol.name, diff --git a/cinder/volume/drivers/sheepdog.py b/cinder/volume/drivers/sheepdog.py index eb7d31cc101..64214250a89 100644 --- a/cinder/volume/drivers/sheepdog.py +++ b/cinder/volume/drivers/sheepdog.py @@ -56,6 +56,18 @@ CONF.import_opt("image_conversion_dir", "cinder.image.image_utils") CONF.register_opts(sheepdog_opts, group=configuration.SHARED_CONF_GROUP) +class SheepdogError(exception.VolumeBackendAPIException): + message = _("An error has occurred in SheepdogDriver. " + "(Reason: %(reason)s)") + + +class SheepdogCmdError(SheepdogError): + message = _("(Command: %(cmd)s) " + "(Return Code: %(exit_code)s) " + "(Stdout: %(stdout)s) " + "(Stderr: %(stderr)s)") + + class SheepdogClient(object): """Sheepdog command executor.""" @@ -113,7 +125,7 @@ class SheepdogClient(object): reason = (_('Failed to connect to sheep daemon. ' 'addr: %(addr)s, port: %(port)s'), {'addr': addr, 'port': self.port}) - raise exception.SheepdogError(reason=reason) + raise SheepdogError(reason=reason) return (_stdout, _stderr) except OSError as e: with excutils.save_and_reraise_exception(): @@ -128,8 +140,8 @@ class SheepdogClient(object): reason = (_('Failed to connect to sheep daemon. ' 'addr: %(addr)s, port: %(port)s'), {'addr': addr, 'port': self.port}) - raise exception.SheepdogError(reason=reason) - raise exception.SheepdogCmdError( + raise SheepdogError(reason=reason) + raise SheepdogCmdError( cmd=e.cmd, exit_code=e.exit_code, stdout=e.stdout.replace('\n', '\\n'), @@ -165,8 +177,8 @@ class SheepdogClient(object): reason = (_('Failed to connect to sheep daemon. ' 'addr: %(addr)s, port: %(port)s'), {'addr': addr, 'port': self.port}) - raise exception.SheepdogError(reason=reason) - raise exception.SheepdogCmdError( + raise SheepdogError(reason=reason) + raise SheepdogCmdError( cmd=e.cmd, exit_code=e.exit_code, stdout=e.stdout.replace('\n', '\\n'), @@ -175,7 +187,7 @@ class SheepdogClient(object): def check_cluster_status(self): try: (_stdout, _stderr) = self._run_dog('cluster', 'info') - except exception.SheepdogCmdError as e: + except SheepdogCmdError as e: cmd = e.kwargs['cmd'] with excutils.save_and_reraise_exception(): LOG.error('Failed to check cluster status.' @@ -192,12 +204,12 @@ class SheepdogClient(object): elif _stdout.startswith(self.DOG_RESP_CLUSTER_WAITING): reason = _('Waiting for all nodes to join cluster. ' 'Ensure all sheep daemons are running.') - raise exception.SheepdogError(reason=reason) + raise SheepdogError(reason=reason) def create(self, vdiname, size): try: self._run_dog('vdi', 'create', vdiname, '%sG' % size) - except exception.SheepdogCmdError as e: + except SheepdogCmdError as e: _stderr = e.kwargs['stderr'] with excutils.save_and_reraise_exception(): if _stderr.rstrip('\\n').endswith( @@ -211,7 +223,7 @@ class SheepdogClient(object): (_stdout, _stderr) = self._run_dog('vdi', 'delete', vdiname) if _stderr.rstrip().endswith(self.DOG_RESP_VDI_NOT_FOUND): LOG.warning('Volume not found. %s', vdiname) - except exception.SheepdogCmdError as e: + except SheepdogCmdError as e: _stderr = e.kwargs['stderr'] with excutils.save_and_reraise_exception(): LOG.error('Failed to delete volume. %s', vdiname) @@ -219,7 +231,7 @@ class SheepdogClient(object): def create_snapshot(self, vdiname, snapname): try: self._run_dog('vdi', 'snapshot', '-s', snapname, vdiname) - except exception.SheepdogCmdError as e: + except SheepdogCmdError as e: cmd = e.kwargs['cmd'] _stderr = e.kwargs['stderr'] with excutils.save_and_reraise_exception(): @@ -244,7 +256,7 @@ class SheepdogClient(object): LOG.warning('Snapshot "%s" not found.', snapname) elif _stderr.rstrip().endswith(self.DOG_RESP_VDI_NOT_FOUND): LOG.warning('Volume "%s" not found.', vdiname) - except exception.SheepdogCmdError as e: + except SheepdogCmdError as e: cmd = e.kwargs['cmd'] _stderr = e.kwargs['stderr'] with excutils.save_and_reraise_exception(): @@ -258,7 +270,7 @@ class SheepdogClient(object): {'src_vdiname': src_vdiname, 'src_snapname': src_snapname}, 'sheepdog:%s' % dst_vdiname, '%sG' % size) - except exception.SheepdogCmdError as e: + except SheepdogCmdError as e: cmd = e.kwargs['cmd'] _stderr = e.kwargs['stderr'] with excutils.save_and_reraise_exception(): @@ -283,7 +295,7 @@ class SheepdogClient(object): size = int(size) * units.Gi try: (_stdout, _stderr) = self._run_dog('vdi', 'resize', vdiname, size) - except exception.SheepdogCmdError as e: + except SheepdogCmdError as e: _stderr = e.kwargs['stderr'] with excutils.save_and_reraise_exception(): if _stderr.rstrip('\\n').endswith( @@ -308,7 +320,7 @@ class SheepdogClient(object): def get_volume_stats(self): try: (_stdout, _stderr) = self._run_dog('node', 'info', '-r') - except exception.SheepdogCmdError as e: + except SheepdogCmdError as e: with excutils.save_and_reraise_exception(): LOG.error('Failed to get volume status. %s', e) return _stdout @@ -317,7 +329,7 @@ class SheepdogClient(object): # Get info of the specified vdi. try: (_stdout, _stderr) = self._run_dog('vdi', 'list', vdiname, '-r') - except exception.SheepdogCmdError as e: + except SheepdogCmdError as e: with excutils.save_and_reraise_exception(): LOG.error('Failed to get vdi info. %s', e) return _stdout @@ -325,7 +337,7 @@ class SheepdogClient(object): def update_node_list(self): try: (_stdout, _stderr) = self._run_dog('node', 'list', '-r') - except exception.SheepdogCmdError as e: + except SheepdogCmdError as e: with excutils.save_and_reraise_exception(): LOG.error('Failed to get node list. %s', e) node_list = []