Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #837: Distances for Europe and Asia #857

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 31 additions & 11 deletions docker/rucio_client/scripts/cmslinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
And script for updating the distances.
"""
import gitlab
import base64

import argparse
import base64
import json
import logging
import os
Expand All @@ -16,7 +17,7 @@

DEFAULT_EXCLUDE_LINKS = (
{'dest': {'type': 'temp'}, 'src': {}},
{'dest': {'rse': 'T2_US_Caltech'}, 'src': {'rse': 'T2_US_Caltech_Ceph'}},
{'dest': {'rse': 'T2_US_Caltech'}, 'src': {'rse': 'T2_US_Caltech_Ceph'}}, # TODO: Temporary site, Clear up
{'dest': {'rse': 'T1_UK_RAL_Tape_Test'}, 'src': {}},
{'dest': {}, 'src': {'rse': 'T1_UK_RAL_Tape_Test'}},
{'dest': {'rse': 'T1_UK_RAL_Tape'}, 'src': {'rse': '^(?!T1_UK_RAL_Disk|T0_CH_CERN_Disk).*$'}},
Expand All @@ -26,7 +27,17 @@
CTA_RSES = ['T0_CH_CERN_Tape']
CERN_RSES = ['T2_CH_CERN']

DEFAULT_DISTANCE_RULES = {'site': 1, 'region&country': 4, 'country': 7, 'region': 10, 'other': 13}
# TODO: Regions A and C should be 11
# TODO: Regions C and D should be 12
DEFAULT_DISTANCE_RULES = {
'site': 1,
'region&country': 4,
'country': 7,
'region': 10,
'AC': 11,
'CD': 12,
'other': 13
}


class LinksMatrix(object):
Expand Down Expand Up @@ -101,32 +112,38 @@ def _get_rselist(self, rselist=None):

def _get_matrix(self, distance, exclude):

# TODO: Unused?
matrix = {}

self.links = {}

for src in self.rselist:
for src in self.rselist: # get the list
for dest in self.rselist:

src_rse = src['rse']
dest_rse = dest['rse']
src_pnn = src['pnn']
dest_pnn = dest['pnn']

# TODO: If region A and region C, set to 11
# TODO: Region C and D: 12
if dest_pnn == src_pnn:
link = distance['site']
elif src['region'] and dest['region'] and src['region'] == dest['region']:
if src['country'] == dest['country']:
elif src['region'] and dest['region'] and src['region'] == dest['region']: # Check same region
if src['country'] == dest['country']: # Same country and region
link = distance['region&country']
else:
link = distance['region']
elif src_pnn in matrix and dest_pnn in matrix[src_pnn]:
elif src_pnn in matrix and dest_pnn in matrix[src_pnn]: # not sure what this is for
link = distance['site'] - matrix[src_pnn][dest_pnn]
elif src['country'] == dest['country']:
link = distance['country']
elif {src['region'], dest['region']} == {'A', 'C'}:
link = distance['AC']
elif {src['region'], dest['region']} == {'C', 'D'}:
link = distance['CD']
else:
if src['country'] == dest['country']:
link = distance['country']
else:
link = distance['other']
link = distance['other']

if src_rse not in self.links:
self.links[src_rse] = {}
Expand All @@ -136,6 +153,9 @@ def _get_matrix(self, distance, exclude):
self._filter_matrix(exclude)

def _filter_matrix(self, exclude):
"""
Removes links from list of excluded
"""

for src in self.rselist:
for dest in self.rselist:
Expand Down