summaryrefslogtreecommitdiff
path: root/nova/volume
diff options
context:
space:
mode:
authorHe Jie Xu <soulxu@gmail.com>2014-11-07 14:22:05 +0800
committerHe Jie Xu <soulxu@gmail.com>2014-11-17 17:07:50 +0800
commit173a8638c1526b92771b8de6d9f43402e5e2cb0e (patch)
treeecfec7add4cd79e8844647de092211e4dde1950e /nova/volume
parent89cd6a0c493e26b5a9e017c99d731464292abbaf (diff)
downloadnova-173a8638c1526b92771b8de6d9f43402e5e2cb0e.tar.gz
Better error message when check volume status
When debug the code, the cinder volume status checking code return the error message, but without which volume is wrong and detail. This patch add volume uuid and detail in the message. Change-Id: I043f7b956b7e56ea5eb7e4ff9c9023fd607f2358
Diffstat (limited to 'nova/volume')
-rw-r--r--nova/volume/cinder.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/nova/volume/cinder.py b/nova/volume/cinder.py
index c080c515c0..1c605a7ec4 100644
--- a/nova/volume/cinder.py
+++ b/nova/volume/cinder.py
@@ -278,16 +278,20 @@ class API(object):
def check_attached(self, context, volume):
if volume['status'] != "in-use":
- msg = _("status must be 'in-use'")
+ msg = _("volume '%(vol)s' status must be 'in-use'. Currently in "
+ "'%(status)s' status") % {"vol": volume['id'],
+ "status": volume['status']}
raise exception.InvalidVolume(reason=msg)
def check_attach(self, context, volume, instance=None):
# TODO(vish): abstract status checking?
if volume['status'] != "available":
- msg = _("status must be 'available'")
+ msg = _("volume '%(vol)s' status must be 'available'. Currently "
+ "in '%(status)s'") % {'vol': volume['id'],
+ 'status': volume['status']}
raise exception.InvalidVolume(reason=msg)
if volume['attach_status'] == "attached":
- msg = _("already attached")
+ msg = _("volume %s already attached") % volume['id']
raise exception.InvalidVolume(reason=msg)
if instance and not CONF.cinder.cross_az_attach:
# NOTE(sorrison): If instance is on a host we match against it's AZ
@@ -298,13 +302,19 @@ class API(object):
else:
instance_az = instance['availability_zone']
if instance_az != volume['availability_zone']:
- msg = _("Instance and volume not in same availability_zone")
+ msg = _("Instance %(instance)s and volume %(vol)s are not in "
+ "the same availability_zone. Instance is in "
+ "%(ins_zone)s. Volume is in %(vol_zone)s") % {
+ "instance": instance['id'],
+ "vol": volume['id'],
+ 'ins_zone': instance_az,
+ 'vol_zone': volume['availability_zone']}
raise exception.InvalidVolume(reason=msg)
def check_detach(self, context, volume):
# TODO(vish): abstract status checking?
if volume['status'] == "available":
- msg = _("already detached")
+ msg = _("volume %s already detached") % volume['id']
raise exception.InvalidVolume(reason=msg)
@translate_volume_exception