Clear the old environment in rc file

When sourcing the Keystone RC file, some of the variable options are
conflicting, and may provide the wrong information to a token request.
For example, If both OS_USERNAME and OS_USER_ID are passed, the
Keystone Client has to chose which one to add to the token request,
and it might not be the one the user expects.  The same is true for
any value that can be passed both by name and ID. In addition, some
of the combinations lead to cryptic error messages.

To clearly identify the users intention, the old environment is
cleared of all variables that start with the `OS_` prefix
before setting any new variables.

Change-Id: I6badc5864426a371323a59100155e1c284af84b8
This commit is contained in:
Adam Young 2016-07-26 16:54:50 -04:00 committed by ayoung
parent 3af59f1455
commit 04f9600c69
1 changed files with 3 additions and 0 deletions

View File

@ -174,6 +174,9 @@ def create_overcloudrc(stack, no_proxy, config_directory='.'):
config_path = os.path.join(config_directory, '%src' % stack.stack_name)
with open(config_path, 'w') as f:
f.write("# Clear any old environment that may conflict.\n")
f.write("for key in $( set | awk '{FS=\"=\"} /^OS_/ {print $1}' );"
"do unset $key ; done\n")
for key, value in rc_params.items():
f.write("export %(key)s=%(value)s\n" %
{'key': key, 'value': value})