diff options
author | Jose Lausuch <jose.lausuch@ericsson.com> | 2017-02-13 13:03:12 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-02-13 13:03:12 +0000 |
commit | 61322cab353e2553e0af2bdb35b482c33683312f (patch) | |
tree | 1190d17c0b5a148ec9e57d9ba8d9344110788973 /functest/utils | |
parent | 8eef71278d06f2fd91b99e6be19069ba077c2d29 (diff) | |
parent | eb0151059dcc1efff797eeeb9f0e77e344426ef6 (diff) |
Merge "Fix source_credentials in openstack_utils"
Diffstat (limited to 'functest/utils')
-rwxr-xr-x | functest/utils/openstack_utils.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/functest/utils/openstack_utils.py b/functest/utils/openstack_utils.py index 64f18504..a0d78ae9 100755 --- a/functest/utils/openstack_utils.py +++ b/functest/utils/openstack_utils.py @@ -10,7 +10,7 @@ import os import os.path -import subprocess +import re import sys import time @@ -112,12 +112,12 @@ def get_credentials(other_creds={}): def source_credentials(rc_file): - pipe = subprocess.Popen(". %s; env" % rc_file, stdout=subprocess.PIPE, - shell=True) - output = pipe.communicate()[0] - env = dict((line.split("=", 1) for line in output.splitlines())) - os.environ.update(env) - return env + with open(rc_file, "r") as f: + for line in f: + var = line.rstrip('"\n').replace('export ', '').split("=") + key = re.sub(r'^ *| *$', '', var[0]) + value = re.sub(r'^[" ]*|[ "]*$', '', "".join(var[1:])) + os.environ[key] = value def get_credentials_for_rally(): |