Skip to content

Commit

Permalink
Fixes to keep only relevant _ info
Browse files Browse the repository at this point in the history
  • Loading branch information
amanrique1 committed Oct 10, 2023
1 parent f5d1c1c commit ab94248
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions docker/CMSRucioClient/scripts/cmslinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ def __init__(self, account, auth_type=None, exclude=DEFAULT_EXCLUDE_LINKS,
self._get_matrix(distance, exclude)

def _get_rselist(self, rselist=None):
private_token = os.environ['GITLAB_TOKEN']
gl = gitlab.Gitlab('https://gitlab.cern.ch', private_token=private_token)
try:
private_token = os.environ['GITLAB_TOKEN']
gl = gitlab.Gitlab('https://gitlab.cern.ch', private_token=private_token)
except Exception as e:
logging.warning(f'Could not connect to gitlab. Error: {str(e)}')
gl = None

self.rselist = []

Expand All @@ -58,11 +62,17 @@ def _get_rselist(self, rselist=None):
attrs = self.rcli.list_rse_attributes(rse=rse)
pnn = attrs.get('pnn')
if pnn is None:
project = gl.projects.get('SITECONF/'+rse)
f = project.files.get('storage.json', 'master')
sites = json.loads(base64.b64decode(f.content))
sites = []
try:
project_rse = rse.split('_')[:3]
project_rse = '_'.join(project_rse)
project = gl.projects.get('SITECONF/'+project_rse)
f = project.files.get('storage.json', 'master')
sites = json.loads(base64.b64decode(f.content))
except Exception as e:
logging.warning(f'No PNN for RSE {rse}. Trying to get it from gitlab. Error: {str(e)}')
for site in sites:
if site.get('rse') == rse:
if site.get('rse') in rse:
pnn = site.get('site')
break

Expand Down

0 comments on commit ab94248

Please sign in to comment.