]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Update exceptions to pass correct kwargs.
authorDan Prince <dprince@redhat.com>
Tue, 8 Jan 2013 18:23:15 +0000 (13:23 -0500)
committerDan Prince <dprince@redhat.com>
Tue, 8 Jan 2013 18:23:15 +0000 (13:23 -0500)
Updates a variety of Cinder exceptions so that they pass the correct
kwargs for proper exception message formatting. Previously
these exceptions would work but have incorrect error messages
because of how CinderException handled exception formatting errors.

Change-Id: Id1d15b112cad46a698227fa172d81a9ab586e66e

cinder/db/sqlalchemy/api.py
cinder/volume/driver.py
cinder/volume/drivers/nexenta/volume.py
cinder/volume/drivers/rbd.py
cinder/volume/manager.py

index 26658057527b286eb88e5d00aaac969c7e338c8e..121a233553d0312fc3d0c0cbb44b15e977fa3e9e 100644 (file)
@@ -914,7 +914,7 @@ def volume_allocate_iscsi_target(context, volume_id, host):
 @require_admin_context
 def volume_attached(context, volume_id, instance_uuid, mountpoint):
     if not uuidutils.is_uuid_like(instance_uuid):
-        raise exception.InvalidUUID(instance_uuid)
+        raise exception.InvalidUUID(uuid=instance_uuid)
 
     session = get_session()
     with session.begin():
index 6626ddf701346372a9901d68667e09e95cdf24d8..1ae2e95c08faacbf69b3b8fa8059e1b8badbc244 100644 (file)
@@ -547,9 +547,9 @@ class ISCSIDriver(VolumeDriver):
             location = self._do_iscsi_discovery(volume)
 
             if not location:
-                raise exception.InvalidVolume(_("Could not find iSCSI export "
-                                                " for volume %s") %
-                                              (volume['name']))
+                msg = (_("Could not find iSCSI export for volume %s") %
+                        (volume['name']))
+                raise exception.InvalidVolume(reason=msg)
 
             LOG.debug(_("ISCSI Discovery: Found %s") % (location))
             properties['target_discovered'] = True
index cdff190cbfde0458b15b7a9cac02c0d2f4ec89ad..0b737e9146c897f998546f10caa7d6501e7403f7 100644 (file)
@@ -130,7 +130,7 @@ class NexentaDriver(driver.ISCSIDriver):  # pylint: disable=R0921
             self.nms.zvol.destroy(self._get_zvol_name(volume['name']), '')
         except nexenta.NexentaException as exc:
             if "zvol has children" in exc.args[1]:
-                raise exception.VolumeIsBusy
+                raise exception.VolumeIsBusy(volume_name=volume['name'])
             else:
                 raise
 
@@ -166,7 +166,7 @@ class NexentaDriver(driver.ISCSIDriver):  # pylint: disable=R0921
                 '')
         except nexenta.NexentaException as exc:
             if "snapshot has dependent clones" in exc.args[1]:
-                raise exception.SnapshotIsBusy
+                raise exception.SnapshotIsBusy(snapshot_name=snapshot['name'])
             else:
                 raise
 
index cc2fb53ba5c3da55f6347c4e6e4ecfa7d7934669..a4241aa551d336de73a2a20c2912053a3673e641 100644 (file)
@@ -176,15 +176,15 @@ class RBDDriver(driver.VolumeDriver):
     def _parse_location(self, location):
         prefix = 'rbd://'
         if not location.startswith(prefix):
-            reason = _('Image %s is not stored in rbd') % location
-            raise exception.ImageUnacceptable(reason)
+            reason = _('Not stored in rbd')
+            raise exception.ImageUnacceptable(image_id=location, reason=reason)
         pieces = map(urllib.unquote, location[len(prefix):].split('/'))
         if any(map(lambda p: p == '', pieces)):
-            reason = _('Image %s has blank components') % location
-            raise exception.ImageUnacceptable(reason)
+            reason = _('Blank components')
+            raise exception.ImageUnacceptable(image_id=location, reason=reason)
         if len(pieces) != 4:
-            reason = _('Image %s is not an rbd snapshot') % location
-            raise exception.ImageUnacceptable(reason)
+            reason = _('Not an rbd snapshot')
+            raise exception.ImageUnacceptable(image_id=location, reason=reason)
         return pieces
 
     def _get_fsid(self):
index 8950076386b2812b43353c692dfadc69caff4568..7400f62a7fe33c1b5f81568c59120321f144977d 100644 (file)
@@ -362,7 +362,7 @@ class VolumeManager(manager.SchedulerDependentManager):
             # TODO(vish): refactor this into a more general "reserve"
             # TODO(sleepsonthefloor): Is this 'elevated' appropriate?
             if not uuidutils.is_uuid_like(instance_uuid):
-                raise exception.InvalidUUID(instance_uuid)
+                raise exception.InvalidUUID(uuid=instance_uuid)
 
             try:
                 self.driver.attach_volume(context,