def export_getCachedDowntimes(self, element, elementType, name, severity): if elementType == 'StorageElement': res = getSEHosts(name) if not res['OK']: return res names = res['Value'] else: names = name columns = [ 'Element', 'Name', 'StartDate', 'EndDate', 'Severity', 'Description', 'Link' ] res = rmClient.selectDowntimeCache(element=element, name=names, severity=severity, meta={'columns': columns}) if not res['OK']: return res result = S_OK(res['Value']) result['Columns'] = columns return result
def export_getCachedDowntimes(self, element, elementType, name, severity): if elementType == "StorageElement": res = getSEHosts(name) if not res["OK"]: return res names = res["Value"] else: names = name columns = [ "Element", "Name", "StartDate", "EndDate", "Severity", "Description", "Link" ] res = self.rmClient.selectDowntimeCache(element=element, name=names, severity=severity, meta={"columns": columns}) if not res["OK"]: self.log.error("Error selecting downtime cache", res["Message"]) return res result = S_OK(res["Value"]) result["Columns"] = columns return result
def export_getDowntimes(self, element, elementType, name): if elementType == 'StorageElement': res = getSEHosts(name) if not res['OK']: return res names = res['Value'] else: names = name return rmClient.selectDowntimeCache(element=element, name=names, meta={'columns': ['StartDate', 'EndDate', 'Link', 'Description', 'Severity']})
def export_getDowntimes(cls, element, elementType, name): if elementType == "StorageElement": res = getSEHosts(name) if not res["OK"]: return res names = res["Value"] else: names = name return cls.rmClient.selectDowntimeCache( element=element, name=names, meta={ "columns": ["StartDate", "EndDate", "Link", "Description", "Severity"] })
def getDIRACSesForHostName(hostName): """ returns the DIRAC SEs that share the same hostName :param str hostName: host name, e.g. 'storm-fe-lhcb.cr.cnaf.infn.it' :return: S_OK with list of DIRAC SE names, or S_ERROR """ seNames = DMSHelpers().getStorageElements() resultDIRACSEs = [] for seName in seNames: res = getSEHosts(seName) if not res['OK']: return res if hostName in res['Value']: resultDIRACSEs.extend(seName) return S_OK(resultDIRACSEs)
def _prepareCommand(self): """ DowntimeCommand requires four arguments: - name : <str> - element : Site / Resource - elementType: <str> If the elements are Site(s), we need to get their GOCDB names. They may not have, so we ignore them if they do not have. """ if 'name' not in self.args: return S_ERROR('"name" not found in self.args') elementName = self.args['name'] if 'element' not in self.args: return S_ERROR('"element" not found in self.args') element = self.args['element'] if 'elementType' not in self.args: return S_ERROR('"elementType" not found in self.args') elementType = self.args['elementType'] if element not in ['Site', 'Resource']: return S_ERROR('element is neither Site nor Resource') hours = None if 'hours' in self.args: hours = self.args['hours'] gOCDBServiceType = None # Transform DIRAC site names into GOCDB topics if element == 'Site': gocSite = getGOCSiteName(elementName) if not gocSite[ 'OK']: # The site is most probably is not a grid site - not an issue, of course pass # so, elementName remains unchanged else: elementName = gocSite['Value'] # The DIRAC se names mean nothing on the grid, but their hosts do mean. elif elementType == 'StorageElement': # for SRM and SRM only, we need to distinguish if it's tape or disk # if it's not SRM, then gOCDBServiceType will be None (and we'll use them all) try: se = StorageElement(elementName) seOptions = se.options seProtocols = set(se.localAccessProtocolList) | set( se.localWriteProtocolList) except AttributeError: # Sometimes the SE can't be instantiated properly self.log.error("Failure instantiating StorageElement object", elementName) return S_ERROR("Failure instantiating StorageElement") if 'SEType' in seOptions and 'srm' in seProtocols: # Type should follow the convention TXDY seType = seOptions['SEType'] diskSE = re.search('D[1-9]', seType) is not None tapeSE = re.search('T[1-9]', seType) is not None if tapeSE: gOCDBServiceType = "srm.nearline" elif diskSE: gOCDBServiceType = "srm" res = getSEHosts(elementName) if not res['OK']: return res seHosts = res['Value'] if not seHosts: return S_ERROR('No seHost(s) for %s' % elementName) elementName = seHosts # in this case it will return a list, because there might be more than one host only elif elementType in ['FTS', 'FTS3']: gOCDBServiceType = 'FTS' # WARNING: this method presupposes that the server is an FTS3 type gocSite = getGOCFTSName(elementName) if not gocSite['OK']: self.log.warn("FTS not in Resources/FTSEndpoints/FTS3 ?", elementName) else: elementName = gocSite['Value'] return S_OK((element, elementName, hours, gOCDBServiceType))
def _prepareCommand(self): """ DowntimeCommand requires four arguments: - name : <str> - element : Site / Resource - elementType: <str> If the elements are Site(s), we need to get their GOCDB names. They may not have, so we ignore them if they do not have. """ if "name" not in self.args: return S_ERROR('"name" not found in self.args') elementName = self.args["name"] if "element" not in self.args: return S_ERROR('"element" not found in self.args') element = self.args["element"] if "elementType" not in self.args: return S_ERROR('"elementType" not found in self.args') elementType = self.args["elementType"] if element not in ["Site", "Resource"]: return S_ERROR("element is neither Site nor Resource") hours = None if "hours" in self.args: hours = self.args["hours"] gOCDBServiceType = None # Transform DIRAC site names into GOCDB topics if element == "Site": gocSite = getGOCSiteName(elementName) if not gocSite[ "OK"]: # The site is most probably is not a grid site - not an issue, of course pass # so, elementName remains unchanged else: elementName = gocSite["Value"] # The DIRAC se names mean nothing on the grid, but their hosts do mean. elif elementType == "StorageElement": # for SRM and SRM only, we need to distinguish if it's tape or disk # if it's not SRM, then gOCDBServiceType will be None (and we'll use them all) try: se = StorageElement(elementName) seOptions = se.options seProtocols = set(se.localAccessProtocolList) | set( se.localWriteProtocolList) except AttributeError: # Sometimes the SE can't be instantiated properly self.log.error("Failure instantiating StorageElement object", elementName) return S_ERROR("Failure instantiating StorageElement") if "SEType" in seOptions and "srm" in seProtocols: # Type should follow the convention TXDY seType = seOptions["SEType"] diskSE = re.search("D[1-9]", seType) is not None tapeSE = re.search("T[1-9]", seType) is not None if tapeSE: gOCDBServiceType = "srm.nearline" elif diskSE: gOCDBServiceType = "srm" res = getSEHosts(elementName) if not res["OK"]: return res seHosts = res["Value"] if not seHosts: return S_ERROR("No seHost(s) for %s" % elementName) elementName = seHosts # in this case it will return a list, because there might be more than one host only elif elementType in ["FTS", "FTS3"]: gOCDBServiceType = "FTS" # WARNING: this method presupposes that the server is an FTS3 type gocSite = getGOCFTSName(elementName) if not gocSite["OK"]: self.log.warn("FTS not in Resources/FTSEndpoints/FTS3 ?", elementName) else: elementName = gocSite["Value"] elif elementType == "ComputingElement": res = getCESiteMapping(elementName) if not res["OK"]: return res siteName = res["Value"][elementName] ceType = gConfig.getValue( cfgPath("Resources", "Sites", siteName.split(".")[0], siteName, "CEs", elementName, "CEType")) if ceType == "HTCondorCE": gOCDBServiceType = "org.opensciencegrid.htcondorce" elif ceType == "ARC": gOCDBServiceType = "ARC-CE" return S_OK((element, elementName, hours, gOCDBServiceType))