示例#1
0
    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)
示例#2
0
    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}
示例#3
0
  def setUp( self ):

    self.mockRSS = Mock()

    self.RSCli = ResourceStatusClient( serviceIn = self.mockRSS )
    self.RMCli = ResourceManagementClient( serviceIn = self.mockRSS )
    self.PilotsCli = PilotsClient()
    self.JobsCli = JobsClient()
示例#4
0
    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 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
示例#6
0
    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}