Ejemplo n.º 1
0
  def export_getCachedDowntimes( self, element, elementType, elementName, severity, startDate, endDate ):
    
    if elementType == 'StorageElement':
      result = CSHelpers.getSEProtocolOption( elementName, 'Host' )
      if not result['OK']:
        return S_ERROR( 'StorageElement %s host not found' % elementName )
      name = result['Value']
   
    if startDate > endDate:
      return S_ERROR( 'startDate > endDate' )
    
    res = rmClient.selectDowntimeCache( element = element, name = name, severity = severity,
                                        meta = { 'columns' : [ 'Element', 'Name', 'StartDate',
                                                               'EndDate', 'Severity',
                                                               'Description', 'Link' ] } )
    if not res[ 'OK' ]:
      return res
    
    downtimes = []
    
    for dt in res[ 'Value' ]:
      
      dtDict = dict( zip( res[ 'Columns' ], dt ) ) 
    
      if dtDict[ 'StartDate' ] < endDate and dtDict[ 'EndDate' ] > startDate:
        downtimes.append( dt )
    
    result = S_OK( downtimes )
    result[ 'Columns' ] = res[ 'Columns' ]
    
    return result    

#...............................................................................
#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF
Ejemplo n.º 2
0
 def export_getDowntimes( self, element, elementType, elementName ):
   
   if elementType == 'StorageElement':
     result = CSHelpers.getSEProtocolOption( elementName, 'Host' )
     if not result['OK']:
       return S_ERROR( 'StorageElement %s host not found' % elementName )
     name = result['Value']
   
   return rmClient.selectDowntimeCache( element = element, name = name, 
                                        meta = { 'columns' : [ 'StartDate', 'EndDate', 
                                                               'Link', 'Description', 
                                                               'Severity' ] } )
Ejemplo n.º 3
0
  def _prepareCommand( self ):
    '''
      DowntimeCommand requires three arguments:
      - name : <str>
      - element : Site / Resource
      - elementType: <str>  
      
      If the elements are Site(s), we need to get their GOCDB names. They may
      not have, so we ignore them if they do not have.
    '''
    
    if 'name' not in self.args:
      return S_ERROR( '"name" not found in self.args' )
    elementName = self.args[ 'name' ]      
    
    if 'element' not in self.args:
      return S_ERROR( '"element" not found in self.args' )
    element = self.args[ 'element' ]
    
    if 'elementType' not in self.args:
      return S_ERROR( '"elementType" not found in self.args' )
    elementType = self.args[ 'elementType' ]
    
    if not element in [ 'Site', 'Resource' ]:
      return S_ERROR( 'element is not Site nor Resource' )   

    hours = None
    if 'hours' in self.args:
      hours = self.args[ 'hours' ]
    
    # Transform DIRAC site names into GOCDB topics
    if element == 'Site':

      gocSite = getGOCSiteName( elementName )
      if not gocSite[ 'OK' ]:
        return gocSite
      elementName = gocSite[ 'Value' ]
          
    # The DIRAC se names mean nothing on the grid, but their hosts do mean.
    elif elementType == 'StorageElement':
      
      result = CSHelpers.getSEProtocolOption( elementName, 'Host' )
      if not result['OK']:
        return S_ERROR( 'No seHost for %s' % elementName )
      elementName = result['Value']
             
    return S_OK( ( element, elementName, hours ) )
Ejemplo n.º 4
0
    def _prepareCommand(self):
        '''
      DowntimeCommand requires three arguments:
      - name : <str>
      - element : Site / Resource
      - elementType: <str>  
      
      If the elements are Site(s), we need to get their GOCDB names. They may
      not have, so we ignore them if they do not have.
    '''

        if 'name' not in self.args:
            return S_ERROR('"name" not found in self.args')
        elementName = self.args['name']

        if 'element' not in self.args:
            return S_ERROR('"element" not found in self.args')
        element = self.args['element']

        if 'elementType' not in self.args:
            return S_ERROR('"elementType" not found in self.args')
        elementType = self.args['elementType']

        if not element in ['Site', 'Resource']:
            return S_ERROR('element is not Site nor Resource')

        hours = None
        if 'hours' in self.args:
            hours = self.args['hours']

        # Transform DIRAC site names into GOCDB topics
        if element == 'Site':

            gocSite = getGOCSiteName(elementName)
            if not gocSite['OK']:
                return gocSite
            elementName = gocSite['Value']

        # The DIRAC se names mean nothing on the grid, but their hosts do mean.
        elif elementType == 'StorageElement':

            result = CSHelpers.getSEProtocolOption(elementName, 'Host')
            if not result['OK']:
                return S_ERROR('No seHost for %s' % elementName)
            elementName = result['Value']

        return S_OK((element, elementName, hours))
Ejemplo n.º 5
0
    def _prepareCommand(self):
        '''
      SpaceTokenOccupancy requires one argument:
      - elementName : <str>
    
      Given a (storage)elementName, we calculate its endpoint and spaceToken,
      which are used to query the srm interface.
    '''

        if not 'name' in self.args:
            return S_ERROR('"name" not found in self.args')
        elementName = self.args['name']

        endpoint = CSHelpers.getStorageElementEndpoint(elementName)
        if not endpoint['OK']:
            return endpoint
        endpoint = endpoint['Value']

        spaceToken = CSHelpers.getSEProtocolOption(elementName, 'SpaceToken')
        if not spaceToken['OK']:
            return spaceToken
        spaceToken = spaceToken['Value']

        return S_OK((endpoint, spaceToken))
Ejemplo n.º 6
0
  def _prepareCommand( self ):
    '''
      SpaceTokenOccupancy requires one argument:
      - elementName : <str>
    
      Given a (storage)elementName, we calculate its endpoint and spaceToken,
      which are used to query the srm interface.
    '''

    if not 'name' in self.args:
      return S_ERROR( '"name" not found in self.args' )
    elementName = self.args[ 'name' ]
    
    endpoint = CSHelpers.getStorageElementEndpoint( elementName )
    if not endpoint[ 'OK' ]:
      return endpoint
    endpoint = endpoint[ 'Value' ]
    
    spaceToken = CSHelpers.getSEProtocolOption( elementName, 'SpaceToken' )
    if not spaceToken[ 'OK' ]:
      return spaceToken
    spaceToken = spaceToken[ 'Value']
  
    return S_OK( ( endpoint, spaceToken ) )