def doCommand(self, RSClientIn=None): """ Returns simple pilots efficiency :attr:`args`: - args[0]: string - should be a ValidRes - args[1]: string - should be the name of the ValidRes returns: { 'Result': 'Good'|'Fair'|'Poor'|'Idle'|'Bad' } """ super(PilotsEffSimple_Command, self).doCommand() if self.args[0] in ('Service', 'Services'): if RSClientIn is not None: rsc = RSClientIn else: from DIRAC.ResourceStatusSystem.Client.ResourceStatusClient import ResourceStatusClient rsc = ResourceStatusClient() try: name = rsc.getGeneralName(self.args[0], self.args[1], 'Site')['Value'][0] except: gLogger.error( "PilotsEffSimple_Command: can't get a general name for %s %s" % (self.args[0], self.args[1])) return {'Result': 'Unknown'} granularity = 'Site' elif self.args[0] in ('Site', 'Sites', 'Resource', 'Resources'): name = self.args[1] granularity = self.args[0] else: raise InvalidRes, where(self, self.doCommand) if self.client is None: from DIRAC.ResourceStatusSystem.Client.PilotsClient import PilotsClient self.client = PilotsClient() try: res = self.client.getPilotsSimpleEff(granularity, name, timeout=self.timeout) if res is None: return {'Result': 'Idle'} if res[name] is None: return {'Result': 'Idle'} except: gLogger.exception("Exception when calling PilotsClient for %s %s" % (granularity, name)) return {'Result': 'Unknown'} return {'Result': res[name]}
def setCommandClient(self, comm, cObj, RPCWMSAdmin=None, RPCAccounting=None): client = None if comm == 'JobsEffSimpleEveryOne_Command': from DIRAC.ResourceStatusSystem.Client.JobsClient import JobsClient client = JobsClient() cObj.setRPC(RPCWMSAdmin) elif comm == 'PilotsEffSimpleEverySites_Command': from DIRAC.ResourceStatusSystem.Client.PilotsClient import PilotsClient client = PilotsClient() cObj.setRPC(RPCWMSAdmin) elif comm in ('TransferQualityEverySEs_Command', 'TransferQualityEverySEsSplitted_Command'): from DIRAC.AccountingSystem.Client.ReportsClient import ReportsClient client = ReportsClient(rpcClient=RPCAccounting) cObj.setRPC(RPCAccounting) cObj.setClient(client)
def setUp( self ): self.mockRSS = Mock() self.RSCli = ResourceStatusClient( serviceIn = self.mockRSS ) self.RMCli = ResourceManagementClient( serviceIn = self.mockRSS ) self.PilotsCli = PilotsClient() self.JobsCli = JobsClient()
def doCommand(self): """ Return getPilotsEff from Pilots Client """ super(PilotsEff_Command, self).doCommand() if self.client is None: from DIRAC.ResourceStatusSystem.Client.PilotsClient import PilotsClient self.client = PilotsClient() try: res = self.client.getPilotsEff(self.args[0], self.args[1], self.args[2]) except: gLogger.exception("Exception when calling PilotsClient for %s %s" % (self.args[0], self.args[1])) return {'Result': 'Unknown'} return {'Result': res}
def doCommand(self, sites=None): """ Returns simple pilots efficiency for all the sites and resources in input. :params: :attr:`sites`: list of site names (when not given, take every site) :returns: {'SiteName': {'PE_S': 'Good'|'Fair'|'Poor'|'Idle'|'Bad'} ...} """ if self.client is None: from DIRAC.ResourceStatusSystem.Client.PilotsClient import PilotsClient self.client = PilotsClient() if sites is None: # from DIRAC.Core.DISET.RPCClient import RPCClient RPC = RPCClient("ResourceStatus/ResourceStatus") sites = RPC.getSitesList() if not sites['OK']: raise RSSException, where( self, self.doCommand) + " " + sites['Message'] else: sites = sites['Value'] if self.RPC is None: # from DIRAC.Core.DISET.RPCClient import RPCClient self.RPC = RPCClient("WorkloadManagement/WMSAdministrator") try: res = self.client.getPilotsSimpleEff('Site', sites, None, self.RPC) if res is None: res = [] except: gLogger.exception("Exception when calling PilotsClient.") return {} resToReturn = {} for site in res: resToReturn[site] = {'PE_S': res[site]} return resToReturn
class PilotsEffSimple_Command(Command): def doCommand(self, RSClientIn = None): """ Returns simple pilots efficiency :attr:`args`: - args[0]: string - should be a ValidRes - args[1]: string - should be the name of the ValidRes returns: { 'Result': 'Good'|'Fair'|'Poor'|'Idle'|'Bad' } """ super(PilotsEffSimple_Command, self).doCommand() if self.args[0] in ('Service', 'Services'): if RSClientIn is not None: rsc = RSClientIn else: from DIRAC.ResourceStatusSystem.Client.ResourceStatusClient import ResourceStatusClient rsc = ResourceStatusClient() try: name = rsc.getGeneralName(self.args[0], self.args[1], 'Site')[0] except: gLogger.error("PilotsEffSimple_Command: can't get a general name for %s %s" %(self.args[0], self.args[1])) return {'Result':'Unknown'} granularity = 'Site' elif self.args[0] in ('Site', 'Sites', 'Resource', 'Resources'): name = self.args[1] granularity = self.args[0] else: raise InvalidRes, where(self, self.doCommand) if self.client is None: from DIRAC.ResourceStatusSystem.Client.PilotsClient import PilotsClient self.client = PilotsClient() try: res = self.client.getPilotsSimpleEff(granularity, name, timeout = self.timeout) if res is None: return {'Result':'Idle'} if res[name] is None: return {'Result':'Idle'} except: gLogger.exception("Exception when calling PilotsClient for %s %s" %(granularity, name)) return {'Result':'Unknown'} return {'Result':res[name]} doCommand.__doc__ = Command.doCommand.__doc__ + doCommand.__doc__
class PilotsEffSimpleEverySites_Command( Command ): def doCommand( self, sites = None ): """ Returns simple pilots efficiency for all the sites and resources in input. :params: :attr:`sites`: list of site names (when not given, take every site) :returns: {'SiteName': {'PE_S': 'Good'|'Fair'|'Poor'|'Idle'|'Bad'} ...} """ if self.client is None: from DIRAC.ResourceStatusSystem.Client.PilotsClient import PilotsClient self.client = PilotsClient() if sites is None: # from DIRAC.Core.DISET.RPCClient import RPCClient RPC = RPCClient( "ResourceStatus/ResourceStatus" ) sites = RPC.getSitesList() if not sites['OK']: raise RSSException, where( self, self.doCommand ) + " " + sites['Message'] else: sites = sites['Value'] if self.RPC is None: # from DIRAC.Core.DISET.RPCClient import RPCClient self.RPC = RPCClient( "WorkloadManagement/WMSAdministrator" ) try: res = self.client.getPilotsSimpleEff( 'Site', sites, None, self.RPC ) if res is None: res = [] except: gLogger.exception( "Exception when calling PilotsClient." ) return {} resToReturn = {} for site in res: resToReturn[site] = {'PE_S': res[site]} return resToReturn doCommand.__doc__ = Command.doCommand.__doc__ + doCommand.__doc__
def doCommand(self): """ Return getPilotsEff from Pilots Client """ super(PilotsEff_Command, self).doCommand() if self.client is None: from DIRAC.ResourceStatusSystem.Client.PilotsClient import PilotsClient self.client = PilotsClient() try: res = self.client.getPilotsEff(self.args[0], self.args[1], self.args[2]) except: gLogger.exception("Exception when calling PilotsClient for %s %s" %(self.args[0], self.args[1])) return {'Result':'Unknown'} return {'Result':res}