コード例 #1
0
ファイル: StorageFactory.py プロジェクト: acasajus/DIRAC
 def _getConfigStorageProtocols(self, storageName):
     """ Protocol specific information is present as sections in the Storage configuration
 """
     result = getSiteForResource('Storage', storageName)
     if not result['OK']:
         return result
     site = result['Value']
     result = self.resourcesHelper.getEligibleNodes('AccessProtocol', {
         'Site': site,
         'Resource': storageName
     })
     if not result['OK']:
         return result
     nodesDict = result['Value']
     protocols = []
     for site in nodesDict:
         for se in nodesDict[site]:
             protocols.extend(nodesDict[site][se])
     sortedProtocols = sortList(protocols)
     protocolDetails = []
     for protocol in sortedProtocols:
         result = self._getConfigStorageProtocolDetails(
             storageName, protocol)
         if not result['OK']:
             return result
         protocolDetails.append(result['Value'])
     self.protocols = self.localProtocols + self.remoteProtocols
     return S_OK(protocolDetails)
コード例 #2
0
ファイル: SiteCEMapping.py プロジェクト: graciani/DIRAC
def getSiteForCE(computingElement):
    """ Given a Grid CE name this method returns the DIRAC site name.
  """
    result = getSiteForResource(computingElement)
    if not result['OK']:
        return result
    site = result['Value']
    result = getSiteFullNames(site)
    if not result['OK']:
        return result
    siteFullName = result['Value'][0]

    return S_OK(siteFullName)
コード例 #3
0
ファイル: SiteCEMapping.py プロジェクト: graciani/DIRAC
def getSiteForCE( computingElement ):
  """ Given a Grid CE name this method returns the DIRAC site name.
  """
  result = getSiteForResource( computingElement )
  if not result['OK']:
    return result
  site = result['Value']
  result = getSiteFullNames( site )
  if not result['OK']:
    return result
  siteFullName = result['Value'][0]

  return S_OK( siteFullName )
コード例 #4
0
ファイル: PublisherHandler.py プロジェクト: graciani/DIRAC
  def export_getTree( self, element, elementType, elementName ):

    tree = {}

    resources = Resources.Resources()

    #site = self.getSite( element, elementType, elementName )
    result = getSiteForResource( elementName )
    if not result['OK']:
      return S_ERROR( 'Can not get site name: %s' % result[ 'Message' ] ) 
    site = result['Value']       
    if not site:
      return S_ERROR( 'No site' )
    
    siteStatus = rsClient.selectStatusElement( 'Site', 'Status', name = site, 
                                               meta = { 'columns' : [ 'StatusType', 'Status' ] } )
    if not siteStatus[ 'OK' ]:
      return siteStatus      

    tree[ site ] = { 'statusTypes' : dict( siteStatus[ 'Value' ] ) }
      
    ces = resources.getEligibleResources( 'Computing', { 'Site': site } )
    cesStatus = rsClient.selectStatusElement( 'Resource', 'Status', name = ces,
                                              meta = { 'columns' : [ 'Name', 'StatusType', 'Status'] } )
    if not cesStatus[ 'OK' ]:
      return cesStatus
    
    tree[ site ][ 'ces' ] = {}
    for ceTuple in cesStatus[ 'Value' ]:
      name, statusType, status = ceTuple
      if not name in tree[ site ][ 'ces' ]:
        tree[ site ][ 'ces' ][ name ] = {}
      tree[ site ][ 'ces' ][ name ][ statusType ] = status   
    
    ses = resources.getEligibleStorageElements( { 'Site': site } )
    sesStatus = rsClient.selectStatusElement( 'Resource', 'Status', name = ses,
                                              meta = { 'columns' : [ 'Name', 'StatusType', 'Status'] } )
    if not sesStatus[ 'OK' ]:
      return sesStatus
    
    tree[ site ][ 'ses' ] = {}
    for seTuple in sesStatus[ 'Value' ]:
      name, statusType, status = seTuple
      if not name in tree[ site ][ 'ses' ]:
        tree[ site ][ 'ses' ][ name ] = {}
      tree[ site ][ 'ses' ][ name ][ statusType ] = status   

    return S_OK( tree )
コード例 #5
0
ファイル: StorageFactory.py プロジェクト: acasajus/DIRAC
    def _getConfigStorageProtocolDetails(self, storageName, protocol):
        """
      Parse the contents of the protocol block
    """
        # First obtain the options that are available
        result = getSiteForResource('Storage', storageName)
        if not result['OK']:
            return result
        site = result['Value']
        result = self.resourcesHelper.getNodeOptionsDict(
            site, 'Storage', storageName, protocol)
        if not result['OK']:
            return result
        optionsDict = result['Value']

        # We must have certain values internally even if not supplied in CS
        protocolDict = {
            'Access': '',
            'Host': '',
            'Path': '',
            'Port': '',
            'Protocol': '',
            'ProtocolName': '',
            'SpaceToken': '',
            'WSUrl': ''
        }
        for option in optionsDict:
            protocolDict[option] = optionsDict[option]

        # Now update the local and remote protocol lists.
        # A warning will be given if the Access option is not set.
        if protocolDict['Access'] == 'remote':
            self.remoteProtocols.append(protocolDict['ProtocolName'])
        elif protocolDict['Access'] == 'local':
            self.localProtocols.append(protocolDict['ProtocolName'])
        else:
            errStr = "StorageFactory.__getProtocolDetails: The 'Access' option for %s:%s is neither 'local' or 'remote'." % (
                storageName, protocol)
            gLogger.warn(errStr)

        # The ProtocolName option must be defined
        if not protocolDict['ProtocolName']:
            errStr = "StorageFactory.__getProtocolDetails: 'ProtocolName' option is not defined."
            gLogger.error(errStr, "%s: %s" % (storageName, protocol))
            return S_ERROR(errStr)
        return S_OK(protocolDict)
コード例 #6
0
ファイル: StorageFactory.py プロジェクト: graciani/DIRAC
 def _getConfigStorageProtocols(self, storageName):
     """ Protocol specific information is present as sections in the Storage configuration
 """
     result = getSiteForResource(storageName)
     if not result["OK"]:
         return result
     site = result["Value"]
     result = self.resourcesHelper.getEligibleNodes("AccessProtocol", {"Site": site, "Resource": storageName})
     if not result["OK"]:
         return result
     nodesList = result["Value"]
     protocols = []
     for node in nodesList:
         protocols.append(node)
     protocolDetails = []
     for protocol in protocols:
         result = self._getConfigStorageProtocolDetails(protocol)
         if not result["OK"]:
             return result
         protocolDetails.append(result["Value"])
     self.protocols = self.localProtocols + self.remoteProtocols
     return S_OK(protocolDetails)