From 39309b266df19c33272079f462b64dfba126396d Mon Sep 17 00:00:00 2001 From: Alex O'Rourke Date: Fri, 9 Oct 2015 11:10:38 -0700 Subject: [PATCH] Fix error string format for replication API calls 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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cinder/volume/api.py b/cinder/volume/api.py index ee43f022f..f3d89c6e9 100644 --- a/cinder/volume/api.py +++ b/cinder/volume/api.py @@ -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}) -- 2.45.2