aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Sokolovsky <paul.sokolovsky@linaro.org>2013-12-15 10:59:41 +0200
committerPaul Sokolovsky <paul.sokolovsky@linaro.org>2013-12-15 10:59:41 +0200
commitd11c300a4cbd903d910b70e4bfb7484b6aa14b88 (patch)
treed4d4184487d22aeb86aff5e6bdfa887be0043499
parent15037aec0c74bcb343a23f8ed83d0c0b4cceb699 (diff)
downloadcrowd-tool-d11c300a4cbd903d910b70e4bfb7484b6aa14b88.tar.gz
Add "members" command.
-rwxr-xr-xcrowd-tool15
1 files changed, 14 insertions, 1 deletions
diff --git a/crowd-tool b/crowd-tool
index 2429e25..ee13c78 100755
--- a/crowd-tool
+++ b/crowd-tool
@@ -48,7 +48,7 @@ def rest(uri, params):
if __name__ == "__main__":
logging.basicConfig()
- optparser = optparse.OptionParser(usage="%prog user|alises|group|usergroups|ismember|groupusers|groupgroups")
+ optparser = optparse.OptionParser(usage="%prog user|alises|group|usergroups|ismember|groupusers|groupgroups|members")
optparser.add_option("-u", "--user", default="rest-test", help="Crowd username")
optparser.add_option("-p", "--passwd", help="Crowd password")
optparser.add_option("-P", "--ask-passwd", action="store_true", help="Ask Crowd password")
@@ -105,6 +105,19 @@ if __name__ == "__main__":
for n in names:
print n
+ elif args[0] == "members":
+ def print_names(header, list):
+ if list:
+ print header
+ for n in list:
+ print "\t" + n
+ data = rest("/group/user/direct.json", {"groupname": args[1]})
+ names = sorted([x["name"] for x in data["users"]])
+ print_names("Users:", names)
+ data = rest("/group/child-group/direct.json", {"groupname": args[1]})
+ names = sorted([x["name"] for x in data["groups"]])
+ print_names("Groups:", names)
+
elif args[0] == "ismember":
url = "/user/group/nested.json" if options.nested else "/user/group/direct.json"
try: