Exemple #1
0
  def initialize( self ):
    """ Standard constructor
    """

    try:
      self.rsDB = ResourceStatusDB()
      self.rmDB = ResourceManagementDB()

      self.StorageElementToBeChecked = Queue.Queue()
      self.StorageElementInCheck     = []

      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' )

      self.setup                = getSetup()[ 'Value' ]
      self.VOExtension          = getExt()
      self.StorageElsWriteFreqs = CheckingFreqs[ 'StorageElsWriteFreqs' ]
      self.nc                   = NotificationClient()
      self.diracAdmin           = DiracAdmin()
      self.csAPI                = CSAPI()

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

      return S_OK()

    except Exception:
      errorStr = "StElWriteInspectorAgent initialization"
      gLogger.exception( errorStr )
      return S_ERROR( errorStr )
def initializeResourceManagementHandler(serviceInfo):

    global rsDB
    rsDB = ResourceStatusDB()
    global rmDB
    rmDB = ResourceManagementDB()

    cc = CommandCaller()

    global VOExtension
    VOExtension = getExt()

    ig = InfoGetter(VOExtension)

    WMSAdmin = RPCClient("WorkloadManagement/WMSAdministrator")

    global publisher
    publisher = Publisher(VOExtension,
                          rsDBIn=rsDB,
                          commandCallerIn=cc,
                          infoGetterIn=ig,
                          WMSAdminIn=WMSAdmin)

    #  sync_O = Synchronizer(rsDB)
    #  gConfig.addListenerToNewVersionEvent( sync_O.sync )

    return S_OK()
Exemple #3
0
    def setCommandObject(self, comm):
        """ 
    Returns a command object, given comm
    
    :params:
      `comm`: a tuple, where comm[0] is a module name and comm[1] is a class name (inside the module)
    """

        moduleBase = "DIRAC.ResourceStatusSystem.Command."

        ext = getExt()

        # TRY FIRST TO IMPORT FROM DIRAC. AS IT IS NOW, THERE ARE MUCH MORE COMMANDS IN
        # DIRAC THAN IN THE EXTENSION. IT MIGHT CHANGE.

        try:
            cModule = comm[0]
            cClass = comm[1]
            module = moduleBase + cModule
            commandModule = __import__(module, globals(), locals(), ['*'])
        except ImportError:
            try:
                cModule = comm[0]
                cClass = comm[1]
                module = ext + moduleBase + cModule
                commandModule = __import__(module, globals(), locals(), ['*'])
            except ImportError:
                cModule = "Command"
                cClass = "Command"
                module = moduleBase + cModule
                commandModule = __import__(module, globals(), locals(), ['*'])

        c = getattr(commandModule, cClass)()

        return c
  def setCommandObject(self, comm):
    """ 
    Returns a command object, given comm
    
    :params:
      `comm`: a tuple, where comm[0] is a module name and comm[1] is a class name (inside the module)
    """ 

    moduleBase = "DIRAC.ResourceStatusSystem.Command."
    
    ext = getExt()
    
    # TRY FIRST TO IMPORT FROM DIRAC. AS IT IS NOW, THERE ARE MUCH MORE COMMANDS IN
    # DIRAC THAN IN THE EXTENSION. IT MIGHT CHANGE.
    
    try:
      cModule = comm[0]
      cClass = comm[1]
      module = moduleBase + cModule
      commandModule = __import__(module, globals(), locals(), ['*'])
    except ImportError:  
      try:
        cModule = comm[0]
        cClass = comm[1]
        module = ext + moduleBase + cModule
        commandModule = __import__(module, globals(), locals(), ['*'])
      except ImportError:
        cModule = "Command"
        cClass = "Command"
        module = moduleBase + cModule
        commandModule = __import__(module, globals(), locals(), ['*'])
      
    c = getattr(commandModule, cClass)()

    return c
