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 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__
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__