Esempio n. 1
0
class ServiceStats_Command(Command):
    """
  The ServiceStats_Command class is a command class to know about
  present services stats
  """

    def doCommand(self):
        """
    Uses :meth:`DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.getServiceStats`

    :params:
      :attr:`args`: a tuple
        - args[1]: a ValidRes

        - args[0]: should be the name of the Site

    :returns:
      {'Active':xx, 'Probing':yy, 'Banned':zz, 'Total':xyz}
    """
        super(ServiceStats_Command, self).doCommand()

        if self.client is None:
            from DIRAC.ResourceStatusSystem.Client.ResourceStatusClient import ResourceStatusClient

            self.client = ResourceStatusClient(timeout=self.timeout)

        try:
            res = self.client.getServiceStats(self.args[0], self.args[1])
        except:
            gLogger.exception("Exception when calling ResourceStatusClient for %s %s" % (self.args[0], self.args[1]))
            return {"Result": "Unknown"}

        return {"Result": res}

    doCommand.__doc__ = Command.doCommand.__doc__ + doCommand.__doc__
Esempio n. 2
0
class ServiceStats_Command( Command ):
  """
  The ServiceStats_Command class is a command class to know about
  present services stats
  """

  def doCommand( self ):
    """
    Uses :meth:`DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.getServiceStats`

    :params:
      :attr:`args`: a tuple
        - args[1]: a ValidRes

        - args[0]: should be the name of the Site

    :returns:
      {'Active':xx, 'Probing':yy, 'Banned':zz, 'Total':xyz}
    """
    super( ServiceStats_Command, self ).doCommand()

    if self.client is None:
      from DIRAC.ResourceStatusSystem.Client.ResourceStatusClient import ResourceStatusClient
      self.client = ResourceStatusClient( timeout = self.timeout )

    try:
      res = self.client.getServiceStats( self.args[0], self.args[1] )['Value']
    except:
      gLogger.exception( "Exception when calling ResourceStatusClient for %s %s" % ( self.args[0], self.args[1] ) )
      return {'Result':'Unknown'}

    return {'Result':res}

  doCommand.__doc__ = Command.doCommand.__doc__ + doCommand.__doc__
Esempio n. 3
0
class ServiceStatsCommand(Command):
    """
  The ServiceStats_Command class is a command class to know about
  present services stats
  """
    def __init__(self, args=None, clients=None):

        super(ServiceStatsCommand, self).__init__(args, clients)

        if 'ResourceStatusClient' in self.apis:
            self.rsClient = self.apis['ResourceStatusClient']
        else:
            self.rsClient = ResourceStatusClient()

    def doCommand(self):
        """
    Uses :meth:`DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.getServiceStats`

    :params:
      :attr:`args`: a tuple
        - args[1]: a ValidElement

        - args[0]: should be the name of the Site

    :returns:
      {'Active':xx, 'Probing':yy, 'Banned':zz, 'Total':xyz}
    """

        #    try:

        res = self.rsClient.getServiceStats(
            self.args[1]
        )  #, statusType = None )# self.args[0], self.args[1] )['Value']
        if not res['OK']:
            return self.returnERROR(res)
#    except Exception, e:
#      _msg = '%s (%s): %s' % ( self.__class__.__name__, self.args, e )
#      gLogger.exception( _msg )
#      return S_ERROR( _msg )

        return res
Esempio n. 4
0
class ServiceStatsCommand( Command ):
  """
  The ServiceStats_Command class is a command class to know about
  present services stats
  """

  def __init__( self, args = None, clients = None ):
    
    super( ServiceStatsCommand, self ).__init__( args, clients )
    
    if 'ResourceStatusClient' in self.apis:
      self.rsClient = self.apis[ 'ResourceStatusClient' ]
    else:
      self.rsClient = ResourceStatusClient()   

  def doCommand( self ):
    """
    Uses :meth:`DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.getServiceStats`

    :params:
      :attr:`args`: a tuple
        - args[1]: a ValidElement

        - args[0]: should be the name of the Site

    :returns:
      {'Active':xx, 'Probing':yy, 'Banned':zz, 'Total':xyz}
    """

#    try:
      
    res = self.rsClient.getServiceStats( self.args[1] )#, statusType = None )# self.args[0], self.args[1] )['Value']
    if not res[ 'OK' ]:
      return self.returnERROR( res )
#    except Exception, e:
#      _msg = '%s (%s): %s' % ( self.__class__.__name__, self.args, e )
#      gLogger.exception( _msg )
#      return S_ERROR( _msg )

    return res