summaryrefslogtreecommitdiff
path: root/troveclient/utils.py
diff options
context:
space:
mode:
authorLingxian Kong <anlin.kong@gmail.com>2021-02-20 09:51:57 +1300
committerLingxian Kong <anlin.kong@gmail.com>2021-02-21 00:37:08 +1300
commitc7319d8fe8cb6cfd5c423472283aadffb12ed52c (patch)
tree77e269a79927c26cd084f6cdf7e13296d620f0a8 /troveclient/utils.py
parent4c71809fadc070aa0f1ec3b4082546d4d2cf0d51 (diff)
downloadpython-troveclient-wallaby-em.tar.gz
Support to restore backup from data locationwallaby-em7.0.0
This feature needs to bump python-troveclient major version as it introduced an incompatible change for backup creation CLI. Change-Id: I6fe94ccb552e2c0020150494ccc2ba6361184229
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