From f56cdf3ca6d622366cbb5cf89fffe18b2cd662e3 Mon Sep 17 00:00:00 2001 From: Eric Vaandering Date: Fri, 1 Sep 2023 16:15:24 -0500 Subject: [PATCH] no message --- docker/CMSRucioClient/scripts/syncaccounts.py | 2 +- .../scripts/user_to_site_mapping.py | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/docker/CMSRucioClient/scripts/syncaccounts.py b/docker/CMSRucioClient/scripts/syncaccounts.py index 4f8eefa7..0dfde101 100755 --- a/docker/CMSRucioClient/scripts/syncaccounts.py +++ b/docker/CMSRucioClient/scripts/syncaccounts.py @@ -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 diff --git a/docker/CMSRucioClient/scripts/user_to_site_mapping.py b/docker/CMSRucioClient/scripts/user_to_site_mapping.py index 3c05d0c0..0f3f4b23 100755 --- a/docker/CMSRucioClient/scripts/user_to_site_mapping.py +++ b/docker/CMSRucioClient/scripts/user_to_site_mapping.py @@ -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 = '' @@ -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 @@ -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