From bf643c49164d291d25f4f86d32efd7aa2000272e Mon Sep 17 00:00:00 2001 From: Thiago da Silva Date: Wed, 4 Dec 2013 18:12:12 -0500 Subject: 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 Reviewed-on: http://review.gluster.org/6431 Reviewed-by: Luis Pabon Tested-by: Luis Pabon Reviewed-on: http://review.gluster.org/6707 Reviewed-by: Chetan Risbud Tested-by: Chetan Risbud --- .../middleware/gswauth/bin/gswauth-delete-account | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'gluster/swift/common/middleware/gswauth/bin/gswauth-delete-account') diff --git a/gluster/swift/common/middleware/gswauth/bin/gswauth-delete-account b/gluster/swift/common/middleware/gswauth/bin/gswauth-delete-account index b1440f4..204bb95 100755 --- a/gluster/swift/common/middleware/gswauth/bin/gswauth-delete-account +++ b/gluster/swift/common/middleware/gswauth/bin/gswauth-delete-account @@ -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 @@ -57,9 +58,17 @@ if __name__ == '__main__': path = '%sv2/%s' % (parsed_path, account) headers = {'X-Auth-Admin-User': options.admin_user, 'X-Auth-Admin-Key': options.admin_key} - conn = http_connect(parsed.hostname, parsed.port, 'DELETE', path, headers, - ssl=(parsed.scheme == 'https')) - resp = conn.getresponse() + try: + conn = http_connect(parsed.hostname, parsed.port, 'DELETE', path, headers, + ssl=(parsed.scheme == 'https')) + resp = conn.getresponse() + except socket.gaierror, err: + exit('Account deletion failed: %s. ' \ + 'Check that the admin_url is valid' % err) + except socket.error, (errno, msg): + exit('Account deletion failed: %s. ' \ + 'Check that the admin_url is valid' % msg) + if resp.status // 100 != 2: if resp.status == 401: exit('Delete account failed: %s %s: Invalid user/key provided' % -- cgit