summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxudan <xudan16@huawei.com>2017-10-31 23:53:18 -0400
committerxudan <xudan16@huawei.com>2017-11-02 04:08:26 -0400
commitdcd38df7c2d69eca8da01cdf710d16ffcc18a0fd (patch)
treea53b637cb5d06c1d978af74300d19f7351a470e5
parentc73df2bb04147df075199abc79bc69a2c7a1cc22 (diff)
Get SUT's endpoint info
Get the admin endpoints of all service. JIRA: DOVETAIL-546 Change-Id: Ie0ac3bc5b4eb0885046e207b73217994a4f0e358 Signed-off-by: xudan <xudan16@huawei.com>
-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