If you spend a lot of time switching between different cloud, different users, or even different projects for the same user when working with openstack, you’ve come across the problem where one environment variable from an old sourceing pollutes the current environment. I’ve been hit by that enough times that I wrote a small script to clear the environment.
I call it clear_os_env
unset OS_AUTH_TYPE unset OS_AUTH_URL unset OS_CACERT unset OS_COMPUTE_API_VERSION unset OS_DEFAULT_DOMAIN unset OS_DOMAIN_ID unset OS_DOMAIN_NAME unset OS_IDENTITY_API_VERSION unset OS_IDENTITY_PROVIDER unset OS_IDENTITY_PROVIDER_URL unset OS_IMAGE_API_VERSION unset OS_NETWORK_API_VERSION unset OS_OBJECT_API_VERSION unset OS_PASSWORD unset OS_PROJECT_DOMAIN_ID unset OS_PROJECT_DOMAIN_NAME unset OS_PROJECT_ID unset OS_PROJECT_NAME unset OS_REGION_NAME unset OS_SERVICE_ENDPOINT unset OS_SERVICE_PROVIDER_ENDPOINT unset OS_SERVICE_TOKEN unset OS_TENANT_ID unset OS_TENANT_NAME unset OS_TOKEN unset OS_TRUST_ID unset OS_URL unset OS_USERNAME unset OS_USER_DOMAIN_ID unset OS_USER_DOMAIN_NAME unset OS_USER_ID unset OS_USER_ID unset OS_VOLUME_API_VERSION
Source this prior to sourcing any keystone.rc file, and you should have cleared out the old variables, regardless of how vigilant the new source file writer was in clearing old variables. THis includes some old variables that should no longer be used, like OS_SERVICE_TOKEN
Or we could just do something like:
env | grep OS_ | awk -F “=” ‘{print $1}’ | xargs unset
this should also work:
unset `env | awk -F= ‘/OS_/ {print $1}’ | xargs`
I was set this version, too.
key in `set | grep -E ‘^OS_’` ; do unset $key ; done
IN general, if you are piping grep to awk, you should mve the grep into the awk code, as in stevemar’s version