X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=functest%2Futils%2Fopenstack_utils.py;h=3093cb558062872b379946ebd4611d6b4358a019;hb=568259b1a056de7e08e568168bf0d881b427a54d;hp=64f18504d9816593f02c95f4b45aa1a86d3cbe45;hpb=fec5f179377a891117c4f3f3665df47063a1e1bd;p=functest.git diff --git a/functest/utils/openstack_utils.py b/functest/utils/openstack_utils.py index 64f18504d..3093cb558 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,15 @@ 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("=") + # 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 def get_credentials_for_rally():