File indexing completed on 2026-04-10 08:39:06
0001 """
0002 nucleus specification
0003
0004 """
0005
0006 import re
0007
0008
0009 class NucleusSpec(object):
0010
0011 def __init__(self, name):
0012 self.name = name
0013 self.allPandaSites = []
0014 self.allDdmEndPoints = {}
0015 self.all_ddm_endpoints_in = {}
0016 self.state = None
0017 self.bareNucleus = None
0018 self.secondaryNucleus = None
0019 self.nucleus = True
0020 self.default_ddm_endpoint_out = None
0021
0022
0023 def add(self, siteName, ddmSpecDict, ddmSpecDictForInput=None):
0024 if siteName not in self.allPandaSites:
0025 self.allPandaSites.append(siteName)
0026
0027 for scope in ddmSpecDict:
0028 ddmSpec = ddmSpecDict[scope]
0029 for localEndPoint in ddmSpec.getLocalEndPoints():
0030 if localEndPoint not in self.allDdmEndPoints:
0031 self.allDdmEndPoints[localEndPoint] = ddmSpec.getEndPoint(localEndPoint)
0032 if ddmSpecDictForInput is not None:
0033
0034 for scope in ddmSpecDictForInput:
0035 ddmSpec = ddmSpecDictForInput[scope]
0036 for localEndPoint in ddmSpec.getAllEndPoints():
0037 if localEndPoint not in self.all_ddm_endpoints_in:
0038 self.all_ddm_endpoints_in[localEndPoint] = ddmSpec.getEndPoint(localEndPoint)
0039
0040
0041 def isAssociatedPandaSite(self, siteName):
0042 return siteName in self.allPandaSites
0043
0044
0045 def isAssociatedEndpoint(self, endPoint):
0046 return endPoint in self.allDdmEndPoints
0047
0048
0049 def is_associated_for_input(self, endpoint):
0050 return endpoint in self.all_ddm_endpoints_in
0051
0052
0053 def getEndpoint(self, endpoint):
0054 try:
0055 if endpoint in self.allDdmEndPoints:
0056 return self.allDdmEndPoints[endpoint]
0057 return self.all_ddm_endpoints_in[endpoint]
0058 except Exception:
0059 return None
0060
0061 def getAssociatedEndpoint(self, pattern):
0062 pattern = pattern.split("/")[-1]
0063 if pattern.startswith("dst:"):
0064 pattern = pattern.split(":")[-1]
0065
0066 if pattern in self.allDdmEndPoints:
0067 return self.allDdmEndPoints[pattern]
0068
0069 for endpoint_name in self.allDdmEndPoints:
0070 if re.search(pattern, endpoint_name) is not None:
0071 return self.allDdmEndPoints[endpoint_name]
0072
0073 pattern_without_vo = re.sub("ATLAS", "", pattern)
0074
0075 if self.allDdmEndPoints[endpoint_name]["type"] == pattern_without_vo:
0076 return self.allDdmEndPoints[endpoint_name]
0077
0078 return None
0079
0080
0081 def getOnePandaSite(self):
0082 if len(self.allPandaSites) > 0:
0083 return self.allPandaSites[0]
0084 return None
0085
0086
0087 def set_bare_nucleus_mode(self, mode):
0088 self.bareNucleus = mode
0089
0090
0091 def get_bare_nucleus_mode(self):
0092 return self.bareNucleus
0093
0094
0095 def set_secondary_nucleus(self, nucleus):
0096 self.secondaryNucleus = nucleus
0097
0098
0099 def get_secondary_nucleus(self):
0100 return self.secondaryNucleus
0101
0102
0103 def set_satellite(self):
0104 self.nucleus = False
0105
0106
0107 def is_nucleus(self):
0108 return self.nucleus
0109
0110
0111 def set_default_endpoint_out(self, rse):
0112 self.default_ddm_endpoint_out = rse
0113
0114
0115 def get_default_endpoint_out(self):
0116 return self.getEndpoint(self.default_ddm_endpoint_out)