Skip to content

Commit

Permalink
Make people status independent of CO status
Browse files Browse the repository at this point in the history
  • Loading branch information
mrvanes committed Jan 16, 2024
1 parent 071abb3 commit 8f98d6e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
20 changes: 14 additions & 6 deletions plsc_flat.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# Create phase
def create(src, dst):
global vc
overruling_status = 'expired'
overruling_status = 'active'

services = util.find_ordered_services(src)
logging.debug(f"s: {services}")
Expand All @@ -33,7 +33,8 @@ def create(src, dst):

# voPersonStatus is a special case (per service)
voPersonStatus = {}
dst_entries = {}
people_entries = {}
group_entries = {}

logging.debug("service: {}".format(service))

Expand All @@ -54,6 +55,7 @@ def create(src, dst):
src_dn = src.rfind(f"o={co_id},dc=ordered,dc={service}", '(ObjectClass=organization)')
src_co = src_dn.get(f"o={co_id},dc=ordered,dc={service},{src.basedn}", {})
src_mail = src_co.get('mail', [])
src_status = src_co.get('organizationalStatus', ['active'])
logging.debug(f"src_mail: {src_mail}")

co_dn = f"dc=flat,dc={service},{dst.basedn}"
Expand All @@ -71,7 +73,7 @@ def create(src, dst):
if overruling_status in voPersonStatus[src_uid] else [current_status]

dst_dn = f"uid={src_uid},ou=People,{co_dn}"
dst_entries[dst_dn] = src_entry
people_entries[dst_dn] = src_entry

logging.debug(" - Groups")
grp_dns = src.rfind(f"ou=Groups,o={co_id},dc=ordered,dc={service}", '(objectClass=groupOfMembers)')
Expand Down Expand Up @@ -106,13 +108,19 @@ def create(src, dst):
new_entry['cn'] = [grp_cn]
new_entry['member'] = members
new_entry['mail'] = src_mail
new_entry['organizationalStatus'] = src_status

dst_dn = f"cn={grp_cn},ou=Groups,{co_dn}"
group_entries[dst_dn] = new_entry

ldif = dst.store(dst_dn, new_entry)
logging.debug(" - store: {}".format(ldif))
# We need to write People first so that
# memberOf overlay can find the members
for dst_dn, dst_entry in people_entries.items():
ldif = dst.store(dst_dn, dst_entry)
logging.debug(f" - store: {dst_dn} {ldif}")

for dst_dn, dst_entry in dst_entries.items():
# Then Groups
for dst_dn, dst_entry in group_entries.items():
ldif = dst.store(dst_dn, dst_entry)
logging.debug(f" - store: {dst_dn} {ldif}")

Expand Down
1 change: 1 addition & 0 deletions plsc_ordered.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ def create(src, dst):
co_entry['businessCategory'] = add_scope(values=co.get('tags'),
scope=co['organisation']['short_name'])
co_entry['mail'] = list(set(admin.get('email') for admin in co.get('admins')))
co_entry['OrganizationalStatus'] = [co.get('status', 'active')]

co_dns = dst.rfind(f"dc=ordered,dc={service}", f"(&(objectClass=organization)(o={co_identifier}))")

Expand Down

0 comments on commit 8f98d6e

Please sign in to comment.