diff options
Diffstat (limited to 'utils/openstack_utils.py')
-rw-r--r-- | utils/openstack_utils.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/utils/openstack_utils.py b/utils/openstack_utils.py index 4084e1fc..646df7ae 100644 --- a/utils/openstack_utils.py +++ b/utils/openstack_utils.py @@ -41,6 +41,14 @@ def get_credentials(service): requesting the credentials. """ creds = {} + + # Check that the env vars exists: + envvars = ('OS_USERNAME', 'OS_PASSWORD', 'OS_AUTH_URL', 'OS_TENANT_NAME') + for envvar in envvars: + if os.getenv(envvar) is None: + print("'%s' is not exported as an env variable." % envvar) + exit(-1) + # Unfortunately, each of the OpenStack client will request slightly # different entries in their credentials dict. if service.lower() in ("nova", "cinder"): @@ -53,11 +61,10 @@ def get_credentials(service): # The most common way to pass these info to the script is to do it through # environment variables. creds.update({ - "username": os.environ.get('OS_USERNAME', "admin"), - password: os.environ.get("OS_PASSWORD", 'admin'), - "auth_url": os.environ.get("OS_AUTH_URL", - "http://192.168.20.71:5000/v2.0"), - tenant: os.environ.get("OS_TENANT_NAME", "admin"), + "username": os.environ.get("OS_USERNAME"), + password: os.environ.get("OS_PASSWORD"), + "auth_url": os.environ.get("OS_AUTH_URL"), + tenant: os.environ.get("OS_TENANT_NAME") }) cacert = os.environ.get("OS_CACERT") if cacert is not None: |