def doCommand(self): """ Return getJobsEff from Jobs Client :attr:`args`: - args[0]: string: should be a ValidRes - args[1]: string: should be the name of the ValidRes returns: { 'JobsEff': X } """ super(JobsEff_Command, self).doCommand() if self.client is None: from DIRAC.ResourceStatusSystem.Client.JobsClient import JobsClient self.client = JobsClient() try: res = self.client.getJobsEff(self.args[0], self.args[1], self.args[2]) except: gLogger.exception("Exception when calling JobsClient") return {'Result': 'Unknown'} return {'Result': res}
def doCommand(self, RSClientIn=None): """ Returns simple jobs 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(JobsEffSimple_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( "JobsEffSimple_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'): name = self.args[1] granularity = self.args[0] else: raise InvalidRes, where(self, self.doCommand) if self.client is None: from DIRAC.ResourceStatusSystem.Client.JobsClient import JobsClient self.client = JobsClient() try: res = self.client.getJobsSimpleEff(name, timeout=self.timeout) if res == None: return {'Result': 'Idle'} except: gLogger.exception("Exception when calling JobsClient 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)
class SystemCharge_Command(Command): def doCommand(self): """ Returns last hour system charge, and the system charge of an hour before returns: { 'LastHour': n_lastHour 'anHourBefore': n_anHourBefore } """ super(SystemCharge_Command, self).doCommand() if self.client is None: from DIRAC.ResourceStatusSystem.Client.JobsClient import JobsClient self.client = JobsClient() try: res = self.client.getSystemCharge() except: gLogger.exception("Exception when calling JobsClient") return {'Result': 'Unknown'} return {'Result': res} doCommand.__doc__ = Command.doCommand.__doc__ + doCommand.__doc__
class JobsStats_Command(Command): def doCommand(self): """ Return getJobStats from Jobs Client :attr:`args`: - args[0]: string: should be a ValidRes - args[1]: string: should be the name of the ValidRes returns: { 'MeanProcessedJobs': X } """ super(JobsStats_Command, self).doCommand() if self.client is None: from DIRAC.ResourceStatusSystem.Client.JobsClient import JobsClient self.client = JobsClient() try: res = self.client.getJobsStats(self.args[0], self.args[1], self.args[2]) except: gLogger.exception("Exception when calling JobsClient for %s %s" % (self.args[0], self.args[1])) return {'Result': 'Unknown'} return {'Result': res} doCommand.__doc__ = Command.doCommand.__doc__ + doCommand.__doc__
class SystemCharge_Command(Command): def doCommand(self): """ Returns last hour system charge, and the system charge of an hour before returns: { 'LastHour': n_lastHour 'anHourBefore': n_anHourBefore } """ super(SystemCharge_Command, self).doCommand() if self.client is None: from DIRAC.ResourceStatusSystem.Client.JobsClient import JobsClient self.client = JobsClient() try: res = self.client.getSystemCharge() except: gLogger.exception("Exception when calling JobsClient") return {'Result':'Unknown'} return {'Result':res} doCommand.__doc__ = Command.doCommand.__doc__ + doCommand.__doc__
def doCommand(self): """ Return getJobsEff from Jobs Client :attr:`args`: - args[0]: string: should be a ValidRes - args[1]: string: should be the name of the ValidRes returns: { 'JobsEff': X } """ super(JobsEff_Command, self).doCommand() if self.client is None: from DIRAC.ResourceStatusSystem.Client.JobsClient import JobsClient self.client = JobsClient() try: res = self.client.getJobsEff(self.args[0], self.args[1], self.args[2]) except: gLogger.exception("Exception when calling JobsClient") return {'Result':'Unknown'} return {'Result':res}
class JobsStats_Command(Command): def doCommand(self): """ Return getJobStats from Jobs Client :attr:`args`: - args[0]: string: should be a ValidRes - args[1]: string: should be the name of the ValidRes returns: { 'MeanProcessedJobs': X } """ super(JobsStats_Command, self).doCommand() if self.client is None: from DIRAC.ResourceStatusSystem.Client.JobsClient import JobsClient self.client = JobsClient() try: res = self.client.getJobsStats(self.args[0], self.args[1], self.args[2]) except: gLogger.exception("Exception when calling JobsClient for %s %s" %(self.args[0], self.args[1])) return {'Result':'Unknown'} return {'Result':res} doCommand.__doc__ = Command.doCommand.__doc__ + doCommand.__doc__
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, sites=None): """ Returns simple jobs efficiency for all the sites in input. :params: :attr:`sites`: list of site names (when not given, take every site) :returns: {'SiteName': {'JE_S': 'Good'|'Fair'|'Poor'|'Idle'|'Bad'}, ...} """ if self.client is None: from DIRAC.ResourceStatusSystem.Client.JobsClient import JobsClient self.client = JobsClient() 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.getJobsSimpleEff(sites, self.RPC) if res is None: res = [] except: gLogger.exception("Exception when calling JobsClient.") return {} resToReturn = {} for site in res: resToReturn[site] = {'JE_S': res[site]} return resToReturn
class JobsEffSimple_Command(Command): def doCommand(self, RSClientIn = None): """ Returns simple jobs 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 (JobsEffSimple_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("JobsEffSimple_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'): name = self.args[1] granularity = self.args[0] else: raise InvalidRes, where(self, self.doCommand) if self.client is None: from DIRAC.ResourceStatusSystem.Client.JobsClient import JobsClient self.client = JobsClient() try: res = self.client.getJobsSimpleEff(name, timeout = self.timeout) if res == None: return {'Result':'Idle'} except: gLogger.exception("Exception when calling JobsClient for %s %s" %(granularity, name)) return {'Result':'Unknown'} return {'Result':res[name]} doCommand.__doc__ = Command.doCommand.__doc__ + doCommand.__doc__
class JobsEffSimpleEveryOne_Command( Command ): def doCommand( self, sites = None ): """ Returns simple jobs efficiency for all the sites in input. :params: :attr:`sites`: list of site names (when not given, take every site) :returns: {'SiteName': {'JE_S': 'Good'|'Fair'|'Poor'|'Idle'|'Bad'}, ...} """ if self.client is None: from DIRAC.ResourceStatusSystem.Client.JobsClient import JobsClient self.client = JobsClient() 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.getJobsSimpleEff( sites, self.RPC ) if res is None: res = [] except: gLogger.exception( "Exception when calling JobsClient." ) return {} resToReturn = {} for site in res: resToReturn[site] = {'JE_S': res[site]} return resToReturn doCommand.__doc__ = Command.doCommand.__doc__ + doCommand.__doc__