当前位置: 首页>>代码示例>>Python>>正文


Python ResourceStatusClient.ResourceStatusClient类代码示例

本文整理汇总了Python中DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.ResourceStatusClient的典型用法代码示例。如果您正苦于以下问题:Python ResourceStatusClient类的具体用法?Python ResourceStatusClient怎么用?Python ResourceStatusClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ResourceStatusClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __getSelectionData

  def __getSelectionData(self):
    callback = {}
    lhcbGroup = credentials.getSelectedGroup()
    lhcbUser = str(credentials.getUsername())
    RPC = getRPCClient( "ResourceStatus/ResourceStatus" )
    client = ResourceStatusClient( serviceIn = RPC )
    if len(request.params) > 0:
      tmp = {}
      for i in request.params:
        tmp[i] = str(request.params[i])
      callback["extra"] = tmp
####
    result = client.getSitePresent( meta = { 'columns' : 'SiteName' } )
    if result["OK"]:
      sites = result["Value"]
      try:
        sites = list(sites)
      except Exception,x:
        gLogger.error("Exception during convertion to a list: %s" % str(x))
        sites = [] # Will return error on length check
      tier1 = gConfig.getValue("/Website/PreferredSites",[]) # Always return a list
      if len(sites)>0:
        tier1.reverse()
        tier1 = [[x] for x in tier1]
        sites = [x for x in sites if x not in tier1] # Removes sites which are in tier1 list
        for i in tier1:
          sites.insert(0,i)
        sites.insert(0,["All"])
      else:
        sites = [["Nothing to display"]]
开发者ID:DIRACGrid,项目名称:DIRACWeb,代码行数:30,代码来源:SiteGateway.py

示例2: __changeSiteStatus

  def __changeSiteStatus( self, site, comment, statusType, status, printOutput = False ):
    """
      Change the RSS status of the given site
    """
    result = self.__checkSiteIsValid( site )
    if not result['OK']:
      return result

    wmsAdmin = RPCClient( 'WorkloadManagement/WMSAdministrator' )
    result = wmsAdmin.allowSite( site, comment )
    if not result['OK']:
      return result
    
    rsc = ResourceStatusClient()
    proxyInfo = getProxyInfo()
    if not proxyInfo[ 'OK' ]:
      return proxyInfo
    userName = proxyInfo[ 'Value' ][ 'username' ]   
    
    tomorrow = datetime.utcnow().replace( microsecond = 0 ) + timedelta( days = 1 )
  
    result = rsc.modifyStatusElement( 'Site', 'Status', 
                                      name = site, 
                                      statusType = statusType,
                                      status     = status,
                                      reason     = comment,  
                                      tokenOwner = userName, 
                                      tokenExpiration = tomorrow )

    return result
开发者ID:graciani,项目名称:DIRAC,代码行数:30,代码来源:DiracAdmin.py

示例3: MonitoredStatus_Command

class MonitoredStatus_Command(Command):
    """
  The MonitoredStatus_Command class is a command class to know about
  monitored status.
  """

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

    :params:
      :attr:`args`: a tuple
        - `args[0]`: string - should be a ValidRes

        - `args[1]`: string - should be the name of the ValidRes

        - `args[2]`: optional string - a ValidRes (get status of THIS ValidRes
          for name in args[1], will call getGeneralName)

    :returns:
      {'MonitoredStatus': 'Active'|'Probing'|'Banned'}
    """
        super(MonitoredStatus_Command, self).doCommand()

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

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

        try:
            if len(self.args) == 3:
                if ValidRes.index(self.args[2]) >= ValidRes.index(self.args[0]):
                    raise InvalidRes, where(self, self.doCommand)
                toBeFound = self.client.getGeneralName(self.args[0], self.args[1], self.args[2])[0]
                statuses = self.client.getMonitoredStatus(self.args[2], toBeFound)
            else:
                toBeFound = self.args[1]
                statuses = self.client.getMonitoredStatus(self.args[0], toBeFound)

            if not statuses:
                gLogger.warn("No status found for %s" % toBeFound)
                return {"Result": "Unknown"}

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

        if len(statuses) == 1:
            res = statuses[0]
        else:
            i = 0
            for status in statuses:
                ind = ValidStatus.index(status)
                if ind > i:
                    i = ind
            res = ValidStatus[i]

        return {"Result": res}

    doCommand.__doc__ = Command.doCommand.__doc__ + doCommand.__doc__
开发者ID:roiser,项目名称:DIRAC,代码行数:60,代码来源:RS_Command.py

示例4: doCommand

  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]} 
开发者ID:KrzysztofCiba,项目名称:DIRAC,代码行数:51,代码来源:Pilots_Command.py

示例5: StorageElementsStats_Command

class StorageElementsStats_Command( Command ):
  """
  The StorageElementsStats_Command class is a command class to know about
  present storageElementss stats
  """

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

    :params:
      :attr:`args`: a tuple
        - `args[0]` should be in ['Site', 'Resource']

        - `args[1]` should be the name of the Site or Resource

    :returns:

    """
    super( StorageElementsStats_Command, self ).doCommand()

    if self.args[0] in ( 'Service', 'Services' ):
      granularity = 'Site'
      name = self.args[1].split( '@' )[1]
    elif self.args[0] in ( 'Site', 'Sites', 'Resource', 'Resources' ):
      granularity = self.args[0]
      name = self.args[1]
    else:
      raise InvalidRes, where( self, self.doCommand )

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

    try:
      resR = self.client.getStorageElementsStats( granularity, name, 'Read' )['Value']
      resW = self.client.getStorageElementsStats( granularity, name, 'Write' )['Value']
    except:
      gLogger.exception( "Exception when calling ResourceStatusClient for %s %s" % ( granularity, name ) )
      return {'Result':'Unknown'}

    res = {}
    for key in ValidStatus:
      res[ key ] = resR[ key ] + resW[ key ]

    return {'Result':res}

  doCommand.__doc__ = Command.doCommand.__doc__ + doCommand.__doc__
