def getClass(cls, *args): """ if emulator flag is set return emulator class otherwise return original class. if emulator flag is not initialized and EMULATOR_CONFIG environment variable is set, r """ emFlag = getattr(EmulatorHelper, cls.__name__) if emFlag: return EmulatorHelper.getEmulatorClass(cls.__name__, *args) elif emFlag == None: try: from WMQuality.Emulators import emulatorSwitch except: # if emulatorSwitch class is not imported don't use # emulator setattr(EmulatorHelper, cls.__name__, False) else: envFlag = emulatorSwitch(cls.__name__) setattr(EmulatorHelper, cls.__name__, envFlag) if envFlag: return EmulatorHelper.getEmulatorClass(cls.__name__, *args) # if emulator flag is False, return original class return cls
callname = 'request' return self._getResult(callname, args=args, verb="GET") def getAssignment(self, teamName=None, request=None): args = {} args['teamName'] = teamName args['request'] = request callname = 'assignment' return self._getResult(callname, args=args, verb="GET") def postAssignment(self, requestName, prodAgentUrl=None): args = {} callname = 'assignment/%s/%s' % (requestName, str(prodAgentUrl)) return self._getResult(callname, args=args, verb="POST") def putTeam(self, team): args = {} callname = 'team/%s' % team return self._getResult(callname, args=args, verb="PUT") # TODO: find the better way to handle emulation: # hacky code: swap the namespace if emulator config is set from WMQuality.Emulators import emulatorSwitch if emulatorSwitch("RequestManager"): from WMQuality.Emulators.RequestManagerClient.RequestManager import RequestManager
callname = 'request' return self._getResult(callname, args = args, verb = "GET") def getAssignment(self, teamName = None, request = None): args = {} args['teamName'] = teamName args['request'] = request callname = 'assignment' return self._getResult(callname, args = args, verb = "GET") def postAssignment(self, requestName, prodAgentUrl = None): args = {} callname = 'assignment/%s/%s' % (requestName, str(prodAgentUrl)) return self._getResult(callname, args = args, verb = "POST") def putTeam(self, team): args = {} callname = 'team/%s' % team return self._getResult(callname, args = args, verb = "PUT") # TODO: find the better way to handle emulation: # hacky code: swap the namespace if emulator config is set from WMQuality.Emulators import emulatorSwitch if emulatorSwitch("RequestManager"): from WMQuality.Emulators.RequestManagerClient.RequestManager import RequestManager
msg += "%s\n" % formatEx(ex) raise DBSReaderError(msg) if blocks == []: return None pathname = blocks[-1].get('Path', None) return pathname def checkDatasetPath(self, pathName): """ _checkDatasetPath_ """ if pathName in ("", None): raise DBSReaderError("Invalid Dataset Path name: => %s <=" % pathName) def checkBlockName(self, blockName): """ _checkBlockName_ """ if blockName in ("", "*", None): raise DBSReaderError("Invalid Block name: => %s <=" % blockName) # TODO: find the better way to handle emulation: # hacky code: swap the namespace if emulator config is set from WMQuality.Emulators import emulatorSwitch if emulatorSwitch("DBSReader"): from WMQuality.Emulators.DBSClient.DBSReader import DBSReader
raise DBSReaderError(msg) if blocks == []: return None pathname = blocks[-1].get('Path', None) return pathname def checkDatasetPath(self, pathName): """ _checkDatasetPath_ """ if pathName in ("", None): raise DBSReaderError("Invalid Dataset Path name: => %s <=" % pathName) def checkBlockName(self, blockName): """ _checkBlockName_ """ if blockName in ("", "*", None): raise DBSReaderError("Invalid Block name: => %s <=" % blockName) # TODO: find the better way to handle emulation: # hacky code: swap the namespace if emulator config is set from WMQuality.Emulators import emulatorSwitch if emulatorSwitch("DBSReader"): from WMQuality.Emulators.DBSClient.DBSReader import DBSReader
Convert SE to Name """ names = [] output = self.getNodeMap() nodeList = output['phedex']['node'] for node in nodeList: if node['se'] == se: names.append(node['name']) return names def getNodeSE(self, name): """ _getNodeSE_ Convert Name to SE """ output = self.getNodeMap() nodeList = output['phedex']['node'] for node in nodeList: if node['name'] == name: return node['se'] return None # TODO: find the better way to handle emulation: # hacky code: swap the namespace if emulator config is set from WMQuality.Emulators import emulatorSwitch if emulatorSwitch("PhEDEx"): from WMQuality.Emulators.PhEDExClient.PhEDEx import PhEDEx
return theList def phEDExNodetocmsName(self, node): """ Convert PhEDEx node name to cms site """ # api doesn't work at the moment - so reverse engineer # first strip special endings and check with cmsNametoPhEDExNode # if this fails (to my knowledge no node does fail) do a full lookup name = node.replace('_MSS', '').replace('_Buffer', '').replace('_Export', '') return name # Disable cross-check until following bug fixed. # https://savannah.cern.ch/bugs/index.php?67044 # if node in self.cmsNametoPhEDExNode(name): # return name # # # As far as i can tell there is no way to get a full listing, would # # need to call CMSNametoPhEDExNode?cms_name= but can't find a way to do # # that. So simply raise an error # raise ValueError, "Unable to find CMS name for \'%s\'" % node # TODO: find the better way to handle emulation: # hacky code: swap the namespace if emulator config is set from WMQuality.Emulators import emulatorSwitch if emulatorSwitch("SiteDB"): from WMQuality.Emulators.SiteDBClient.SiteDB import SiteDBJSON