Skip to content

Commit 842db88

Browse files
committed
add --fix-all option to fix all misnamed groups (SOFTWARE-5057)
1 parent ccc05a3 commit 842db88

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

group_fixup.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
-a show all UnixCluster autogroups, not just misnamed ones
3535
-i COGroupId show fixup info for a specific CO Group
3636
-x COGroupId run UnixCluster Group fixups for given CO Group Id
37+
--fix-all run UnixCluster Group fixups for all misnamed groups
3738
-h display this help text
3839
3940
Run without options to display misnamed UnixCluster autogroups.
@@ -64,6 +65,7 @@ class Options:
6465
fix_gid = None
6566
info_gid = None
6667
showall = False
68+
fix_all = False
6769

6870

6971
options = Options()
@@ -287,12 +289,18 @@ def fixup_unixcluster_group(gid):
287289
return 0
288290

289291

292+
def fixup_all_unixcluster_groups():
293+
groups = get_misnamed_unixcluster_groups()
294+
for group in groups:
295+
fixup_unixcluster_group(group["Id"])
296+
297+
290298
# CLI
291299

292300

293301
def parse_options(args):
294302
try:
295-
ops, args = getopt.getopt(args, 'u:c:d:f:e:x:i:ah')
303+
ops, args = getopt.getopt(args, 'u:c:d:f:e:x:i:ah', ["fix-all"])
296304
except getopt.GetoptError:
297305
usage()
298306

@@ -313,6 +321,8 @@ def parse_options(args):
313321
if op == '-i': options.info_gid = int(arg)
314322
if op == '-a': options.showall = True
315323

324+
if op == '--fix-all': options.fix_all = True
325+
316326
user, passwd = getpw(options.user, passfd, passfile)
317327
options.authstr = mkauthstr(user, passwd)
318328

@@ -322,6 +332,8 @@ def main(args):
322332

323333
if options.fix_gid:
324334
return fixup_unixcluster_group(options.fix_gid)
335+
elif options.fix_all:
336+
return fixup_all_unixcluster_groups()
325337
elif options.showall:
326338
show_all_unixcluster_groups()
327339
elif options.info_gid:

0 commit comments

Comments
 (0)