aboutsummaryrefslogtreecommitdiffstats
path: root/api/resources/env_action.py
diff options
context:
space:
mode:
authorrexlee8776 <limingjiang@huawei.com>2017-03-01 06:55:55 +0000
committerrexlee8776 <limingjiang@huawei.com>2017-03-02 02:20:56 +0000
commite6a35a677a6db4005ae2e1726c7cfd04fb132dc8 (patch)
treee8faac0c5f07d73b96fe408a57718de2a2eef391 /api/resources/env_action.py
parent3410e13b059e0b86ce89a791608ce90753009906 (diff)
env prepare check openrc already sourced
env prepare should check if openrc is sourced before using os_fetch_utils to fetch openrc JIRA: YARDSTICK-577 Change-Id: I0efb0bae3b408156b1133812c29583ab8c58d94b Signed-off-by: rexlee8776 <limingjiang@huawei.com>
Diffstat (limited to 'api/resources/env_action.py')
-rw-r--r--api/resources/env_action.py16
1 files changed, 11 insertions, 5 deletions
diff --git a/api/resources/env_action.py b/api/resources/env_action.py
index ea94bc123..9d1686a1d 100644
--- a/api/resources/env_action.py
+++ b/api/resources/env_action.py
@@ -195,6 +195,13 @@ def prepareYardstickEnv(args):
return result_handler('success', {'task_id': task_id})
+def _already_source_openrc():
+ """Check if openrc is sourced already"""
+ return all(os.environ.get(k) for k in ['OS_AUTH_URL', 'OS_USERNAME',
+ 'OS_PASSWORD', 'OS_TENANT_NAME',
+ 'EXTERNAL_NETWORK'])
+
+
def _prepare_env_daemon(task_id):
_create_task(task_id)
@@ -208,11 +215,10 @@ def _prepare_env_daemon(task_id):
rc_file = config.OPENSTACK_RC_FILE
- _get_remote_rc_file(rc_file, installer_ip, installer_type)
-
- _source_file(rc_file)
-
- _append_external_network(rc_file)
+ if not _already_source_openrc():
+ _get_remote_rc_file(rc_file, installer_ip, installer_type)
+ _source_file(rc_file)
+ _append_external_network(rc_file)
# update the external_network
_source_file(rc_file)