diff options
Diffstat (limited to 'dovetail/utils/dovetail_utils.py')
-rw-r--r-- | dovetail/utils/dovetail_utils.py | 25 |
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 |