swauth scripts exit with non zero exit codes on failure now

This commit is contained in:
Greg Lange 2011-04-18 16:08:48 +00:00
parent 59ff252362
commit 527a9ac0c7
8 changed files with 12 additions and 14 deletions

View File

@ -65,4 +65,4 @@ if __name__ == '__main__':
ssl=(parsed.scheme == 'https')) ssl=(parsed.scheme == 'https'))
resp = conn.getresponse() resp = conn.getresponse()
if resp.status // 100 != 2: if resp.status // 100 != 2:
print 'Account creation failed: %s %s' % (resp.status, resp.reason) exit('Account creation failed: %s %s' % (resp.status, resp.reason))

View File

@ -90,4 +90,4 @@ if __name__ == '__main__':
ssl=(parsed.scheme == 'https')) ssl=(parsed.scheme == 'https'))
resp = conn.getresponse() resp = conn.getresponse()
if resp.status // 100 != 2: if resp.status // 100 != 2:
print 'User creation failed: %s %s' % (resp.status, resp.reason) exit('User creation failed: %s %s' % (resp.status, resp.reason))

View File

@ -69,13 +69,11 @@ if __name__ == '__main__':
objs = conn.get_container(container, marker=marker)[1] objs = conn.get_container(container, marker=marker)[1]
except ClientException, e: except ClientException, e:
if e.http_status == 404: if e.http_status == 404:
print 'Container %s not found' % (container) exit('Container %s not found. swauth-prep needs to be '
print 'swauth-prep needs to be rerun' 'rerun' % (container))
exit()
else: else:
print 'Object listing on container %s failed with ' \ exit('Object listing on container %s failed with status '
'status code %d' % (container, e.http_status) 'code %d' % (container, e.http_status))
break
if objs: if objs:
marker = objs[-1]['name'] marker = objs[-1]['name']
else: else:

View File

@ -57,4 +57,4 @@ if __name__ == '__main__':
ssl=(parsed.scheme == 'https')) ssl=(parsed.scheme == 'https'))
resp = conn.getresponse() resp = conn.getresponse()
if resp.status // 100 != 2: if resp.status // 100 != 2:
print 'Account deletion failed: %s %s' % (resp.status, resp.reason) exit('Account deletion failed: %s %s' % (resp.status, resp.reason))

View File

@ -57,4 +57,4 @@ if __name__ == '__main__':
ssl=(parsed.scheme == 'https')) ssl=(parsed.scheme == 'https'))
resp = conn.getresponse() resp = conn.getresponse()
if resp.status // 100 != 2: if resp.status // 100 != 2:
print 'User deletion failed: %s %s' % (resp.status, resp.reason) exit('User deletion failed: %s %s' % (resp.status, resp.reason))

View File

@ -75,9 +75,9 @@ If the [user] is '.groups', the active groups for the account will be listed.
conn = http_connect(parsed.hostname, parsed.port, 'GET', path, headers, conn = http_connect(parsed.hostname, parsed.port, 'GET', path, headers,
ssl=(parsed.scheme == 'https')) ssl=(parsed.scheme == 'https'))
resp = conn.getresponse() resp = conn.getresponse()
if resp.status // 100 != 2:
print 'List failed: %s %s' % (resp.status, resp.reason)
body = resp.read() body = resp.read()
if resp.status // 100 != 2:
exit('List failed: %s %s' % (resp.status, resp.reason))
if options.plain_text: if options.plain_text:
info = json.loads(body) info = json.loads(body)
for group in info[['accounts', 'users', 'groups'][len(args)]]: for group in info[['accounts', 'users', 'groups'][len(args)]]:

View File

@ -56,4 +56,4 @@ if __name__ == '__main__':
ssl=(parsed.scheme == 'https')) ssl=(parsed.scheme == 'https'))
resp = conn.getresponse() resp = conn.getresponse()
if resp.status // 100 != 2: if resp.status // 100 != 2:
print 'Auth subsystem prep failed: %s %s' % (resp.status, resp.reason) exit('Auth subsystem prep failed: %s %s' % (resp.status, resp.reason))

View File

@ -70,4 +70,4 @@ Example: %prog -K swauthkey test storage local http://127.0.0.1:8080/v1/AUTH_018
conn.send(body) conn.send(body)
resp = conn.getresponse() resp = conn.getresponse()
if resp.status // 100 != 2: if resp.status // 100 != 2:
print 'Service set failed: %s %s' % (resp.status, resp.reason) exit('Service set failed: %s %s' % (resp.status, resp.reason))