]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
remove Brick deps on cinder.exception
authorWalter A. Boring IV <walter.boring@hp.com>
Thu, 8 Aug 2013 22:50:22 +0000 (15:50 -0700)
committerGerrit Code Review <review@openstack.org>
Mon, 12 Aug 2013 17:59:08 +0000 (17:59 +0000)
This patch removes more cinder.exception
dependencies from brick.  This involves
moving some exceptions into brick's
exception module.

Change-Id: I577d403f02c2fd0d727d2694776008e1e9791453

cinder/brick/exception.py
cinder/brick/iscsi/iscsi.py
cinder/brick/local_dev/lvm.py
cinder/exception.py

index b103e16d8533b6a71eed9beee940cbad868e70aa..b3de34298ba7a825376c1a1311b3434e75508d60 100644 (file)
@@ -112,3 +112,23 @@ class ISERTargetCreateFailed(BrickException):
 
 class ISERTargetRemoveFailed(BrickException):
     message = _("Failed to remove iser target for volume %(volume_id)s.")
+
+
+class VolumeGroupNotFound(BrickException):
+    message = _('Unable to find Volume Group: %(vg_name)s')
+
+
+class VolumeGroupCreationFailed(BrickException):
+    message = _('Failed to create Volume Group: %(vg_name)s')
+
+
+class ISCSITargetCreateFailed(BrickException):
+    message = _("Failed to create iscsi target for volume %(volume_id)s.")
+
+
+class ISCSITargetRemoveFailed(BrickException):
+    message = _("Failed to remove iscsi target for volume %(volume_id)s.")
+
+
+class ISCSITargetAttachFailed(BrickException):
+    message = _("Failed to attach iSCSI target for volume %(volume_id)s.")
index 118fe04e8bcaf9bcd8991ac3ac1f7629f1c20800..5fb59b449ae2c853ba73c3af32c76f99c8629cd5 100644 (file)
@@ -27,7 +27,7 @@ import stat
 
 from oslo.config import cfg
 
-from cinder import exception
+from cinder.brick import exception
 from cinder.openstack.common import fileutils
 from cinder.openstack.common import log as logging
 from cinder.openstack.common import processutils as putils
@@ -170,7 +170,7 @@ class TgtAdm(TargetAdmin):
                                        '--update',
                                        name,
                                        run_as_root=True)
-        except exception.ProcessExecutionError as e:
+        except putils.ProcessExecutionError as e:
             LOG.error(_("Failed to create iscsi target for volume "
                         "id:%(vol_id)s: %(e)s")
                       % {'vol_id': vol_id, 'e': str(e)})
@@ -212,7 +212,7 @@ class TgtAdm(TargetAdmin):
                           '--delete',
                           iqn,
                           run_as_root=True)
-        except exception.ProcessExecutionError as e:
+        except putils.ProcessExecutionError as e:
             LOG.error(_("Failed to remove iscsi target for volume "
                         "id:%(vol_id)s: %(e)s")
                       % {'vol_id': vol_id, 'e': str(e)})
@@ -291,7 +291,7 @@ class IetAdm(TargetAdmin):
                     f = open(conf_file, 'a+')
                     f.write(volume_conf)
                     f.close()
-            except exception.ProcessExecutionError as e:
+            except putils.ProcessExecutionError as e:
                 vol_id = name.split(':')[1]
                 LOG.error(_("Failed to create iscsi target for volume "
                             "id:%(vol_id)s: %(e)s")
@@ -385,7 +385,7 @@ class LioAdm(TargetAdmin):
 
         try:
             self._execute('rtstool', 'verify')
-        except (OSError, exception.ProcessExecutionError):
+        except (OSError, putils.ProcessExecutionError):
             LOG.error(_('rtstool is not installed correctly'))
             raise
 
@@ -429,7 +429,7 @@ class LioAdm(TargetAdmin):
             if extra_args != []:
                 command_args += extra_args
             self._execute(*command_args, run_as_root=True)
-        except exception.ProcessExecutionError as e:
+        except putils.ProcessExecutionError as e:
                 LOG.error(_("Failed to create iscsi target for volume "
                             "id:%s.") % vol_id)
                 LOG.error("%s" % str(e))
@@ -455,7 +455,7 @@ class LioAdm(TargetAdmin):
                           'delete',
                           iqn,
                           run_as_root=True)
