aboutsummaryrefslogtreecommitdiffstats
path: root/functest/utils
diff options
context:
space:
mode:
authorCedric Ollivier <ollivier.cedric@gmail.com>2017-02-14 12:25:38 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-02-14 12:25:38 +0000
commit8b0f0b5b5ce3395dddd938fc43f048eb90d8da8e (patch)
treed69c008ef39c4c5b88b3b797cf4c0c3f64dc1bdf /functest/utils
parent145b5f3f9e1cf70c0825459ff641e05ea851fcfe (diff)
parent4c142226db85c89c5459737715223b7be30bd17e (diff)
Merge "Limit the substitution of ' in env vars"
Diffstat (limited to 'functest/utils')
-rwxr-xr-xfunctest/utils/openstack_utils.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/functest/utils/openstack_utils.py b/functest/utils/openstack_utils.py
index c21ed818e..3093cb558 100755
--- a/functest/utils/openstack_utils.py
+++ b/functest/utils/openstack_utils.py
@@ -114,10 +114,12 @@ def get_credentials(other_creds={}):
def source_credentials(rc_file):
with open(rc_file, "r") as f:
for line in f:
- var = line.rstrip('"\n').replace(
- 'export ', '').replace("'", "").split("=")
- key = re.sub(r'^ *| *$', '', var[0])
- value = re.sub(r'^[" ]*|[ "]*$', '', "".join(var[1:]))
+ var = line.rstrip('"\n').replace('export ', '').split("=")
+ # The two next lines should be modified as soon as rc_file
+ # conforms with common rules. Be aware that it could induce
+ # issues if value starts with '
+ key = re.sub(r'^["\' ]*|[ \'"]*$', '', var[0])
+ value = re.sub(r'^["\' ]*|[ \'"]*$', '', "".join(var[1:]))
os.environ[key] = value