env prepare check openrc already sourced 35/29535/2
authorrexlee8776 <limingjiang@huawei.com>
Wed, 1 Mar 2017 06:55:55 +0000 (06:55 +0000)
committerrexlee8776 <limingjiang@huawei.com>
Thu, 2 Mar 2017 02:20:56 +0000 (02:20 +0000)
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>
api/resources/env_action.py

index ea94bc1..9d1686a 100644 (file)
@@ -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)