diff --git a/src/policy/CMSRucioPolicy/__init__.py b/src/policy/CMSRucioPolicy/__init__.py index c5eb32f..31cc983 100644 --- a/src/policy/CMSRucioPolicy/__init__.py +++ b/src/policy/CMSRucioPolicy/__init__.py @@ -2,7 +2,7 @@ # # Eric Vaandering , 2022 -from CMSRucioPolicy.algorithms import lfn2pfn, auto_approve +from CMSRucioPolicy.algorithms import lfn2pfn, auto_approve, pfn2lfn SUPPORTED_VERSION = ["32", "33", "34", "35"] @@ -17,5 +17,8 @@ def get_algorithms(): }, 'auto_approve': { 'global': auto_approve.global_approval, + }, + 'pfn2lfn': { + 'cms_pfn2lfn': pfn2lfn.cms_pfn2lfn, } } diff --git a/src/policy/CMSRucioPolicy/algorithms/pfn2lfn.py b/src/policy/CMSRucioPolicy/algorithms/pfn2lfn.py new file mode 100644 index 0000000..cd98657 --- /dev/null +++ b/src/policy/CMSRucioPolicy/algorithms/pfn2lfn.py @@ -0,0 +1,14 @@ +""" +PFN to scope:name translation algorithm for CMS Rucio policy +""" +from collections.abc import Mapping + +def cms_pfn2lfn(parsed_pfn: Mapping[str, str]) -> tuple[str, str]: + """ + This function converts a PFN into scope:name pair. + It ignores user scopes and sets all scopes to cms. + """ + # Ignore user scopes for now + scope = "cms" + name = parsed_pfn['path'] + parsed_pfn['name'] + return name, scope \ No newline at end of file