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


Python Resources.getSites方法代码示例

本文整理汇总了Python中DIRAC.ConfigurationSystem.Client.Helpers.Resources.getSites方法的典型用法代码示例。如果您正苦于以下问题:Python Resources.getSites方法的具体用法?Python Resources.getSites怎么用?Python Resources.getSites使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DIRAC.ConfigurationSystem.Client.Helpers.Resources的用法示例。


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

示例1: doCommand

# 需要导入模块: from DIRAC.ConfigurationSystem.Client.Helpers import Resources [as 别名]
# 或者: from DIRAC.ConfigurationSystem.Client.Helpers.Resources import getSites [as 别名]
  def doCommand( self ):
    """ 
    Returns running and runned jobs, querying the WMSHistory  
    for the last self.args[0] hours 
        
    :params:
      :attr:`sites`: list of sites (when not given, take every sites)

    :returns:
      
    """

    if not 'hours' in self.args:
      return S_ERROR( 'Number of hours not specified' )
    hours = self.args[ 'hours' ]

    sites = None
    if 'sites' in self.args:
      sites = self.args[ 'sites' ] 
    if sites is None:      
#FIXME: pointing to the CSHelper instead     
#      sources = self.rsClient.getSite( meta = {'columns': 'SiteName'} )
#      if not sources[ 'OK' ]:
#        return sources 
#      sources = [ si[0] for si in sources[ 'Value' ] ]
      sites = Resources.getSites()      
      if not sites[ 'OK' ]:
        return sites
      sites = sites[ 'Value' ]
    
    if not sites:
      return S_ERROR( 'Sites is empty' )   

    fromD = datetime.utcnow() - timedelta( hours = hours )
    toD   = datetime.utcnow()

    runJobs = self.rClient.getReport( 'WMSHistory', 'NumberOfJobs', fromD, toD, 
                                       {}, 'Site')
    if not runJobs[ 'OK' ]:
      return runJobs 
    runJobs    = runJobs[ 'Value' ]
    
    if not 'data' in runJobs:
      return S_ERROR( 'Missing data key' )
    if not 'granularity' in runJobs:
      return S_ERROR( 'Missing granularity key' )
    
    singlePlots = {}
    
    for site, value in runJobs[ 'data' ].items():
      if site in sites:
        plot                  = {}
        plot[ 'data' ]        = { site: value }
        plot[ 'granularity' ] = runJobs[ 'granularity' ]
        singlePlots[ site ]   = plot
    
    return S_OK( singlePlots )

################################################################################
#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF
开发者ID:graciani,项目名称:DIRAC,代码行数:62,代码来源:AccountingCacheCommand.py

示例2: export_getSitesResources

# 需要导入模块: from DIRAC.ConfigurationSystem.Client.Helpers import Resources [as 别名]
# 或者: from DIRAC.ConfigurationSystem.Client.Helpers.Resources import getSites [as 别名]
 def export_getSitesResources( self, siteNames ):
   
   resources = Resources.Resources()
   
   if siteNames is None:
     siteNames = Resources.getSites()
     if not siteNames[ 'OK' ]:
       return siteNames
     siteNames = siteNames[ 'Value' ]
   
   if isinstance( siteNames, str ):
     siteNames = [ siteNames ]
   
   sitesRes = {}
   
   for siteName in siteNames:
     
     res = {}         
     res[ 'ces' ] = resources.getEligibleResources( 'Computing', { 'Site': siteName } )
     ses          = resources.getEligibleStorageElements( { 'Site': siteName } )
     sesHosts = CSHelpers.getStorageElementsHosts( ses )
     if not sesHosts[ 'OK' ]:
       return sesHosts
     res[ 'ses' ] = list( set( sesHosts[ 'Value' ] ) )
         
     sitesRes[ siteName ] = res
   
   return S_OK( sitesRes )
开发者ID:graciani,项目名称:DIRAC,代码行数:30,代码来源:PublisherHandler.py

示例3: getGOCSites

# 需要导入模块: from DIRAC.ConfigurationSystem.Client.Helpers import Resources [as 别名]
# 或者: from DIRAC.ConfigurationSystem.Client.Helpers.Resources import getSites [as 别名]
def getGOCSites(diracSites=None):

    # FIXME: THIS SHOULD GO INTO Resources HELPER

    if diracSites is None:
        diracSites = Resources.getSites()
        if not diracSites["OK"]:
            return diracSites
        diracSites = diracSites["Value"]

    gocSites = []

    for diracSite in diracSites:
        gocSite = getGOCSiteName(diracSite)
        if not gocSite["OK"]:
            continue
        gocSites.append(gocSite["Value"])

    return S_OK(list(set(gocSites)))
开发者ID:graciani,项目名称:DIRAC,代码行数:21,代码来源:CSHelpers.py

示例4: doMaster

