summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2014-12-10 12:34:21 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2014-12-10 12:34:21 +0000
commitdc4deacf9244c5f97693c1b5953c12e811843281 (patch)
tree42dcb97d0bd2f82025af6885cb8fadb55cfe17de
parent6c1cc0f3706d1019158b6a31735f416b974a1226 (diff)
parentde88869eff96b3f9c09f61f4c9f67c0a710e1974 (diff)
downloaddefinitions-dc4deacf9244c5f97693c1b5953c12e811843281.tar.gz
Merge branch 'sam/fix-openstack-credentials-check'
Reviewed-By: Richard Ipsum <richard.ipsum@codethink.co.uk> Reviewed-By: Francisco Redondo Marchena <francisco.marchena@codethink.co.uk>
-rwxr-xr-xopenstack.check15
1 files changed, 11 insertions, 4 deletions
diff --git a/openstack.check b/openstack.check
index edc37cc1..a6856c31 100755
--- a/openstack.check
+++ b/openstack.check
@@ -77,9 +77,16 @@ class OpenStackCheckExtension(morphlib.writeexts.WriteExtension):
'--os-password', password,
'--os-auth-url', auth_url,
'image-list']
- try:
- cliapp.runcmd(cmdline)
- except cliapp.AppException:
- raise cliapp.AppException('Wrong OpenStack credentals.')
+
+ exit, out, err = cliapp.runcmd_unchecked(cmdline)
+
+ if exit != 0:
+ if err.startswith('The request you have made requires ' \
+ 'authentication. (HTTP 401)'):
+ raise cliapp.AppException('Invalid OpenStack credentials.')
+ else:
+ raise cliapp.AppException(
+ 'Failed to connect to OpenStack instance at %s: %s' %
+ (auth_url, err))
OpenStackCheckExtension().run()