diff options
author | Thiago da Silva <thiago@redhat.com> | 2013-12-04 18:12:12 -0500 |
---|---|---|
committer | Chetan Risbud <crisbud@redhat.com> | 2014-01-14 23:06:44 -0800 |
commit | bf643c49164d291d25f4f86d32efd7aa2000272e (patch) | |
tree | 233e512a4fd34d3948dd82af9da024b945e1950d /gluster/swift/common/middleware/gswauth/bin/gswauth-list | |
parent | 41c7bbcc74b64babefa0455917cbd04c89b9c94d (diff) |
fix error handing in swauth tools
The swauth tools did not handle an invalid admin_url, so it just failed
printing the stacktrace, which is not useful to end users.
This fix catches the exception and prints an error message that can
help user solve the issue.
Change-Id: I806c1cf191b5921e904b155f65cdbde5f2aac695
Signed-off-by: Thiago da Silva <thiago@redhat.com>
Reviewed-on: http://review.gluster.org/6431
Reviewed-by: Luis Pabon <lpabon@redhat.com>
Tested-by: Luis Pabon <lpabon@redhat.com>
Reviewed-on: http://review.gluster.org/6707
Reviewed-by: Chetan Risbud <crisbud@redhat.com>
Tested-by: Chetan Risbud <crisbud@redhat.com>
Diffstat (limited to 'gluster/swift/common/middleware/gswauth/bin/gswauth-list')
-rwxr-xr-x | gluster/swift/common/middleware/gswauth/bin/gswauth-list | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/gluster/swift/common/middleware/gswauth/bin/gswauth-list b/gluster/swift/common/middleware/gswauth/bin/gswauth-list index 4f2d834..50b7936 100755 --- a/gluster/swift/common/middleware/gswauth/bin/gswauth-list +++ b/gluster/swift/common/middleware/gswauth/bin/gswauth-list @@ -19,8 +19,10 @@ try: except ImportError: import json import gettext +import socket +import types + from optparse import OptionParser -from os.path import basename from sys import argv, exit from swift.common.bufferedhttp import http_connect_raw as http_connect @@ -79,9 +81,17 @@ If the [user] is '.groups', the active groups for the account will be listed. path = '%sv2/%s' % (parsed_path, '/'.join(args)) headers = {'X-Auth-Admin-User': options.admin_user, 'X-Auth-Admin-Key': options.admin_key} - conn = http_connect(parsed.hostname, parsed.port, 'GET', path, headers, - ssl=(parsed.scheme == 'https')) - resp = conn.getresponse() + try: + conn = http_connect(parsed.hostname, parsed.port, 'GET', path, headers, + ssl=(parsed.scheme == 'https')) + resp = conn.getresponse() + except socket.gaierror, err: + exit('List failed: %s. ' \ + 'Check that the admin_url is valid' % err) + except socket.error, (errno, msg): + exit('List failed: %s. ' \ + 'Check that the admin_url is valid' % msg) + body = resp.read() if resp.status // 100 != 2: if resp.status == 401: |