summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjose.lausuch <jose.lausuch@ericsson.com>2016-06-16 13:16:11 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-06-16 13:16:11 +0000
commit4295dbe8b8013db3876b21c11756d5908062df68 (patch)
tree148451191390d35061f7615964cf5da5a4efbc0a
parent6ecc6f14a3325895233f40e5193cb369c6aab914 (diff)
parent7654dbe5c215ca0649908c66c3c66e49199dbc8c (diff)
Merge "Remove default values if the os credentials are not set"
-rw-r--r--utils/openstack_utils.py17
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: