From 527a9ac0c7cbbb8c8b37f1fa2c539bd9a52f7430 Mon Sep 17 00:00:00 2001 From: Greg Lange Date: Mon, 18 Apr 2011 16:08:48 +0000 Subject: [PATCH] swauth scripts exit with non zero exit codes on failure now --- bin/swauth-add-account | 2 +- bin/swauth-add-user | 2 +- bin/swauth-cleanup-tokens | 10 ++++------ bin/swauth-delete-account | 2 +- bin/swauth-delete-user | 2 +- bin/swauth-list | 4 ++-- bin/swauth-prep | 2 +- bin/swauth-set-account-service | 2 +- 8 files changed, 12 insertions(+), 14 deletions(-) diff --git a/bin/swauth-add-account b/bin/swauth-add-account index 2b91b6292d..b8591c3425 100755 --- a/bin/swauth-add-account +++ b/bin/swauth-add-account @@ -65,4 +65,4 @@ if __name__ == '__main__': ssl=(parsed.scheme == 'https')) resp = conn.getresponse() 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)) diff --git a/bin/swauth-add-user b/bin/swauth-add-user index 23144df41b..7b3dc129d3 100755 --- a/bin/swauth-add-user +++ b/bin/swauth-add-user @@ -90,4 +90,4 @@ if __name__ == '__main__': ssl=(parsed.scheme == 'https')) resp = conn.getresponse() 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)) diff --git a/bin/swauth-cleanup-tokens b/bin/swauth-cleanup-tokens index bf7f1e610c..3b09072f40 100755 --- a/bin/swauth-cleanup-tokens +++ b/bin/swauth-cleanup-tokens @@ -69,13 +69,11 @@ if __name__ == '__main__': objs = conn.get_container(container, marker=marker)[1] except ClientException, e: if e.http_status == 404: - print 'Container %s not found' % (container) - print 'swauth-prep needs to be rerun' - exit() + exit('Container %s not found. swauth-prep needs to be ' + 'rerun' % (container)) else: - print 'Object listing on container %s failed with ' \ - 'status code %d' % (container, e.http_status) - break + exit('Object listing on container %s failed with status ' + 'code %d' % (container, e.http_status)) if objs: marker = objs[-1]['name'] else: diff --git a/bin/swauth-delete-account b/bin/swauth-delete-account index 66bdf2bbe1..45aba4c502 100755 --- a/bin/swauth-delete-account +++ b/bin/swauth-delete-account @@ -57,4 +57,4 @@ if __name__ == '__main__': ssl=(parsed.scheme == 'https')) resp = conn.getresponse() 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)) diff --git a/bin/swauth-delete-user b/bin/swauth-delete-user index de3ac3b12b..95025bc195 100755 --- a/bin/swauth-delete-user +++ b/bin/swauth-delete-user @@ -57,4 +57,4 @@ if __name__ == '__main__': ssl=(parsed.scheme == 'https')) resp = conn.getresponse() 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)) diff --git a/bin/swauth-list b/bin/swauth-list index 3f9ae5ea49..bbf5bfe9f1 100755 --- a/bin/swauth-list +++ b/bin/swauth-list @@ -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, ssl=(parsed.scheme == 'https')) resp = conn.getresponse() - if resp.status // 100 != 2: - print 'List failed: %s %s' % (resp.status, resp.reason) body = resp.read() + if resp.status // 100 != 2: + exit('List failed: %s %s' % (resp.status, resp.reason)) if options.plain_text: info = json.loads(body) for group in info[['accounts', 'users', 'groups'][len(args)]]: diff --git a/bin/swauth-prep b/bin/swauth-prep index a7b912e60c..456cf3e4c8 100755 --- a/bin/swauth-prep +++ b/bin/swauth-prep @@ -56,4 +56,4 @@ if __name__ == '__main__': ssl=(parsed.scheme == 'https')) resp = conn.getresponse() 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)) diff --git a/bin/swauth-set-account-service b/bin/swauth-set-account-service index 0317546df5..acdba77962 100755 --- a/bin/swauth-set-account-service +++ b/bin/swauth-set-account-service @@ -70,4 +70,4 @@ Example: %prog -K swauthkey test storage local http://127.0.0.1:8080/v1/AUTH_018 conn.send(body) resp = conn.getresponse() 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))