Beispiel #1
0
    def __init__(self, apfqueue, config, section):

        _thread.__init__(self)
        apfqueue.factory.threadsregistry.add("plugin", self)
        
        self.log = logging.getLogger('autopyfactory.batchhistory.%s' %apfqueue.apfqname)
        self.log.debug('Initializing object...')

        self.apfqueue = apfqueue
        self.apfqname = apfqueue.apfqname
        
        try:
            self.condoruser = apfqueue.fcl.get('Factory', 'factoryUser')
            self.factoryid = apfqueue.fcl.get('Factory', 'factoryId')
            self.maxage = apfqueue.fcl.generic_get('Factory', 'batchhistory.condor.maxage', default_value=360) 
            self.sleeptime = self.apfqueue.fcl.getint('Factory', 'batchhistory.condor.sleep')
            self.interval = self.apfqueue.fcl.getint('Factory', 'batchhistory.condor.interval')
            self.mintime = self.apfqueue.fcl.getint('Factory', 'batchhistory.condor.mintime')
            self._thread_loop_interval = self.sleeptime
            self.queryargs = self.apfqueue.qcl.generic_get(self.apfqname, 'batchhistory.condor.queryargs') 

        except AttributeError:
            self.condoruser = '******'
            self.facoryid = 'test-local'
            self.sleeptime = 10
            self.log.warning("Got AttributeError during init. We should be running stand-alone for testing.")

        self.currentinfo = None              

        # ================================================================
        #                     M A P P I N G S 
        # ================================================================
        

        self.jobstatus2info = self.apfqueue.factory.mappingscl.section2dict('CONDORBATCHSTATUS-JOBSTATUS2INFO')
        self.log.info('jobstatus2info mappings are %s' %self.jobstatus2info)


        # variable to record when was last time info was updated
        # the info is recorded as seconds since epoch
        self.lasttime = 0
        checkCondor()
        self.log.info('BatchHistoryStatus: Object initialized.')
Beispiel #2
0
    def __init__(self, apfqueue):
        #try:
        threading.Thread.__init__(self) # init the thread
        
        self.log = logging.getLogger("main.wmsstatusplugin[singleton created by %s]" %apfqueue.apfqname)
        self.log.debug('Initializing object...')
        self.stopevent = threading.Event()

        # to avoid the thread to be started more than once
        self.__started = False
        
        self.apfqueue = apfqueue   
        self.apfqname = apfqueue.apfqname
        #self.condoruser = apfqueue.fcl.get('Factory', 'factoryUser')
        #self.factoryid = apfqueue.fcl.get('Factory', 'factoryId') 
        self.sleeptime = self.apfqueue.fcl.getint('Factory', 'wmsstatus.condor.sleep')
        self.queryargs = self.apfqueue.qcl.generic_get(self.apfqname, 'wmsstatus.condorlocal.queryargs')

        self.currentcloudinfo = None
        self.currentjobinfo = None
        self.currentsiteinfo = None
              

        # ================================================================
        #                     M A P P I N G S 
        # ================================================================
        
        self.jobstatus2info = {'0': 'ready',
                               '1': 'ready',
                               '2': 'running',
                               '3': 'done',
                               '4': 'done',
                               '5': 'failed',
                               '6': 'running'}

        # variable to record when was last time info was updated
        # the info is recorded as seconds since epoch
        self.lasttime = 0
        checkCondor()
        self.log.info('WMSStatusPlugin: Object initialized.')
