aboutsummaryrefslogtreecommitdiffstats
path: root/testcases/functest_utils.py
diff options
context:
space:
mode:
authorDan Radez <dradez@redhat.com>2015-12-07 14:04:55 -0500
committerDan Radez <dradez@redhat.com>2015-12-07 14:06:03 -0500
commit2e6774462537a69be83e4ebdb8c574359163b071 (patch)
tree0b452e474e1fb7818349f71d4204e00f0ad53938 /testcases/functest_utils.py
parent8ed8590b49bb429b7160c45bf06518fd494e9765 (diff)
condensing python code in utils check_credentials
comment said: TODO: there must be a short way to do this doing if os.environ["something"] == "" throws an error This does the same thing removing the try catches using conditionals and list functions Change-Id: I614e0aa49ab62aeeb738bdd36ef55452d585d8fb Signed-off-by: Dan Radez <dradez@redhat.com>
Diffstat (limited to 'testcases/functest_utils.py')
-rw-r--r--testcases/functest_utils.py21
1 files changed, 2 insertions, 19 deletions
diff --git a/testcases/functest_utils.py b/testcases/functest_utils.py
index 59af2175e..d09ae8312 100644
--- a/testcases/functest_utils.py
+++ b/testcases/functest_utils.py
@@ -23,25 +23,8 @@ def check_credentials():
"""
Check if the OpenStack credentials (openrc) are sourced
"""
- # TODO: there must be a short way to do this
- # doing if os.environ["something"] == "" throws an error
- try:
- os.environ['OS_AUTH_URL']
- except KeyError:
- return False
- try:
- os.environ['OS_USERNAME']
- except KeyError:
- return False
- try:
- os.environ['OS_PASSWORD']
- except KeyError:
- return False
- try:
- os.environ['OS_TENANT_NAME']
- except KeyError:
- return False
- return True
+ env_vars = ['OS_AUTH_URL','OS_USERNAME','OS_PASSWORD','OS_TENANT_NAME']
+ return all(map(lambda v: v in os.environ and os.environ[v], env_vars))
def get_credentials(service):