summaryrefslogtreecommitdiffstats
path: root/dovetail/utils/openstack_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'dovetail/utils/openstack_utils.py')
-rw-r--r--dovetail/utils/openstack_utils.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/dovetail/utils/openstack_utils.py b/dovetail/utils/openstack_utils.py
new file mode 100644
index 00000000..2ce2df9d
--- /dev/null
+++ b/dovetail/utils/openstack_utils.py
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2018 xudan16@huawei.com and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+
+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 search_endpoints(self, interface='public'):
+ try:
+ res = self.cloud.search_endpoints(filters={'interface': interface})
+ return True, res
+ except exc.OpenStackCloudException as o_exc:
+ return False, o_exc.orig_message
+
+ def search_services(self, service_id=None):
+ try:
+ res = self.cloud.search_services(name_or_id=service_id)
+ return True, res
+ except exc.OpenStackCloudException as o_exc:
+ return False, o_exc.orig_message