# 需要导入模块: from DIRAC.ConfigurationSystem.Client.Helpers import Resources [as 别名]
# 或者: from DIRAC.ConfigurationSystem.Client.Helpers.Resources import getSites [as 别名]
  def doMaster( self ):
    '''
      Master method, which looks little bit spaguetti code, sorry !
      - It gets all Sites.
      - It gets all StorageElements
      
      As there is no bulk query, it compares with what we have on the database.
      It queries a portion of them.
    '''

    sites = Resources.getSites()
    if not sites[ 'OK' ]:
      return sites
    sites = sites[ 'Value' ]
  
    ses = self.resources.getEligibleStorageElements()
    if not ses[ 'OK' ]:
      return ses
    ses = ses[ 'Value' ]
      
    elementNames = sites + ses   

#    sourceQuery = self.rmClient.selectTransferCache( meta = { 'columns' : [ 'SourceName' ] } )
#    if not sourceQuery[ 'OK' ]:
#      return sourceQuery
#    sourceQuery = [ element[0] for element in sourceQuery[ 'Value' ] ]
#    
#    sourceElementsToQuery = list( set( elementNames ).difference( set( sourceQuery ) ) )
    gLogger.info( 'Processing %s' % ', '.join( elementNames ) )
 
    for metric in [ 'Quality', 'FailedTransfers' ]:
      for direction in [ 'Source', 'Destination' ]: 
        # 2 hours of window
        result = self.doNew( ( 2, elementNames, direction, metric )  ) 
        if not result[ 'OK' ]:
          self.metrics[ 'failed' ].append( result )
       
    return S_OK( self.metrics )
  
################################################################################
#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF
开发者ID:graciani,项目名称:DIRAC,代码行数:43,代码来源:TransferCommand.py

示例5: export_getSites

# 需要导入模块: from DIRAC.ConfigurationSystem.Client.Helpers import Resources [as 别名]
# 或者: from DIRAC.ConfigurationSystem.Client.Helpers.Resources import getSites [as 别名]
 def export_getSites( self ):  
   '''
     Returns list of all sites considered by RSS
   '''
   gLogger.info( 'getSites' )
   return Resources.getSites()
开发者ID:graciani,项目名称:DIRAC,代码行数:8,代码来源:PublisherHandler.py

示例6: doCommand

# 需要导入模块: from DIRAC.ConfigurationSystem.Client.Helpers import Resources [as 别名]
# 或者: from DIRAC.ConfigurationSystem.Client.Helpers.Resources import getSites [as 别名]
  def doCommand( self ):
    """
#    Returns simple pilots efficiency
#
#    :attr:`args`:
#        - args[0]: string - should be a ValidElement
#
#        - args[1]: string - should be the name of the ValidElement
#
#    returns:
#      {
#        'Result': 'Good'|'Fair'|'Poor'|'Idle'|'Bad'
#      }
    """

    if not 'element' in self.args:
      return self.returnERROR( S_ERROR( 'element is missing' ) )
    element = self.args[ 'element' ]    
   
    if not 'siteName' in self.args:
      return self.returnERROR( S_ERROR( 'siteName is missing' ) )
    siteName = self.args[ 'siteName' ]  
    
    # If siteName is None, we take all sites
    if siteName is None:
      siteName = Resources.getSites()      
      if not siteName[ 'OK' ]:
        return self.returnERROR( siteName )
      siteName = siteName[ 'Value' ]

    if element == 'Site':
      results = self.wmsAdmin.getPilotSummaryWeb( { 'GridSite' : siteName }, [], 0, 300 )
    elif element == 'Resource':
      results = self.wmsAdmin.getPilotSummaryWeb( { 'ExpandSite' : siteName }, [], 0, 300 )      
    else:
      return self.returnERROR( S_ERROR( '%s is a wrong element' % element ) )  
       
    if not results[ 'OK' ]:
      return self.returnERROR( results )
    results = results[ 'Value' ]
    
    if not 'ParameterNames' in results:
      return self.returnERROR( S_ERROR( 'Malformed result dictionary' ) )
    params = results[ 'ParameterNames' ]
    
    if not 'Records' in results:
      return self.returnERROR( S_ERROR( 'Malformed result dictionary' ) )
    records = results[ 'Records' ]
    
    pilotResults = [] 
       
    for record in records:
      
      pilotDict = dict( zip( params , record ))
      try:
        pilotDict[ 'PilotsPerJob' ] = float( pilotDict[ 'PilotsPerJob' ] )
        pilotDict[ 'PilotsJobEff' ] = float( pilotDict[ 'PilotsJobEff' ] )
      except KeyError, e:
        return self.returnERROR( S_ERROR( e ) ) 
      except ValueError, e:
        return self.returnERROR( S_ERROR( e ) )
开发者ID:graciani,项目名称:DIRAC,代码行数:63,代码来源:PilotCommand.py


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