-
Notifications
You must be signed in to change notification settings - Fork 8
(INF-2987) Create script to mass import users into CO Manage Registry from files #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
williamnswanson
wants to merge
16
commits into
master
Choose a base branch
from
INF-2987.mass-person-create-update-script
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 13 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
2c76263
WIP commit for COmanage mass CO Person creation / modification script.
williamnswanson e25048b
Add fail-fast api exception check for 403, 404, 405, 500 HTTP codes
williamnswanson bca35a7
Fix name_split to handle >=3 sections in name, add name_unsplit
williamnswanson 1f080df
Add schema info and builder for CO Roles
williamnswanson 5ef73c1
Fix CO_Person schema def formatting
williamnswanson 2115261
WIP commit 2 for COmanage mass CO Person creation / modification script.
williamnswanson 4afbd4c
Add Unix cluster group provisioning after adding the user to the group
williamnswanson 67f985a
Fix exception messaging for early failures
williamnswanson 8130146
Retry on 403 Forbidden for rate limiting, typo in exception note
williamnswanson dfd61e0
Mass import script: fixup for U-Chicago dev ingest
williamnswanson 1a68819
COmanage Mass import script: use production values for target, plugin…
williamnswanson 8f77623
COmanage utils: add 401 to error codes to not retry
williamnswanson 2edda0b
COmanage mass import script: add additional comments for where to fin…
williamnswanson 4d4d8b2
Apply suggestions from code review
williamnswanson fccb47b
Merge branch 'master' into INF-2987.mass-person-create-update-script
williamnswanson 30f7512
Comanage_person_schema_utils.py : fix mutable default argument of co_…
williamnswanson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| .vscode/launch.json | ||
| __pycache__/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,228 @@ | ||
| #!/usr/bin/env python3 | ||
|
|
||
| CO_PERSON = { | ||
| "co_id": None, | ||
| "timezone": None, | ||
| "dateofbirth": None, | ||
| "status": None | ||
| } | ||
|
|
||
| IDENTIFIER = { | ||
| "identifier": None, | ||
| "type": None, | ||
| "login": False, | ||
| "status": None, | ||
| } | ||
|
|
||
| NAME = { | ||
| "honorific": None, | ||
| "given": "None", | ||
| "middle": None, | ||
| "family": "None", | ||
| "suffix": None, | ||
| "type": "official", | ||
| "language": None, | ||
| "primary_name": True, | ||
| } | ||
|
|
||
|
|
||
| GROUP = { | ||
| "co_group_id": None, | ||
| "member": True, | ||
| "owner": False, | ||
| } | ||
|
|
||
|
|
||
| COU = { | ||
| "co_id": None, | ||
| "name": None, | ||
| "description": None, | ||
| "parent_id": None, | ||
| } | ||
|
|
||
|
|
||
| ORG_IDENTITY = { | ||
| "co_id": None, | ||
| "title": None, | ||
| # Organization for OrgID | ||
| "o": None, | ||
| # Department for OrgID | ||
| "ou": None, | ||
| "valid_from": None, | ||
| "valid_through": None, | ||
| "status": "", | ||
| "affiliation": None, | ||
| "date_of_birth": None, | ||
| "Address": [], | ||
| "AdHocAttribute": [], | ||
| "EmailAddress": [], | ||
| "Identifier": [], | ||
| "Name": [], | ||
| "TelephoneNumber": [], | ||
| "Url": [], | ||
| } | ||
|
|
||
|
|
||
| ROLE = { | ||
| "cou_id": None, | ||
| "title": "", | ||
| "o": "", | ||
| "ou": "", | ||
| "valid_from": None, | ||
| "valid_through": None, | ||
| "status": "A", | ||
| "sponsor_co_person_id": None, | ||
| "affiliation": "member", | ||
| "ordr": 1, | ||
| } | ||
|
|
||
|
|
||
| EMAIL_ADDRESS = { | ||
| "mail": None, | ||
| "type": None, | ||
| "verified": None, | ||
| } | ||
|
|
||
|
|
||
| UNIX_CLUSTER_ACCOUNT = { | ||
| "sync_mode": "F", | ||
| "status": None, | ||
| "username": None, | ||
| "uid": None, | ||
| "gecos": None, | ||
| "login_shell": "/bin/bash", | ||
| "home_directory": None, | ||
| "primary_co_group_id": None, | ||
| "valid_from": None, | ||
| "valid_through": None, | ||
| "unix_cluster_id": None, | ||
| } | ||
|
|
||
|
|
||
| SSHKEY = { | ||
| "type": None, | ||
| "skey": None, | ||
| "comment": "", | ||
| "ssh_key_authenticator_id": None, | ||
| } | ||
|
|
||
|
|
||
| def co_person_schema(co_id, timezone=None, dob=None, status="Active"): | ||
| person_data = CO_PERSON.copy() | ||
| person_data["co_id"] = co_id | ||
| person_data["timezone"] = timezone | ||
| person_data["dateofbirth"] = dob | ||
| person_data["status"] = status | ||
| return person_data | ||
|
|
||
|
|
||
| def co_person_identifier(identifier, type, login=False, status="Active"): | ||
| identifier_data = IDENTIFIER.copy() | ||
| identifier_data["identifier"] = identifier | ||
| identifier_data["type"] = type | ||
| identifier_data["login"] = login | ||
| identifier_data["status"] = status | ||
| return identifier_data | ||
|
|
||
|
|
||
| def co_person_name(given, family=None, middle=None, type="official", primary=False): | ||
| name_data = NAME.copy() | ||
| name_data["given"] = given | ||
| name_data["family"] = family | ||
| name_data["middle"] = middle | ||
| name_data["type"] = type | ||
| name_data["primary_name"] = primary | ||
| return name_data | ||
|
|
||
|
|
||
| def name_split(whole_name): | ||
| name_sections = str(whole_name).split() | ||
| parts_count = len(name_sections) | ||
| if parts_count == 1: | ||
| return co_person_name(given=whole_name) | ||
| elif parts_count == 2: | ||
| return co_person_name(given=name_sections[0], family=name_sections[1]) | ||
| else: | ||
| return co_person_name(given=name_sections[0], family=name_sections[parts_count-1], middle=" ".join(name_sections[1:parts_count-1])) | ||
|
|
||
|
|
||
| def name_unsplit(name_id): | ||
| if name_id["given"] is None: | ||
| return "" | ||
| elif name_id["family"] is None: | ||
| return name_id["given"] | ||
| elif name_id["middle"] is None: | ||
| return f'{name_id["given"]} {name_id["family"]}' | ||
| else: | ||
| return f'{name_id["given"]} {name_id["middle"]} {name_id["family"]}' | ||
|
|
||
|
|
||
|
|
||
| def co_person_group_member(group_id, member=True, owner=False): | ||
| group_member = GROUP.copy() | ||
| group_member["co_group_id"] = group_id | ||
| group_member["member"] = member | ||
| group_member["owner"] = owner | ||
| return group_member | ||
|
|
||
|
|
||
| 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() | ||
| org_id["co_id"] = osg_co_id | ||
| org_id["title"] = title | ||
| org_id["o"] = organization | ||
| org_id["ou"] = department | ||
| org_id["affiliation"] = affiliation | ||
| org_id["Identifier"] = id_list | ||
| org_id["Name"] = name | ||
| return org_id | ||
|
|
||
|
|
||
| def co_person_role(cou, title, affiliation, order): | ||
| role = ROLE.copy() | ||
| role["cou_id"] = cou | ||
| role["title"] = title | ||
| role["affiliation"] = affiliation | ||
| role["ordr"] = order | ||
| return role | ||
|
|
||
| def co_person_email_address(mail, type="delivery", verified=False): | ||
| email = EMAIL_ADDRESS.copy() | ||
| email["mail"] = mail | ||
| email["type"] = type | ||
| email["verified"] = verified | ||
| return email | ||
|
|
||
|
|
||
| def co_person_unix_cluster_acc(unix_cluster_id, username, uid, name, group_id, status="A"): | ||
| uca = UNIX_CLUSTER_ACCOUNT.copy() | ||
| uca["unix_cluster_id"] = unix_cluster_id | ||
| uca["username"] = username | ||
| uca["uid"] = uid | ||
| uca["status"] = status | ||
| uca["gecos"] = name | ||
| uca["home_directory"] = f"/home/{username}" | ||
| uca["primary_co_group_id"] = group_id | ||
| return uca | ||
|
|
||
|
|
||
| def co_person_sshkey(type, skey, comment, auth_id): | ||
| sshkey_data = SSHKEY.copy() | ||
| sshkey_data["type"] = type | ||
| sshkey_data["skey"] = skey | ||
| sshkey_data["comment"] = comment | ||
| sshkey_data["ssh_key_authenticator_id"] = auth_id | ||
| return sshkey_data | ||
|
|
||
|
|
||
| # def merge_schema(base_data, new_data, type): | ||
| # temp = base_data | ||
| # for field in type.keys(): | ||
| # for entry in new_data[field]: | ||
| # if "meta" in entry: | ||
| # | ||
| # | ||
| # return temp | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.