diff options
Diffstat (limited to 'gluster/swift/common/middleware/gswauth/bin/gswauth-set-account-service')
-rwxr-xr-x | gluster/swift/common/middleware/gswauth/bin/gswauth-set-account-service | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/gluster/swift/common/middleware/gswauth/bin/gswauth-set-account-service b/gluster/swift/common/middleware/gswauth/bin/gswauth-set-account-service index 5be8319..426ce3c 100755 --- a/gluster/swift/common/middleware/gswauth/bin/gswauth-set-account-service +++ b/gluster/swift/common/middleware/gswauth/bin/gswauth-set-account-service @@ -19,8 +19,8 @@ try: except ImportError: import json 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 @@ -67,10 +67,17 @@ Example: %prog -K gswauthkey test storage local http://127.0.0.1:8080/v1/AUTH_01 headers = {'Content-Length': str(len(body)), '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')) - conn.send(body) - resp = conn.getresponse() + try: + conn = http_connect(parsed.hostname, parsed.port, 'POST', path, headers, + ssl=(parsed.scheme == 'https')) + conn.send(body) + resp = conn.getresponse() + except socket.gaierror, err: + exit('Service set failed: %s. ' \ + 'Check that the admin_url is valid' % err) + except socket.error, (errno, msg): + exit('Service set failed: %s. ' \ + 'Check that the admin_url is valid' % msg) if resp.status // 100 != 2: if resp.status == 401: exit('Service set failed: %s %s: Invalid user/key provided' % |