diff options
author | Thiago da Silva <thiago@redhat.com> | 2013-12-04 18:12:12 -0500 |
---|---|---|
committer | Luis Pabon <lpabon@redhat.com> | 2014-01-14 12:15:53 -0800 |
commit | 62d07833db5412f482001b275d2d646abbf21c14 (patch) | |
tree | a0d892f82f87c51a7eaf8a1cffc3cf6306b11bdf /gluster/swift/common/middleware/gswauth/bin/gswauth-prep | |
parent | 52e9fed8735a6eea3f56453da33313ec4f625d0b (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>
Diffstat (limited to 'gluster/swift/common/middleware/gswauth/bin/gswauth-prep')
-rwxr-xr-x | gluster/swift/common/middleware/gswauth/bin/gswauth-prep | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/gluster/swift/common/middleware/gswauth/bin/gswauth-prep b/gluster/swift/common/middleware/gswauth/bin/gswauth-prep index d153719..a73aa1d 100755 --- a/gluster/swift/common/middleware/gswauth/bin/gswauth-prep +++ b/gluster/swift/common/middleware/gswauth/bin/gswauth-prep @@ -15,8 +15,9 @@ # limitations under the License. import gettext +import socket + 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 @@ -54,9 +55,17 @@ if __name__ == '__main__': path = '%sv2/.prep' % parsed_path headers = {'X-Auth-Admin-User': options.admin_user, 'X-Auth-Admin-Key': options.admin_key} - conn = http_connect(parsed.hostname, parsed.port, 'POST', path, headers, - ssl=(parsed.scheme == 'https')) - resp = conn.getresponse() + try: + conn = http_connect(parsed.hostname, parsed.port, 'POST', path, headers, + ssl=(parsed.scheme == 'https')) + resp = conn.getresponse() + except socket.gaierror, err: + exit('gswauth preparation failed: %s. ' \ + 'Check that the admin_url is valid' % err) + except socket.error, (errno, msg): + exit('gswauth preparation failed: %s. ' \ + 'Check that the admin_url is valid' % msg) + if resp.status // 100 != 2: if resp.status == 401: exit('gswauth preparation failed: %s %s: Invalid user/key provided' % |