Skip to content

Commit

Permalink
Merge pull request #369 from tmaeno/master
Browse files Browse the repository at this point in the history
account lookup with DN in RFC-format
  • Loading branch information
tmaeno authored Jul 2, 2024
2 parents 83933ac + a85dc58 commit b5c0435
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion PandaPkgInfo.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
release_version = "0.3.11"
release_version = "0.3.12"
38 changes: 25 additions & 13 deletions pandaserver/dataservice/ddm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import re
import sys
import traceback

from typing import Dict, List

from rucio.client import Client as RucioClient
Expand All @@ -20,6 +19,7 @@
FileAlreadyExists,
UnsupportedOperation,
)

from pandaserver.srvcore import CoreUtils


Expand All @@ -28,6 +28,7 @@ class RucioAPI:
"""
A class to interact with Rucio API
"""

# constructor
def __init__(self):
"""
Expand Down Expand Up @@ -222,8 +223,9 @@ def get_user(self, client, distinguished_name: str) -> str:
return client.account

# register dataset subscription
def register_dataset_subscription(self, dataset_name: str, rses: list, lifetime: int = None, owner: str = None,
activity: str = None, distinguished_name: str = None, comment: str = None) -> bool:
def register_dataset_subscription(
self, dataset_name: str, rses: list, lifetime: int = None, owner: str = None, activity: str = None, distinguished_name: str = None, comment: str = None
) -> bool:
"""
Register a dataset subscription in Rucio.
Expand Down Expand Up @@ -417,7 +419,7 @@ def register_zip_files(self, zip_map: dict) -> None:
client.add_files_to_archive(
scope=zip_file["scope"],
name=zip_file["name"],
files=files[i_files: i_files + n_files],
files=files[i_files : i_files + n_files],
)
i_files += n_files

Expand Down Expand Up @@ -712,7 +714,7 @@ def get_zip_files(self, dids: List[str], rses: List[str]):
return False, f"{err_type} {err_value}"

# list files in dataset
def list_files_in_dataset(self, dataset_name: str, long: bool = False, file_list: List[str] = None) :
def list_files_in_dataset(self, dataset_name: str, long: bool = False, file_list: List[str] = None):
"""
List files in a Rucio dataset.
Expand Down Expand Up @@ -890,14 +892,24 @@ def finger(self, distinguished_name: str):
x509_user_name = None
for account_type in ["USER", "GROUP"]:
if x509_user_name is not None:
user_name = x509_user_name
for account in client.list_accounts(account_type=account_type, identity=user_name):
user_info = {"nickname": account["account"], "email": account["email"]}
break
if user_info is None:
user_name = CoreUtils.get_bare_dn(distinguished_name, keep_digits=False)
for account in client.list_accounts(account_type=account_type, identity=user_name):
user_info = {"nickname": account["account"], "email": account["email"]}
user_names = [x509_user_name]
# replace / with , and reverse substrings to be converted to RFC format
tmp_list = user_names[-1].split("/")
if "" in tmp_list:
tmp_list.remove("")
user_names.append(",".join(tmp_list[::-1]))
# remove /CN=\d
user_names.append(CoreUtils.get_bare_dn(distinguished_name, keep_digits=False))
# replace / with , and reverse substrings to be converted to RFC format
tmp_list = user_names[-1].split("/")
if "" in tmp_list:
tmp_list.remove("")
user_names.append(",".join(tmp_list[::-1]))
for user_name in user_names:
for i in client.list_accounts(account_type=account_type, identity=user_name):
user_info = {"nickname": i["account"], "email": i["email"]}
break
if user_info is not None:
break
else:
user_name = oidc_user_name
Expand Down

0 comments on commit b5c0435

Please sign in to comment.