summaryrefslogtreecommitdiff
path: root/openstackclient/common
diff options
context:
space:
mode:
authorTerry Howe <terrylhowe@gmail.com>2014-03-17 17:32:41 -0600
committerTerry Howe <terrylhowe@gmail.com>2014-03-17 17:32:41 -0600
commit4900c64d091ffe4ec9050cd71845b12db49bd293 (patch)
treefecfb1e1c990d98465803970d2cb00c52e090d43 /openstackclient/common
parent0c0803d363aeae9e8a6eb2cdaf4b5baedee416dc (diff)
downloadpython-openstackclient-4900c64d091ffe4ec9050cd71845b12db49bd293.tar.gz
Produce a useful error message for NoUniqueMatch
Most of the CLIs use a NoUniqueMatch, so produce a useful error message if that happens. Added some tests for find_resource as well. Change-Id: I85ba61d5f6d1be5bd336a1cc4b02501492905f33 Closes-Bug: #1293846
Diffstat (limited to 'openstackclient/common')
-rw-r--r--openstackclient/common/utils.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/openstackclient/common/utils.py b/openstackclient/common/utils.py
index 7cd877ef..d7702a3f 100644
--- a/openstackclient/common/utils.py
+++ b/openstackclient/common/utils.py
@@ -74,6 +74,10 @@ def find_resource(manager, name_or_id):
msg = "No %s with a name or ID of '%s' exists." % \
(manager.resource_class.__name__.lower(), name_or_id)
raise exceptions.CommandError(msg)
+ if type(ex).__name__ == 'NoUniqueMatch':
+ msg = "More than one %s exists with the name '%s'." % \
+ (manager.resource_class.__name__.lower(), name_or_id)
+ raise exceptions.CommandError(msg)
else:
raise