From: Walter A. Boring IV Date: Thu, 8 Aug 2013 22:50:22 +0000 (-0700) Subject: remove Brick deps on cinder.exception X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=51ec9380383ce6a7d94ccc6963bed26ca9065fce;p=openstack-build%2Fcinder-build.git remove Brick deps on cinder.exception This patch removes more cinder.exception dependencies from brick. This involves moving some exceptions into brick's exception module. Change-Id: I577d403f02c2fd0d727d2694776008e1e9791453 --- diff --git a/cinder/brick/exception.py b/cinder/brick/exception.py index b103e16d8..b3de34298 100644 --- a/cinder/brick/exception.py +++ b/cinder/brick/exception.py @@ -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.") diff --git a/cinder/brick/iscsi/iscsi.py b/cinder/brick/iscsi/iscsi.py index 118fe04e8..5fb59b449 100644 --- a/cinder/brick/iscsi/iscsi.py +++ b/cinder/brick/iscsi/iscsi.py @@ -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']) diff --git a/cinder/brick/local_dev/lvm.py b/cinder/brick/local_dev/lvm.py index 72870fcd4..1f5a4eae5 100644 --- a/cinder/brick/local_dev/lvm.py +++ b/cinder/brick/local_dev/lvm.py @@ -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'] diff --git a/cinder/exception.py b/cinder/exception.py index f9fb69fc7..d49bc0daa 100644 --- a/cinder/exception.py +++ b/cinder/exception.py @@ -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")