Skip to content

Commit c340729

Browse files
committed
Filter out users with no associated projects
1 parent c410e7c commit c340729

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

osg-comanage-project-usermap.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323

2424
_usage = f"""\
25-
usage: [PASS=...] {SCRIPT} [OPTIONS]
25+
usage: {SCRIPT} [OPTIONS]
2626
2727
OPTIONS:
2828
-u USER[:PASS] specify USER and optionally PASS on command line
@@ -36,7 +36,7 @@
3636
(default = {ENDPOINT})
3737
-o outfile specify output file (default: write to stdout)
3838
-g filter_group filter users by group name (eg, 'ap1-login')
39-
-l localmaps specify a comma-delimited list of local HTCondor mapfiles to merge into outfile
39+
-m localmaps specify a comma-delimited list of local HTCondor mapfiles to merge into outfile
4040
-h display this help text
4141
4242
PASS for USER is taken from the first of:
@@ -133,7 +133,7 @@ def parse_options(args):
133133
if op == '-e': options.endpoint = arg
134134
if op == '-o': options.outfile = arg
135135
if op == '-g': options.filtergrp = arg
136-
if op == '-l': options.localmaps = arg.split(",")
136+
if op == '-m': options.localmaps = arg.split(",")
137137

138138
try:
139139
user, passwd = utils.getpw(options.user, passfd, passfile)
@@ -208,7 +208,11 @@ def get_osguser_groups(filter_group_name=None):
208208
ldap_users = utils.get_ldap_active_users_and_groups(options.ldap_server, options.ldap_user, options.ldap_authtok, filter_group_name)
209209
topology_projects = requests.get(f"{TOPOLOGY_ENDPOINT}/miscproject/json").json()
210210
project_names = topology_projects.keys()
211-
return {user: [p for p in groups if p in project_names] for user, groups in ldap_users.items()}
211+
return {
212+
user: [g for g in groups if g in project_names]
213+
for user, groups in ldap_users.items()
214+
if any(g in project_names for g in groups)
215+
}
212216

213217

214218
def parse_localmap(inputfile):

0 commit comments

Comments
 (0)