Beispiel #3
0
    def __init__(self, apfqueue, config, section):
        #try:
        _thread.__init__(self)
        apfqueue.factory.threadsregistry.add("plugin", self)

        self.log = logging.getLogger('autopyfactory.wmsstatus.%s' %
                                     apfqueue.apfqname)
        self.log.debug('Initializing object...')

        self.apfqueue = apfqueue
        self.apfqname = apfqueue.apfqname
        #self.condoruser = apfqueue.fcl.get('Factory', 'factoryUser')
        #self.factoryid = apfqueue.fcl.get('Factory', 'factoryId')
        self.sleeptime = self.apfqueue.fcl.getint('Factory',
                                                  'wmsstatus.condor.sleep')
        self._thread_loop_interval = self.sleeptime
        self.maxage = self.apfqueue.fcl.generic_get('Factory',
                                                    'wmsstatus.condor.maxage',
                                                    default_value=360)
        self.queryargs = self.apfqueue.qcl.generic_get(
            self.apfqname, 'wmsstatus.condor.queryargs')
        self.queueskey = self.apfqueue.qcl.generic_get(
            self.apfqname,
            'wmsstatus.condor.queueskey',
            default_value='MATCH_APF_QUEUE')

        ### BEGIN TEST ###
        self.remoteschedd = None
        self.remotecollector = None
        if self.queryargs:
            l = self.queryargs.split()  # convert the string into a list
            if '-name' in l:
                self.remoteschedd = l[l.index('-name') + 1]
            if '-pool' in l:
                self.remotecollector = l[l.index('-pool') + 1]
        ### END TEST ###

        # FIXME
        # check if this works with a Singleton, or I need a different Singleton per value

        self.currentcloudinfo = None
        self.currentjobinfo = None
        self.currentsiteinfo = None

        # ================================================================
        #                     M A P P I N G S
        # ================================================================

        self.jobstatus2info = self.apfqueue.factory.mappingscl.section2dict(
            'CONDORWMSSTATUS-JOBSTATUS2INFO')
        self.log.info('jobstatus2info mappings are %s' % self.jobstatus2info)
        ###self.jobstatus2info = {'0': 'ready',
        ###                       '1': 'ready',
        ###                       '2': 'running',
        ###                       '3': 'done',
        ###                       '4': 'done',
        ###                       '5': 'failed',
        ###                       '6': 'running'}

        # variable to record when was last time info was updated
        # the info is recorded as seconds since epoch
        self.lasttime = 0
        checkCondor()
        self.log.info('WMSStatusPlugin: Object initialized.')
Beispiel #4
0
    def __init__(self, apfqueue, config, section):

        self.log = logging.getLogger('autopyfactory.batchsubmit.%s' %
                                     apfqueue.apfqname)
        if len(self.log.parent.handlers) < 1:
            logStream = logging.StreamHandler()
            FORMAT = '%(asctime)s (UTC) [ %(levelname)s ] %(name)s %(filename)s:%(lineno)d %(funcName)s(): %(message)s'
            formatter = logging.Formatter(FORMAT)
            formatter.converter = time.gmtime  # to convert timestamps to UTC
            logStream.setFormatter(formatter)
            self.log.addHandler(logStream)
            self.log.setLevel(logging.DEBUG)

        qcl = config
        self.apfqueue = apfqueue
        self.apfqname = apfqueue.apfqname
        self.factory = apfqueue.factory
        self.fcl = apfqueue.factory.fcl
        self.mcl = apfqueue.factory.mcl

        try:
            self.wmsqueue = qcl.generic_get(self.apfqname, 'wmsqueue')
            self.executable = qcl.generic_get(self.apfqname, 'executable')
            self.factoryadminemail = self.fcl.generic_get(
                'Factory', 'factoryAdminEmail')

            self.factoryid = self.fcl.generic_get('Factory', 'factoryId')
            self.monitorsection = qcl.generic_get(self.apfqname,
                                                  'monitorsection')
            self.log.debug("monitorsection is %s" % self.monitorsection)
            self.monitorurl = self.mcl.generic_get(self.monitorsection,
                                                   'monitorURL')
            self.log.debug("monitorURL is %s" % self.monitorurl)

            self.factoryuser = self.fcl.generic_get('Factory', 'factoryUser')
            self.submitargs = qcl.generic_get(
                self.apfqname, 'batchsubmit.condorbase.submitargs')
            self.environ = qcl.generic_get(self.apfqname,
                                           'batchsubmit.condorbase.environ')
            #self.batchqueue = qcl.generic_get(self.apfqname, 'batchqueue')
            self.arguments = qcl.generic_get(self.apfqname,
                                             'executable.arguments')
            self.peaceful = qcl.generic_get(self.apfqname,
                                            'batchsubmit.condorbase.peaceful',
                                            get_function='getboolean',
                                            default_value=True)
            self.killorder = qcl.generic_get(
                self.apfqname,
                'batchsubmit.condorbase.killorder',
                default_value="newest")
            self.condor_attributes = qcl.generic_get(
                self.apfqname, 'batchsubmit.condorbase.condor_attributes')
            self.extra_condor_attributes = [(opt.replace('batchsubmit.condorbase.condor_attributes.',''),qcl.generic_get(self.apfqname, opt)) \
                                            for opt in qcl.options(self.apfqname) \
                                            if opt.startswith('batchsubmit.condorbase.condor_attributes.')]  # Note the . at the end of the pattern !!

            self.baselogdir = os.path.expanduser(
                self.fcl.generic_get('Factory', 'baseLogDir'))
            self.baselogdirurl = self.fcl.generic_get('Factory',
                                                      'baseLogDirUrl')

            condor.checkCondor()
            self.log.info(': Object properly initialized.')
        except Exception, e:
            self.log.error("Caught exception: %s " % str(e))
            raise