summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xdovetail/run.py1
-rw-r--r--dovetail/utils/dovetail_utils.py27
2 files changed, 28 insertions, 0 deletions
diff --git a/dovetail/run.py b/dovetail/run.py
index b7c78975..4778fa51 100755
--- a/dovetail/run.py
+++ b/dovetail/run.py
@@ -262,6 +262,7 @@ def main(*args, **kwargs):
copy_userconfig_files(logger)
copy_patch_files(logger)
dt_utils.check_docker_version(logger)
+ dt_utils.get_openstack_endpoint(logger)
validate_input(kwargs, dt_cfg.dovetail_config['validate_input'], logger)
check_hosts_file(logger)
configs = filter_config(kwargs, logger)
diff --git a/dovetail/utils/dovetail_utils.py b/dovetail/utils/dovetail_utils.py
index 75f7356b..99d44484 100644
--- a/dovetail/utils/dovetail_utils.py
+++ b/dovetail/utils/dovetail_utils.py
@@ -297,3 +297,30 @@ def combine_files(file_path, result_file, logger=None):
logger.exception("Failed to write file {}.".format(result_file))
return None
return result_file
+
+
+def get_openstack_endpoint(logger=None):
+ https_enabled = check_https_enabled(logger)
+ insecure_option = ''
+ insecure = os.getenv('OS_INSECURE',)
+ if https_enabled:
+ if insecure:
+ if insecure.lower() == "true":
+ insecure_option = ' --insecure '
+ cmd = ("openstack {} endpoint list --interface admin -f json"
+ .format(insecure_option))
+ ret, msg = exec_cmd(cmd, logger, verbose=False)
+ if ret != 0:
+ logger.error("Failed to get the endpoint info.")
+ return None
+ 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)
+ logger.debug("Record all endpoint info into file {}."
+ .format(result_file))
+ return result_file
+ except Exception:
+ logger.exception("Failed to write endpoint info into file.")
+ return None