-        except exception.ProcessExecutionError as e:
+        except putils.ProcessExecutionError as e:
             LOG.error(_("Failed to remove iscsi target for volume "
                         "id:%s.") % vol_id)
             LOG.error("%s" % str(e))
@@ -484,7 +484,7 @@ class LioAdm(TargetAdmin):
                           auth_pass,
                           connector['initiator'],
                           run_as_root=True)
-        except exception.ProcessExecutionError as e:
+        except putils.ProcessExecutionError as e:
             LOG.error(_("Failed to add initiator iqn %s to target") %
                       connector['initiator'])
             raise exception.ISCSITargetAttachFailed(volume_id=volume['id'])
index 72870fcd4210cd3ddb69ef43fc100a57971a1c68..1f5a4eae5c2d8331695470b0d7c49e601e58c59a 100644 (file)
@@ -24,6 +24,7 @@ import re
 
 from itertools import izip
 
+from cinder.brick import exception
 from cinder.openstack.common.gettextutils import _
 from cinder.openstack.common import log as logging
 from cinder.openstack.common import processutils as putils
@@ -31,18 +32,6 @@ from cinder.openstack.common import processutils as putils
 LOG = logging.getLogger(__name__)
 
 
-class VolumeGroupNotFound(Exception):
-    def __init__(self, vg_name):
-        message = (_('Unable to find Volume Group: %s') % vg_name)
-        super(VolumeGroupNotFound, self).__init__(message)
-
-
-class VolumeGroupCreationFailed(Exception):
-    def __init__(self, vg_name):
-        message = (_('Failed to create Volume Group: %s') % vg_name)
-        super(VolumeGroupCreationFailed, self).__init__(message)
-
-
 class LVM(object):
     """LVM object to enable various LVM related operations."""
 
@@ -84,11 +73,11 @@ class LVM(object):
                 LOG.error(_('Cmd     :%s') % err.cmd)
                 LOG.error(_('StdOut  :%s') % err.stdout)
                 LOG.error(_('StdErr  :%s') % err.stderr)
-                raise VolumeGroupCreationFailed(vg_name=self.vg_name)
+                raise exception.VolumeGroupCreationFailed(vg_name=self.vg_name)
 
         if self._vg_exists() is False:
             LOG.error(_('Unable to locate Volume Group %s') % vg_name)
-            raise VolumeGroupNotFound(vg_name=vg_name)
+            raise exception.VolumeGroupNotFound(vg_name=vg_name)
 
         if lvm_type == 'thin':
             pool_name = "%s-pool" % self.vg_name
@@ -294,7 +283,7 @@ class LVM(object):
 
         if len(vg_list) != 1:
             LOG.error(_('Unable to find VG: %s') % self.vg_name)
-            raise VolumeGroupNotFound(vg_name=self.vg_name)
+            raise exception.VolumeGroupNotFound(vg_name=self.vg_name)
 
         self.vg_size = vg_list[0]['size']
         self.vg_free_space = vg_list[0]['available']
index f9fb69fc797d2e816cf2bb27939be9d6d9d73e35..d49bc0daac44096ac2ba950b43498ba37da5b33b 100644 (file)
@@ -298,18 +298,6 @@ class ISCSITargetNotFoundForVolume(NotFound):
     message = _("No target id found for volume %(volume_id)s.")
 
 
-class ISCSITargetCreateFailed(CinderException):
-    message = _("Failed to create iscsi target for volume %(volume_id)s.")
-
-
-class ISCSITargetAttachFailed(CinderException):
-    message = _("Failed to attach iSCSI target for volume %(volume_id)s.")
-
-
-class ISCSITargetRemoveFailed(CinderException):
-    message = _("Failed to remove iscsi target for volume %(volume_id)s.")
-
-
 class DiskNotFound(NotFound):
     message = _("No disk at %(location)s")