summaryrefslogtreecommitdiffstats
path: root/dovetail/utils/openstack_utils.py
diff options
context:
space:
mode:
authorxudan <xudan16@huawei.com>2018-05-29 02:42:11 -0400
committerxudan <xudan16@huawei.com>2018-06-14 00:00:34 -0400
commit46754323aeac6193dd9b451a6525a478fdb0887b (patch)
tree8ddca633d4093347bcf3f6fb64b702262cf6c668 /dovetail/utils/openstack_utils.py
parent71f945d3e3ca38e4a954a6475234e176e150d2f7 (diff)
Replace openstack commands with shade
Use openstack shade to get endpoint infomation rather than executing openstack commands directly. The next step can replace openstack commands by shade for some test cases that need to create openstack resources (images, flavors) if we agree to use shade. JIRA: DOVETAIL-659 Change-Id: I72b302fb2d4a61e9249a7e53f81ea9464944dcd3 Signed-off-by: xudan <xudan16@huawei.com>
Diffstat (limited to 'dovetail/utils/openstack_utils.py')
-rw-r--r--dovetail/utils/openstack_utils.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/dovetail/utils/openstack_utils.py b/dovetail/utils/openstack_utils.py
new file mode 100644
index 00000000..c4dfabf9
--- /dev/null
+++ b/dovetail/utils/openstack_utils.py
@@ -0,0 +1,20 @@
+import json
+import os_client_config
+import shade
+from shade import exc
+
+
+class OS_Utils(object):
+
+ def __init__(self, **kwargs):
+ self.cloud = shade.OperatorCloud(os_client_config.get_config(**kwargs))
+ self.images = []
+ self.flavors = []
+
+ def list_endpoints(self):
+ try:
+ res = self.cloud.search_endpoints()
+ endpoints = json.dumps(res)
+ return True, endpoints
+ except exc.OpenStackCloudException as o_exc:
+ return False, o_exc.orig_message