diff options
author | jose.lausuch <jose.lausuch@ericsson.com> | 2016-06-16 14:21:00 +0200 |
---|---|---|
committer | jose.lausuch <jose.lausuch@ericsson.com> | 2016-06-16 14:45:47 +0200 |
commit | 7654dbe5c215ca0649908c66c3c66e49199dbc8c (patch) | |
tree | 86a928e8ad15df25b11ef43ef1e307dadb08e809 /utils/openstack_utils.py | |
parent | 62254125c8cf752cdd2251217051db7b3d2f7069 (diff) |
Remove default values if the os credentials are not set
If the creds are not sourced, then exit.
Change-Id: I55c9cd3a5a0885b81df4ce14502ba816546bcbaa
Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
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 4084e1fc2..646df7aec 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: |