Skip to content

(INF-2987) Create script to mass import users into CO Manage Registry from files#29

Open
williamnswanson wants to merge 13 commits into
masterfrom
INF-2987.mass-person-create-update-script
Open

(INF-2987) Create script to mass import users into CO Manage Registry from files#29
williamnswanson wants to merge 13 commits into
masterfrom
INF-2987.mass-person-create-update-script

Conversation

@williamnswanson

Copy link
Copy Markdown
Collaborator

Takes a file with a list of maps of key:value pairs and creates a CO Person record in the COmanage Registry (along with CO Roles, CO Group Memberships, SSH Keys, Unix cluster accounts and groups, ect)

The script doesn't currently have a way to know what parts of the mapping file should be used for what attributes of what type of record, so the build_co_person_record() function will need to be modified to suit the specific import you're trying to do, what data you have for the users, ect.

@williamnswanson williamnswanson self-assigned this Jan 30, 2026
@williamnswanson williamnswanson added the enhancement New feature or request label Jan 30, 2026
@brianhlin brianhlin requested review from jasoncpatton and removed request for brianhlin March 17, 2026 17:47
@brianhlin brianhlin requested a review from Copilot June 17, 2026 19:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new bulk-import script to create COmanage Registry CO Person records from JSON input, including related objects (roles, group memberships, SSH keys, Unix cluster accounts/groups), supported by new schema-building helpers and some new COmanage utility APIs.

Changes:

  • Added mass_person_create_modify.py to read an input data file + mapping file and create/provision CO Person-related records in COmanage.
  • Added comanage_person_schema_utils.py with helpers for constructing Core API v1-style CO Person payloads.
  • Extended comanage_utils.py with Core API v1 people helpers, new retry/fast-fail HTTP handling, and group creation helper.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 7 comments.

File Description
mass_person_create_modify.py New mass import script to create CO People, groups, Unix accounts, and provision them.
comanage_utils.py Adds HTTP fast-fail exception type, Core API people helpers, identifier update helper, and CO group creation helper.
comanage_person_schema_utils.py New module defining payload templates and helper constructors for CO Person-related objects.
.gitignore Ignores Python __pycache__ artifacts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread comanage_utils.py
Comment on lines +33 to +34
# HTTP return codes we shouldn't attempt to retry
HTTP_NO_RETRY_CODES = {401, 404, 405, 500}
Comment thread comanage_utils.py
Comment on lines +209 to +210
return call_api3(PUT, "/api/v2/identifiers" % id_, id_data, endpoint, authstr, )
#return call_api3(PUT, "identifiers/%s.json" % id_, id_data, endpoint, authstr)
Comment thread comanage_utils.py
"RequestType" : "CoGroups",
"Version" : "1.0"
}
return call_api3(POST, "co_groups/.json", data, endpoint, authstr)
Comment on lines +169 to +173
def co_person_org_id(
osg_co_id, name, organization="", department="", title="", affiliation="member", id_list=[]
):
#org_id = {"co_id" : osg_co_id}
org_id = ORG_IDENTITY.copy()
Comment on lines +66 to +71
try:
user, passwd = utils.getpw(options.user, passfd, passfile)
options.authstr = utils.mkauthstr(user, passwd)
except PermissionError:
usage("PASS required")

Comment on lines +168 to +171
identifiers_list = co_person_record["Identifier"]
username = next((item["identifier"] for item in identifiers_list if item["type"] == "osguser"))
uid = next((item["identifier"] for item in identifiers_list if item["type"] == "uid"))
description = f"Unix Cluster Group for {username}"
Comment on lines +73 to +87
def read_data_dump():
data_json = []
with open(options.input_file, 'r', encoding='utf-8') as input_file:
data_json = json.load(input_file)
for entry in range(len(data_json)):
for key_index in range(len(data_json[entry]["public_keys"])):
key = data_json[entry]["public_keys"][key_index]
key_sections = str(key).split()
if len(key_sections) >= 2:
data_json[entry]["public_keys"][key_index] = {"type" : key_sections[0], "pkey" : key_sections[1]}
if len(key_sections) >= 3:
data_json[entry]["public_keys"][key_index].update({"authenticator" : key_sections[2]})
with open(options.mapping_file, 'r', encoding='utf-8') as mapping_file:
mapping_json = json.load(mapping_file)
return data_json, mapping_json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants