path: root/gluster/swift/common/middleware/gswauth/bin
diff options
authorThiago da Silva <>2013-11-25 12:18:03 -0500
committerLuis Pabon <>2013-11-29 14:01:11 -0800
commitdb63e2e59962d9b8d1cb009ec25198a621c61f9f (patch)
treeff2f903b46162484b820dd57f171540a7e705f0a /gluster/swift/common/middleware/gswauth/bin
parent6474e030bf91fb7985d9238f9f1031c0c8626067 (diff)
adding tabular output to swauth-list
swauth-list now shows lists of accounts, users and groups in a tabular format (default). JSON and plain-text options are still available Change-Id: I897009f5f6c05aa4c14e306bb6ad35234e993fcd Signed-off-by: Thiago da Silva <> Reviewed-on: Reviewed-by: Luis Pabon <> Tested-by: Luis Pabon <> Reviewed-on:
Diffstat (limited to 'gluster/swift/common/middleware/gswauth/bin')
1 files changed, 17 insertions, 5 deletions
diff --git a/gluster/swift/common/middleware/gswauth/bin/swauth-list b/gluster/swift/common/middleware/gswauth/bin/swauth-list
index c49af04..7ad0974 100755
--- a/gluster/swift/common/middleware/gswauth/bin/swauth-list
+++ b/gluster/swift/common/middleware/gswauth/bin/swauth-list
@@ -26,6 +26,7 @@ from sys import argv, exit
from swift.common.bufferedhttp import http_connect_raw as http_connect
from swift.common.utils import urlparse
+from prettytable import PrettyTable
if __name__ == '__main__':
gettext.install('swauth', unicode=1)
@@ -34,11 +35,11 @@ Usage: %prog [options] [account] [user]
If [account] and [user] are omitted, a list of accounts will be output.
-If [account] is included but not [user], an account's information will be
-output, including a list of users within the account.
+If [account] is included but not [user], a list of users within the account
+will be output.
-If [account] and [user] are included, the user's information will be output,
-including a list of groups the user belongs to.
+If [account] and [user] are included, a list of groups the user belongs to
+will be ouptput.
If the [user] is '.groups', the active groups for the account will be listed.
@@ -46,6 +47,10 @@ If the [user] is '.groups', the active groups for the account will be listed.
action='store_true', default=False, help='Changes the output from '
'JSON to plain text. This will cause an account to list only the '
'users and a user to list only the groups.')
+ parser.add_option('-j', '--json', dest='json_format',
+ action='store_true', default=False, help='Output in JSON format. '
+ 'This will print all information about given account or user, '
+ 'including stored password.')
parser.add_option('-A', '--admin-url', dest='admin_url',
default='', help='The URL to the auth '
'subsystem (default:')
@@ -82,5 +87,12 @@ If the [user] is '.groups', the active groups for the account will be listed.
info = json.loads(body)
for group in info[['accounts', 'users', 'groups'][len(args)]]:
print group['name']
- else:
+ elif options.json_format:
print body
+ else:
+ info = json.loads(body)
+ h = ['accounts', 'users', 'groups'][len(args)]
+ table = PrettyTable([h.title()])
+ for group in info[h]:
+ table.add_row([group['name']])
+ print table