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
commit1bed7a3732e7d6158613609a57fb1f77ec99de1e (patch)
treee34a440a0ed94629dbce5a12e6b528f184e5684c
parent5ef4b3e74d607181090db6d7e06cc2e960b4d062 (diff)
parenta052d7a7e0d54522512c8c3f4fc4bcf7e47a029c (diff)
downloadmorph-1bed7a3732e7d6158613609a57fb1f77ec99de1e.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-xmorphlib/exts/openstack.check15
1 files changed, 11 insertions, 4 deletions
diff --git a/morphlib/exts/openstack.check b/morphlib/exts/openstack.check
index edc37cc1..a6856c31 100755
--- a/morphlib/exts/openstack.check
+++ b/morphlib/exts/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()