]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix enable/disable_replication raise InvalidVolume
authorWalter A. Boring IV <walter.boring@hp.com>
Thu, 1 Oct 2015 22:47:44 +0000 (15:47 -0700)
committerWalter A. Boring IV <walter.boring@hp.com>
Thu, 1 Oct 2015 23:15:13 +0000 (16:15 -0700)
In both enable_replication and disable_replication,
it tests to see the replication_state is in the correct
state.  When it's not it was raising InvalidVolume()
InvalidVolume requires a reason text message.

This patch adds the missing reason=msg when creating
the InvalidVolume exception

Change-Id: I66a3e4dc4359457e9669c5ddaa4b0529645334f9
Closes-Bug: 1501942

cinder/volume/manager.py

index 969979cc8e4a47f8272de8ee3d715063d3646747..7dc47d9a394234fd7854cdebdf3e9a96da0e0501 100644 (file)
@@ -3088,7 +3088,11 @@ class VolumeManager(manager.SchedulerDependentManager):
         # we are in an expected state ('enabling')
         volume = self.db.volume_get(context, volume['id'])
         if volume['replication_status'] != 'enabling':
-            raise exception.InvalidVolume()
+            msg = (_("Unable to enable replication due to invalid "
+                     "replication status: %(status)s.") %
+                   {'status': volume['replication_status']})
+            LOG.error(msg, resource=volume)
+            raise exception.InvalidVolume(reason=msg)
 
         try:
             rep_driver_data = self.driver.replication_enable(context,
@@ -3124,7 +3128,11 @@ class VolumeManager(manager.SchedulerDependentManager):
 
         volume = self.db.volume_get(context, volume['id'])
         if volume['replication_status'] != 'disabling':
-            raise exception.InvalidVolume()
+            msg = (_("Unable to disable replication due to invalid "
+                     "replication status: %(status)s.") %
+                   {'status': volume['replication_status']})
+            LOG.error(msg, resource=volume)
+            raise exception.InvalidVolume(reason=msg)
 
         try:
             rep_driver_data = self.driver.replication_disable(context,