Skip to content

Commit

Permalink
Merge pull request #592 from ericvaandering/rfc_dn
Browse files Browse the repository at this point in the history
Add another DN for RFC comma separated form
  • Loading branch information
ericvaandering authored Sep 1, 2023
2 parents e80e7c9 + f56cdf3 commit 1c1ed07
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docker/CMSRucioClient/scripts/syncaccounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def _add_identity(self, account, dry=False):
authtype=self.identity['type'], email=None)
logging.debug('added %s for account %s', self.identity, account)
except Duplicate: # Sometimes idmissing doesn't seem to work
logging.warn('identity %s for account %s existed', self.identity, account)
logging.warning('identity %s for account %s existed', self.identity, account)
return False
return idmissing

Expand Down
17 changes: 17 additions & 0 deletions docker/CMSRucioClient/scripts/user_to_site_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def map_cric_users(country, option, dry_run):
institute_country = user['institute_country']
institute = user['institute']
dns = {user['dn']}
dns.add(rfc2253dn(user['dn']))
email = user['email']
account_type = "USER"
policy = ''
Expand All @@ -83,6 +84,7 @@ def map_cric_users(country, option, dry_run):
for profile in profiles:
if 'dn' in profile:
dns.add(profile['dn'])
dns.add(rfc2253dn(profile['dn']))
except KeyError:
continue

Expand Down Expand Up @@ -161,6 +163,21 @@ def usage():
print("\t-d, --dry_run=\tt|f")


def rfc2253dn(legacy_dn):
"""
Convert a slash separated DN to a comma separated format
:param legacy_dn:
:return:
"""
if not legacy_dn.startswith('/'): # No op for things which aren't DNs
return legacy_dn
legacy_dn = legacy_dn.replace(',', r'\,')
parts = legacy_dn.split('/')[1:] # Get rid of leading slash
new_dn = ','.join(parts)

return new_dn


def main():
option = 'set-new-only'
dry_run = False
Expand Down

0 comments on commit 1c1ed07

Please sign in to comment.