summaryrefslogtreecommitdiff
path: root/troveclient/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'troveclient/utils.py')
-rw-r--r--troveclient/utils.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/troveclient/utils.py b/troveclient/utils.py
index 2c6f809..28a2537 100644
--- a/troveclient/utils.py
+++ b/troveclient/utils.py
@@ -21,6 +21,7 @@ import sys
import uuid
from oslo_utils import encodeutils
+from oslo_utils import uuidutils
import prettytable
from troveclient.apiclient import exceptions
@@ -207,6 +208,18 @@ def print_dict(d, property="Property"):
_print(pt, property)
+def get_resource_id(manager, id_or_name):
+ if not uuidutils.is_uuid_like(id_or_name):
+ try:
+ id_or_name = get_resource_id_by_name(manager, id_or_name)
+ except Exception as e:
+ msg = ("Failed to get resource ID for %s, error: %s" %
+ (id_or_name, str(e)))
+ raise exceptions.CommandError(msg)
+
+ return id_or_name
+
+
def get_resource_id_by_name(manager, name):
resource = manager.find(name=name)
return resource.id