Skip to content

Commit 30227b1

Browse files
Add more comments and remove COManage data dict
1 parent f8898d3 commit 30227b1

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

project_group_setup.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ def update_highest_osggid(highest_osggid, group):
123123

124124

125125
def get_comanage_data():
126-
comanage_data = {"Projects": [], "highest_osggid": 0}
126+
projects_list = []
127+
highest_osggid = 0
127128

128129
co_groups = utils.get_osg_co_groups(options.osg_co_id, options.endpoint, options.authstr)["CoGroups"]
129130
for group_data in co_groups:
@@ -132,12 +133,14 @@ def get_comanage_data():
132133
# Store this groups data in a dictionary to avoid repeated API calls
133134
group = {"Gid": group_data["Id"], "Name": group_data["Name"], "ID_List": identifier_list["Identifiers"]}
134135

135-
append_if_project(comanage_data["Projects"], group)
136+
# Add this group to the project list if it's a project, otherwise skip.
137+
append_if_project(projects_list, group)
136138

137-
comanage_data["highest_osggid"] = update_highest_osggid(comanage_data["highest_osggid"], group)
139+
# Update highest_osggid, if this group has an osggid and it's higher than the current highest osggid.
140+
highest_osggid = update_highest_osggid(highest_osggid, group)
138141
except TypeError:
139142
pass
140-
return comanage_data
143+
return (projects_list, highest_osggid)
141144

142145

143146
def get_projects_needing_identifiers(project_groups):
@@ -191,8 +194,9 @@ def get_projects_needing_provisioning(project_groups):
191194

192195

193196
def add_missing_group_identifier(project, id_type, value):
194-
# If the group doesn't already have an id of this type...
197+
# If the group doesn't already have an id of this type ...
195198
if utils.identifier_from_list(project["ID_List"], id_type) is None:
199+
# ... add the identifier to the group
196200
utils.add_identifier_to_group(project["Gid"], id_type, value, options.endpoint, options.authstr)
197201
print(f'project {project["Gid"]}: added id {value} of type {id_type}')
198202

@@ -237,16 +241,23 @@ def provision_groups(project_list):
237241
def main(args):
238242
parse_options(args)
239243

240-
comanage_data = get_comanage_data()
241-
projects = comanage_data["Projects"]
242-
highest_current_osggid = comanage_data["highest_osggid"]
244+
# Make all of the nessisary calls to COManage's API for the data we'll need to set up projects.
245+
# Projects is a List of dicts with keys Gid, Name, and Identifiers, the project's list of identifiers.
246+
# Highest_current_osggid is the highest OSGGID that's currently assigned to any CO Group.
247+
projects, highest_current_osggid = get_comanage_data()
243248

249+
# From all the project groups in COManage, find the ones that need OSGGIDs or OSG GroupNames,
250+
# then assign them the identifiers that they're missing.
244251
projects_needing_identifiers = get_projects_needing_identifiers(projects)
245252
assign_identifiers(projects_needing_identifiers, highest_current_osggid)
246253

254+
# From all the project groups in COManage, find the ones that don't have UNIX Cluster Groups,
255+
# then create UNIX Cluster Groups for them.
247256
projects_needing_cluster_groups = get_projects_needing_cluster_groups(projects)
248257
create_unix_cluster_groups(projects_needing_cluster_groups)
249258

259+
# From all the project groups in COManage, find the ones that aren't already provisioned in LDAP,
260+
# then have COManage provision the project/UNIX Cluster Group in LDAP.
250261
projects_needing_provisioning = get_projects_needing_provisioning(projects)
251262
provision_groups(projects_needing_provisioning)
252263

0 commit comments

Comments
 (0)