]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix error string format for replication API calls
authorAlex O'Rourke <alex.orourke@hpe.com>
Fri, 9 Oct 2015 18:10:38 +0000 (11:10 -0700)
committerAlex O'Rourke <alex.orourke@hpe.com>
Fri, 9 Oct 2015 18:10:38 +0000 (11:10 -0700)
enable_replication, disable_replication, and failover_replication all
raise exceptions if the volume they are being called on are not in
valid states. When that is done, the error message is not properly
formatted and looks as such:
"ERROR: Invalid volume: (u'Invalid status to enable replication. valid
states are: %(valid_states)s, current replication-state is:
%(curr_state)s.', {'curr_state': u'enabled', 'valid_states':
['disabled']}) (HTTP 400)"

The reason for this is the msg string is using a ',' instead of a '%'
to evaluate the string. When fixed, the error is displayed correctly:
"ERROR: Invalid volume: Invalid status to enable replication. valid
states are: ['disabled'], current replication-state is: enabled.
(HTTP 400)"

Change-Id: I47dcb0a7688a7d740672a75292e0bf98df1551b2
Closes-Bug: #1504633

cinder/volume/api.py

index ee43f022f43a88fd1165d0fa5ea6b19f6367c0f3..f3d89c6e903e41ed9e8bdd21c2bb8145ee1153f5 100644 (file)
@@ -1642,7 +1642,7 @@ class API(base.Base):
         if rep_status not in valid_rep_status:
             msg = (_("Invalid status to enable replication. "
                      "valid states are: %(valid_states)s, "
-                     "current replication-state is: %(curr_state)s."),
+                     "current replication-state is: %(curr_state)s.") %
                    {'valid_states': valid_rep_status,
                     'curr_state': rep_status})
 
@@ -1667,7 +1667,7 @@ class API(base.Base):
         if rep_status not in valid_disable_status:
             msg = (_("Invalid status to disable replication. "
                      "valid states are: %(valid_states)s, "
-                     "current replication-state is: %(curr_state)s."),
+                     "current replication-state is: %(curr_state)s.") %
                    {'valid_states': valid_disable_status,
                     'curr_state': rep_status})
 
@@ -1697,7 +1697,7 @@ class API(base.Base):
         if rep_status not in valid_failover_status:
             msg = (_("Invalid status to failover replication. "
                      "valid states are: %(valid_states)s, "
-                     "current replication-state is: %(curr_state)s."),
+                     "current replication-state is: %(curr_state)s.") %
                    {'valid_states': valid_failover_status,
                     'curr_state': rep_status})