开发者ID:NathalieRauschmayr,项目名称:DIRAC,代码行数:48,代码来源:RS_Command.py

示例6: __init__

  def __init__( self, rsClient = None, rmClient = None ):

    self.GOCDBClient = GOCDBClient()
    self.rsClient = ResourceStatusClient()     if rsClient == None else rsClient
    self.rmClient = ResourceManagementClient() if rmClient == None else rmClient

    self.synclist = [ 'Sites', 'Resources', 'StorageElements', 'Services', 'RegistryUsers' ]
开发者ID:bmb,项目名称:DIRAC,代码行数:7,代码来源:Synchronizer.py

示例7: ResourceStats_Command

class ResourceStats_Command( Command ):
  """
  The ResourceStats_Command class is a command class to know about
  present resources stats
  """

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

    :params:
      :attr:`args`: a tuple
        - `args[0]` string, a ValidRes. Should be in ('Site', 'Service')

        - `args[1]` should be the name of the Site or Service

    :returns:

    """
    super( ResourceStats_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.getResourceStats( 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__
开发者ID:NathalieRauschmayr,项目名称:DIRAC,代码行数:34,代码来源:RS_Command.py

示例8: ServiceStats_Command

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__
开发者ID:NathalieRauschmayr,项目名称:DIRAC,代码行数:34,代码来源:RS_Command.py

示例9: initialize

  def initialize( self ):

    # Attribute defined outside __init__ 
    # pylint: disable-msg=W0201

    try:
      self.rsClient             = ResourceStatusClient()
      self.resourcesFreqs       = CS.getTypedDictRootedAtOperations( 'CheckingFreqs/ResourcesFreqs' )
      self.resourcesToBeChecked = Queue.Queue()
      self.resourceNamesInCheck = []

      self.maxNumberOfThreads = self.am_getOption( 'maxThreadsInPool', 1 )
      self.threadPool         = ThreadPool( self.maxNumberOfThreads,
                                            self.maxNumberOfThreads )
      if not self.threadPool:
        self.log.error( 'Can not create Thread Pool' )
        return S_ERROR( 'Can not create Thread Pool' )

      for _i in xrange( self.maxNumberOfThreads ):
        self.threadPool.generateJobAndQueueIt( self._executeCheck, args = ( None, ) )

      return S_OK()

    except Exception:
      errorStr = "RSInspectorAgent initialization"
      self.log.exception( errorStr )
      return S_ERROR( errorStr )
开发者ID:bmb,项目名称:DIRAC,代码行数:27,代码来源:RSInspectorAgent.py

示例10: RSPeriodsCommand

class RSPeriodsCommand( Command ):

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

  def doCommand( self ):
    """
    Return getPeriods from ResourceStatus Client

    - args[0] should be a ValidElement

    - args[1] should be the name of the ValidElement

    - args[2] should be the present status

    - args[3] are the number of hours requested
    """

#    try:
      
    res = self.rsClient.getPeriods( self.args[0], self.args[1], self.args[2], self.args[3] )
    
#    except Exception, e:
#      _msg = '%s (%s): %s' % ( self.__class__.__name__, self.args, e )
#      gLogger.exception( _msg )
#      return S_ERROR( _msg )

    return res
开发者ID:IgorPelevanyuk,项目名称:DIRAC,代码行数:34,代码来源:RSCommand.py

示例11: doCommand

    def doCommand(self):
        """
    Return getPeriods from ResourceStatus Client

    - args[0] should be a ValidRes

    - args[1] should be the name of the ValidRes

    - args[2] should be the present status

    - args[3] are the number of hours requested
    """
        super(RSPeriods_Command, self).doCommand()

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

            self.client = ResourceStatusClient()

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

        return {"Result": res}
开发者ID:roiser,项目名称:DIRAC,代码行数:26,代码来源:RS_Command.py

示例12: __init__

  def __init__( self, clients = None ):
    """ Constructor
    
    examples:
      >>> pep = PEP()
      >>> pep1 = PEP( { 'ResourceStatusClient' : ResourceStatusClient() } )
      >>> pep2 = PEP( { 'ResourceStatusClient' : ResourceStatusClient(), 'ClientY' : None } )
    
    :Parameters:
      **clients** - [ None, `dict` ]
        dictionary with clients to be used in the commands issued by the policies.
        If not defined, the commands will import them. It is a measure to avoid
        opening the same connection every time a policy is evaluated.
        
    """
   
    if clients is None:
      clients = {}
    
    # PEP uses internally two of the clients: ResourceStatusClient and ResouceManagementClient   
    if 'ResourceStatusClient' in clients:           
      self.rsClient = clients[ 'ResourceStatusClient' ]
    else:
      self.rsClient = ResourceStatusClient()
    if 'ResourceManagementClient' in clients:             
      self.rmClient = clients[ 'ResourceManagementClient' ]
    else: 
      self.rmClient = ResourceManagementClient()

    self.clients = clients
    # Pass to the PDP the clients that are going to be used on the Commands
    self.pdp     = PDP( clients )   
开发者ID:Kiyoshi-Hayasaka,项目名称:DIRAC,代码行数:32,代码来源:PEP.py

示例13: __init__

  def __init__(self, granularity, name, status_type, pdp_decision, **kw):
    ActionBase.__init__( self, granularity, name, status_type, pdp_decision, **kw )

    try:             self.rsClient = self.kw["Clients"][ 'ResourceStatusClient' ]
    except KeyError: self.rsClient = ResourceStatusClient()
    try:             self.rmClient = self.kw["Clients"][ 'ResourceManagementClient' ]
    except KeyError: self.rmClient = ResourceManagementClient()
开发者ID:bmb,项目名称:DIRAC,代码行数:7,代码来源:AlarmAction.py

示例14: getSiteMaskLogging

  def getSiteMaskLogging( self, site = None, printOutput = False ):
    """Retrieves site mask logging information.

       Example usage:

       >>> print diracAdmin.getSiteMaskLogging('LCG.AUVER.fr')
       {'OK': True, 'Value': }

       :returns: S_OK,S_ERROR
    """
    result = self.__checkSiteIsValid( site )
    if not result['OK']:
      return result
    
    rssClient = ResourceStatusClient()
    result = rssClient.selectStatusElement( 'Site', 'History', name = site, 
                                            statusType = 'ComputingAccess' )
    
    if not result['OK']:
      return result

    siteDict = {}
    for logTuple in result['Value']:
      status,reason,siteName,dateEffective,dateTokenExpiration,eType,sType,eID,lastCheckTime,author = logTuple
      result = getSiteFullNames( siteName )
      if not result['OK']:
        continue
      for sName in result['Value']:
        if site is None or (site and site == sName):
          siteDict.setdefault( sName, [] )
          siteDict[sName].append( (status,reason,dateEffective,author,dateTokenExpiration) )

    if printOutput:
      if site:
        print '\nSite Mask Logging Info for %s\n' % site
      else:
        print '\nAll Site Mask Logging Info\n'

      for site, tupleList in siteDict.items():
        if not site:
          print '\n===> %s\n' % site
        for tup in tupleList:
          print str( tup[0] ).ljust( 8 ) + str( tup[1] ).ljust( 20 ) + \
               '( ' + str( tup[2] ).ljust( len( str( tup[2] ) ) ) + ' )  "' + str( tup[3] ) + '"'
        print ' '
        
    return S_OK( siteDict )
开发者ID:graciani,项目名称:DIRAC,代码行数:47,代码来源:DiracAdmin.py

示例15: __init__

    def __init__(self, name, decisionParams, enforcementResult, singlePolicyResults, clients=None):

        super(LogStatusAction, self).__init__(name, decisionParams, enforcementResult, singlePolicyResults, clients)

        if clients is not None and "ResourceStatusClient" in clients:
            self.rsClient = clients["ResourceStatusClient"]
        else:
            self.rsClient = ResourceStatusClient()
开发者ID:DIRACGrid,项目名称:DIRAC,代码行数:8,代码来源:LogStatusAction.py


注:本文中的DIRAC.ResourceStatusSystem.Client.ResourceStatusClient.ResourceStatusClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。