22
22
23
23
24
24
_usage = f"""\
25
- usage: [PASS=...] { SCRIPT } [OPTIONS]
25
+ usage: [PASS=...] { SCRIPT } [OPTIONS] COGroupNameOrId ProjectName
26
26
27
27
OPTIONS:
28
28
-u USER[:PASS] specify USER and optionally PASS on command line
31
31
-f passfile specify path to file to open and read PASS
32
32
-e ENDPOINT specify REST endpoint
33
33
(default = { ENDPOINT } )
34
- -a show all UnixCluster autogroups, not just misnamed ones
35
- -i COGroupId show fixup info for a specific CO Group
36
- -x COGroupId run UnixCluster Group fixups for given CO Group Id
37
34
-h display this help text
38
35
39
- Run without options to display misnamed UnixCluster autogroups.
40
- Run with -a to include UnixCluster autogroups with fixed names, too.
41
- Run with -i to display only a given CO Group.
42
- Run with -x to fixup a given CO Group.
36
+ Adds an identifier of type ospoolproject named Yes-ProjectName to
37
+ a COGroup based on its Name or CO Group Id.
43
38
44
39
PASS for USER is taken from the first of:
45
40
1. -u USER:PASS
@@ -61,9 +56,9 @@ class Options:
61
56
osg_co_id = OSG_CO_ID
62
57
user = USER
63
58
authstr = None
64
- fix_gid = None
65
- info_gid = None
66
- showall = False
59
+ gid = None
60
+ gname = None
61
+ project = None
67
62
68
63
69
64
options = Options ()
@@ -327,12 +322,19 @@ def fixup_unixcluster_group(gid):
327
322
328
323
def parse_options (args ):
329
324
try :
330
- ops , args = getopt .getopt (args , 'u:c:d:f:e:x:i:ah ' )
325
+ ops , args = getopt .getopt (args , 'u:c:d:f:e:h ' )
331
326
except getopt .GetoptError :
332
327
usage ()
333
328
334
- if args :
335
- usage ("Extra arguments: %s" % repr (args ))
329
+ if len (args ) != 2 :
330
+ usage ()
331
+
332
+ cogroup , project = args
333
+ if re .fullmatch (r'\d+' , cogroup ):
334
+ options .gid = int (cogroup )
335
+ else :
336
+ options .gname = cogroup
337
+ options .project = project
336
338
337
339
passfd = None
338
340
passfile = None
@@ -344,9 +346,6 @@ def parse_options(args):
344
346
if op == '-d' : passfd = int (arg )
345
347
if op == '-f' : passfile = arg
346
348
if op == '-e' : options .endpoint = arg
347
- if op == '-x' : options .fix_gid = int (arg )
348
- if op == '-i' : options .info_gid = int (arg )
349
- if op == '-a' : options .showall = True
350
349
351
350
user , passwd = getpw (options .user , passfd , passfile )
352
351
options .authstr = mkauthstr (user , passwd )
@@ -355,21 +354,18 @@ def parse_options(args):
355
354
def main (args ):
356
355
parse_options (args )
357
356
358
- if options .fix_gid :
359
- return fixup_unixcluster_group (options .fix_gid )
360
- elif options .showall :
361
- show_all_unixcluster_groups ()
362
- elif options .info_gid :
363
- show_one_unixcluster_group (options .info_gid )
364
- else :
365
- show_misnamed_unixcluster_groups ()
357
+ if options .gname :
358
+ options .gid = gname_to_gid (options .gname )
366
359
367
- return 0
360
+ add_project_identifier_to_group (options .gid , options .project )
361
+
362
+ # no exceptions, must have worked
363
+ print (":thumbsup:" )
368
364
369
365
370
366
if __name__ == "__main__" :
371
367
try :
372
- sys . exit ( main (sys .argv [1 :]) )
368
+ main (sys .argv [1 :])
373
369
except (RuntimeError , urllib .error .HTTPError ) as e :
374
370
print (e , file = sys .stderr )
375
371
sys .exit (1 )
0 commit comments