Exemple #5
0
  def initialize( self ):
    """ ClientsCacheFeeder initialization
    """

    try:

      self.rsDB = ResourceStatusDB()
      self.rmDB = ResourceManagementDB()

      self.clientsInvoker = ClientsInvoker()

      VOExtension = getExt()

      configModule = __import__( VOExtension + "DIRAC.ResourceStatusSystem.Policy.Configurations",
                                globals(), locals(), ['*'] )
      commandsList_ClientsCache = copy.deepcopy( configModule.Commands_ClientsCache )

      commandsList_AccountingCache = copy.deepcopy( configModule.Commands_AccountingCache )

      self.commandObjectsList_ClientsCache = []

      self.commandObjectsList_AccountingCache = []

      cc = CommandCaller()

      RPCWMSAdmin = RPCClient( "WorkloadManagement/WMSAdministrator" )
      RPCAccounting = RPCClient( "Accounting/ReportGenerator" )

      for command in commandsList_ClientsCache:
        cObj = cc.setCommandObject( command )
        cc.setCommandClient( command, cObj, RPCWMSAdmin = RPCWMSAdmin,
                            RPCAccounting = RPCAccounting )
        self.commandObjectsList_ClientsCache.append( ( command, cObj ) )

      for command in commandsList_AccountingCache:
        cObj = cc.setCommandObject( command )
        cc.setCommandClient( command, cObj, RPCAccounting = RPCAccounting )
        try:
          cArgs = command[2]
        except IndexError:
          cArgs = ()
        self.commandObjectsList_AccountingCache.append( ( command, cObj, cArgs ) )

      return S_OK()

    except Exception:
      errorStr = "ClientsCacheFeeder initialization"
      gLogger.exception( errorStr )
      return S_ERROR( errorStr )
Exemple #6
0
    def initialize(self):
        """ Standard constructor
    """

        try:
            self.rsDB = ResourceStatusDB()
            self.rmDB = ResourceManagementDB()

            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')

            self.setup = getSetup()['Value']

            self.VOExtension = getExt()

            configModule = __import__(
                self.VOExtension +
                "DIRAC.ResourceStatusSystem.Policy.Configurations", globals(),
                locals(), ['*'])

            self.Resources_check_freq = copy.deepcopy(
                configModule.Resources_check_freq)

            self.nc = NotificationClient()

            self.diracAdmin = DiracAdmin()

            self.csAPI = CSAPI()

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

            return S_OK()

        except Exception:
            errorStr = "RSInspectorAgent initialization"
            gLogger.exception(errorStr)
            return S_ERROR(errorStr)
Exemple #7
0
    def initialize(self):
        """ 
    TokenAgent initialization
    """

        self.ELEMENTS = ['Site', 'StorageElementRead', 'StorageElementWrite']
        self.notifyHours = self.am_getOption('notifyHours', 10)

        try:
            self.rsDB = ResourceStatusDB()
            self.nc = NotificationClient()
            self.VOExt = getExt()

            return S_OK()
        except Exception:
            errorStr = "TokenAgent initialization"
            gLogger.exception(errorStr)
            return S_ERROR(errorStr)
  def initialize(self):
    """ Standard constructor
    """
    
    try:
      self.rsDB = ResourceStatusDB()
      self.rmDB = ResourceManagementDB()
      
      self.ServicesToBeChecked = Queue.Queue()
      self.ServiceNamesInCheck = []
      
      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')
      
      self.setup = getSetup()['Value']

      self.VOExtension = getExt()

      configModule = __import__(self.VOExtension+"DIRAC.ResourceStatusSystem.Policy.Configurations", 
                                globals(), locals(), ['*'])
      
      self.Services_check_freq = copy.deepcopy(configModule.Services_check_freq)
      
      self.nc = NotificationClient()

      self.diracAdmin = DiracAdmin()

      self.csAPI = CSAPI()      
      
      for i in xrange(self.maxNumberOfThreads):
        self.threadPool.generateJobAndQueueIt(self._executeCheck, args = (None, ) )  
        
      return S_OK()

    except Exception:
      errorStr = "SeSInspectorAgent initialization"
      gLogger.exception(errorStr)
      return S_ERROR(errorStr)
def initializeResourceManagementHandler(serviceInfo):

  global rsDB
  rsDB = ResourceStatusDB()    
  global rmDB
  rmDB = ResourceManagementDB()

  cc = CommandCaller()

  global VOExtension
  VOExtension = getExt()

  ig = InfoGetter(VOExtension)
  
  WMSAdmin = RPCClient("WorkloadManagement/WMSAdministrator")

  global publisher
  publisher = Publisher(VOExtension, rsDBIn = rsDB, commandCallerIn = cc, 
                        infoGetterIn = ig, WMSAdminIn = WMSAdmin)

#  sync_O = Synchronizer(rsDB)
#  gConfig.addListenerToNewVersionEvent( sync_O.sync )
    
  return S_OK()