]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Don't throw ValueError for invalid volume id
authorEric Harney <eharney@redhat.com>
Fri, 24 May 2013 15:44:13 +0000 (11:44 -0400)
committerEric Harney <eharney@redhat.com>
Fri, 24 May 2013 15:57:45 +0000 (11:57 -0400)
If a user runs something like "cinder-manage volume delete a1234",
a ValueError is thrown because it fails to cast to int.
Catch this and treat the parameter as an id which will result in a
later VolumeNotFound error rather than breaking this way.

Change-Id: I95a9b9d7628cebe4b6d855ea925b0ad3a5f1c4c4

bin/cinder-manage

index 63f638fc435371115bf83b6445756cf1b8ce8c0d..8e0de60b6ebcb1343e6b26c9737b592ba1866e14 100755 (executable)
@@ -108,7 +108,10 @@ def param2id(object_id):
         # FIXME(ja): mapping occurs in nova?
         pass
     else:
-        return int(object_id)
+        try:
+            return int(object_id)
+        except ValueError:
+            return object_id
 
 
 class ShellCommands(object):