summaryrefslogtreecommitdiffstats
path: root/dovetail/utils/dovetail_utils.py
diff options
context:
space:
mode:
authorxudan <xudan16@huawei.com>2018-09-04 00:18:58 -0400
committerxudan <xudan16@huawei.com>2018-09-05 02:56:03 -0400
commit3f92680059a8371ec6002e1d909cd89cc4bab96d (patch)
tree2a674f175e7e6d131581e712878a247b6adb3eea /dovetail/utils/dovetail_utils.py
parent16ec1f400882a80c2762c2b1667af81089555591 (diff)
Enable the web portal to show all endpoints
The endpoints info for the 2018.08 has been changed. The web portal needs some adaptions for the new data format. It keeps the same as 2018.01 and doesn't need to change dovetail-webportal. JIRA: DOVETAIL-725 Change-Id: I74cde3aa6032c7afac4b6ce1d2146e09a0f99fe5 Signed-off-by: xudan <xudan16@huawei.com>
Diffstat (limited to 'dovetail/utils/dovetail_utils.py')
-rw-r--r--dovetail/utils/dovetail_utils.py25
1 files changed, 19 insertions, 6 deletions
diff --git a/dovetail/utils/dovetail_utils.py b/dovetail/utils/dovetail_utils.py
index aceb36d5..4a8b45ff 100644
--- a/dovetail/utils/dovetail_utils.py
+++ b/dovetail/utils/dovetail_utils.py
@@ -269,19 +269,32 @@ def get_openstack_endpoint(logger=None):
os_utils = OS_Utils(verify=False)
else:
os_utils = OS_Utils()
- res, msg = os_utils.list_endpoints()
- if not res:
- logger.error("Failed to get admin endpoints. Exception message, {}"
- .format(msg))
+ res_endpoints, msg_endpoints = os_utils.search_endpoints()
+ if not res_endpoints:
+ logger.error("Failed to list endpoints. Exception message, {}"
+ .format(msg_endpoints))
return None
+ endpoints_info = []
+ for item in msg_endpoints:
+ endpoint = {'URL': item['url'], 'Enabled': item['enabled']}
+ res_services, msg_services = os_utils.search_services(
+ service_id=item['service_id'])
+ if not res_services:
+ logger.error("Failed to list services. Exception message, {}"
+ .format(msg_services))
+ return None
+ endpoint['Service Type'] = msg_services[0]['service_type']
+ endpoint['Service Name'] = msg_services[0]['name']
+ endpoints_info.append(endpoint)
+
result_file = os.path.join(dt_cfg.dovetail_config['result_dir'],
'endpoint_info.json')
try:
with open(result_file, 'w') as f:
- f.write(msg)
+ json.dump(endpoints_info, f)
logger.debug("Record all endpoint info into file {}."
.format(result_file))
- return msg
+ return endpoints_info
except Exception:
logger.exception("Failed to write endpoint info into file.")
return None