diff options
Diffstat (limited to 'gluster/swift/common/middleware/gswauth/bin/gswauth-add-account')
-rwxr-xr-x | gluster/swift/common/middleware/gswauth/bin/gswauth-add-account | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/gluster/swift/common/middleware/gswauth/bin/gswauth-add-account b/gluster/swift/common/middleware/gswauth/bin/gswauth-add-account index 37064ae..d3fd243 100755 --- a/gluster/swift/common/middleware/gswauth/bin/gswauth-add-account +++ b/gluster/swift/common/middleware/gswauth/bin/gswauth-add-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 @@ -56,9 +57,17 @@ if __name__ == '__main__': headers = {'X-Auth-Admin-User': options.admin_user, 'X-Auth-Admin-Key': options.admin_key, 'Content-Length': '0'} - conn = http_connect(parsed.hostname, parsed.port, 'PUT', path, headers, - ssl=(parsed.scheme == 'https')) - resp = conn.getresponse() + try: + conn = http_connect(parsed.hostname, parsed.port, 'PUT', path, headers, + ssl=(parsed.scheme == 'https')) + resp = conn.getresponse() + except socket.gaierror, err: + exit('Account creation failed: %s. ' \ + 'Check that the admin_url is valid' % err) + except socket.error, (errno, msg): + exit('Account creation failed: %s. ' \ + 'Check that the admin_url is valid' % msg) + if resp.status // 100 != 2: if resp.status == 401: exit('Account creation failed: %s %s: Invalid user/key provided' % |