Example #1
0
 def refreshProxy( self ):
   """ setup DataManager shifter proxy in env """
   gLogger.info( "refreshProxy: getting proxy for DataManager..." )
   proxy = setupShifterProxyInEnv( "DataManager" )
   if not proxy['OK']:
     gLogger.error( "refreshProxy: %s" % proxy['Message'] )
   return proxy
Example #2
0
 def refreshProxy():
     """ setup DataManager shifter proxy in env """
     gLogger.info("refreshProxy: getting proxy for DataManager...")
     proxy = setupShifterProxyInEnv("DataManager")
     if not proxy['OK']:
         gLogger.error("refreshProxy: %s" % proxy['Message'])
     return proxy
Example #3
0
 def _setShifterProxy( self ):
   if self.__moduleProperties[ "shifterProxy" ]:
     result = setupShifterProxyInEnv( self.__moduleProperties[ "shifterProxy" ],
                                      self.am_getShifterProxyLocation() )
     if not result[ 'OK' ]:
       self.log.error( "Failed to set shifter proxy", result['Message'] )
       return result
   return S_OK()
Example #4
0
 def __installShifterProxy( self ):
   shifterProxy = self.ex_getProperty( "shifterProxy" )
   if not shifterProxy:
     return S_OK()
   location = "%s-%s" % ( self.ex_getProperty( "shifterProxyLocation" ), shifterProxy )
   result = setupShifterProxyInEnv( shifterProxy, location )
   if not result[ 'OK' ]:
     self.log.error( "Cannot set shifter proxy: %s" % result[ 'Message' ] )
   return result
Example #5
0
 def _setShifterProxy(self):
     if self.__moduleProperties["shifterProxy"]:
         result = setupShifterProxyInEnv(
             self.__moduleProperties["shifterProxy"],
             self.am_getShifterProxyLocation())
         if not result['OK']:
             self.log.error(result['Message'])
             return result
     return S_OK()
Example #6
0
 def __installShifterProxy(self):
     shifterProxy = self.ex_getProperty("shifterProxy")
     if not shifterProxy:
         return S_OK()
     location = "%s-%s" % (self.ex_getProperty("shifterProxyLocation"), shifterProxy)
     result = setupShifterProxyInEnv(shifterProxy, location)
     if not result["OK"]:
         self.log.error("Cannot set shifter proxy: %s" % result["Message"])
     return result
Example #7
0
 def _setShifterProxy(self):
     if self.__moduleProperties["shifterProxy"]:
         result = setupShifterProxyInEnv(
             self.__moduleProperties["shifterProxy"],
             self.am_getShifterProxyLocation())
         if not result["OK"]:
             self.log.error("Failed to set shifter proxy",
                            result["Message"])
             return result
     return S_OK()
Example #8
0
    def test_Integration_User_boole(self):
        """ A Boole production job, run as a user job
    """

        # get a shifter proxy
        setupShifterProxyInEnv('ProductionManager')

        oJob = copy.deepcopy(self.lhcbJobTemplate)
        oJob.setName("gaudirun-test-inputs")
        try:
            # This is the standard location in Jenkins
            oJob.setInputSandbox([
                find_all('prodConf_Boole_00012345_00067890_1.py',
                         os.environ['WORKSPACE'],
                         '/tests/Workflow/Integration')[0],
                find_all('pilot.cfg',
                         os.environ['WORKSPACE'] + '/PilotInstallDIR')[0]
            ])
        except (IndexError, KeyError):
            oJob.setInputSandbox([
                find_all('prodConf_Boole_00012345_00067890_1.py', rootPath,
                         '/tests/Workflow/Integration')[0],
                find_all('pilot.cfg', rootPath)[0]
            ])

        # opts = "$APPCONFIGOPTS/Boole/Default.py;"
        # optDT = "$APPCONFIGOPTS/Boole/DataType-2012.py;"
        # optTCK = "$APPCONFIGOPTS/L0/L0TCK-0x0042.py;"
        # optComp = "$APPCONFIGOPTS/Persistency/Compression-ZLIB-1.py;"
        # optPConf = "prodConf_Boole_00012345_00067890_1.py"
        # options = opts + optDT + optTCK + optComp + optPConf

        # oJob.setApplication('Boole', 'v24r0', options,
        #                     inputData='/lhcb/user/f/fstagni/test/12345/12345678/00012345_00067890_1.sim',
        #                     extraPackages='AppConfig.v3r155;ProdConf.v1r9')

        # oJob.setDIRACPlatform()
        # res = oJob.runLocal(self.dLHCb)

        # FIXME: not really running, the above exists with status 2 -- to do it again
        self.assertTrue(True)  # res['OK'])
Example #9
0
 def am_go(self):
     #Set the shifter proxy if required
     if self.__moduleProperties['shifterProxy']:
         result = setupShifterProxyInEnv(
             self.__moduleProperties['shifterProxy'],
             self.am_getShifterProxyLocation())
         if not result['OK']:
             self.log.error(result['Message'])
             return result
     self.log.notice("-" * 40)
     self.log.notice("Starting cycle for module %s" %
                     self.__moduleProperties['fullName'])
     mD = self.am_getMaxCycles()
     if mD > 0:
         cD = self.__moduleProperties['cyclesDone']
         self.log.notice("Remaining %s of %s cycles" % (mD - cD, mD))
     self.log.notice("-" * 40)
     elapsedTime = time.time()
     cpuStats = self.__startReportToMonitoring()
     cycleResult = self.__executeModuleCycle()
     if cpuStats:
         self.__endReportToMonitoring(*cpuStats)
     #Increment counters
     self.__moduleProperties['cyclesDone'] += 1
     #Show status
     elapsedTime = time.time() - elapsedTime
     self.__moduleProperties['totalElapsedTime'] += elapsedTime
     self.log.notice("-" * 40)
     self.log.notice("Agent module %s run summary" %
                     self.__moduleProperties['fullName'])
     self.log.notice(" Executed %s times previously" %
                     self.__moduleProperties['cyclesDone'])
     self.log.notice(" Cycle took %.2f seconds" % elapsedTime)
     averageElapsedTime = self.__moduleProperties[
         'totalElapsedTime'] / self.__moduleProperties['cyclesDone']
     self.log.notice(" Average execution time: %.2f seconds" %
                     (averageElapsedTime))
     elapsedPollingRate = averageElapsedTime * 100 / self.am_getOption(
         'PollingTime')
     self.log.notice(" Polling time: %s seconds" %
                     self.am_getOption('PollingTime'))
     self.log.notice(" Average execution/polling time: %.2f%%" %
                     elapsedPollingRate)
     if cycleResult['OK']:
         self.log.notice(" Cycle was successful")
     else:
         self.log.error(" Cycle had an error:", cycleResult['Message'])
     self.log.notice("-" * 40)
     #Update number of cycles
     self.monitor.setComponentExtraParam(
         'cycles', self.__moduleProperties['cyclesDone'])
     return cycleResult
Example #10
0
 def run(self):
     while True:
         jobId, jobAttrs, jobDef = self.jobQueue.get(block=True)
         #If there's no job def then get it
         if not jobDef:
             result = self.optimizer.getJobDefinition(jobId, jobDef)
             if not result['OK']:
                 self.optimizer.setFailedJob(jobId, result['Message'])
                 return result
             jobDef = result['Value']
         #Does the optimizer require a proxy?
         shifterEnv = False
         if self.optimizer.am_getModuleParam('shifterProxy'):
             shifterEnv = True
             result = setupShifterProxyInEnv(
                 self.optimizer.am_getModuleParam('shifterProxy'),
                 self.optimizer.am_getShifterProxyLocation())
             if not result['OK']:
                 return result
         #Call the initCycle function
         result = self.optimizer.am_secureCall(
             self.optimizer.beginExecution, name="beginExecution")
         if not result['OK']:
             return result
         #Do the work
         result = self.optimizer.optimizeJob(jobId, jobDef['classad'])
         #If there was a shifter proxy, unset it
         if shifterEnv:
             del (os.environ['X509_USER_PROXY'])
         if not result['OK']:
             gLogger.error(
                 "Job failed optimization step\n",
                 "\tJob: %s\n\tOptimizer: %s\n\tMessage: %s" %
                 (jobId, self.optimizerName, result['Message']))
             self.dispatchFunction(jobId, jobAttrs, jobDef, False)
         else:
             #Job optimization was OK
             nextOptimizer = result['Value']
             #Check if the JDL has changed
             newJDL = jobDef['classad'].asJDL()
             if newJDL != jobDef['jdl']:
                 jobDef['jdl'] = newJDL
             #If there's a new optimizer set it!
             if nextOptimizer:
                 jobAttrs['Status'] = 'Checking'
                 jobAttrs['MinorStatus'] = nextOptimizer
                 gLogger.info("Sending job %s to next optimizer: %s" %
                              (jobId, nextOptimizer))
             else:
                 gLogger.info("Finished optimizing job %s" % jobId)
             self.dispatchFunction(jobId, jobAttrs, jobDef, nextOptimizer)
Example #11
0
 def run(self):
     while True:
         jobId, jobAttrs, jobDef = self.jobQueue.get(block=True)
         # If there's no job def then get it
         if not jobDef:
             result = self.optimizer.getJobDefinition(jobId, jobDef)
             if not result["OK"]:
                 self.optimizer.setFailedJob(jobId, result["Message"])
                 return result
             jobDef = result["Value"]
         # Does the optimizer require a proxy?
         shifterEnv = False
         if self.optimizer.am_getModuleParam("shifterProxy"):
             shifterEnv = True
             result = setupShifterProxyInEnv(
                 self.optimizer.am_getModuleParam("shifterProxy"), self.optimizer.am_getShifterProxyLocation()
             )
             if not result["OK"]:
                 return result
         # Call the initCycle function
         result = self.optimizer.am_secureCall(self.optimizer.beginExecution, name="beginExecution")
         if not result["OK"]:
             return result
         # Do the work
         result = self.optimizer.optimizeJob(jobId, jobDef["classad"])
         # If there was a shifter proxy, unset it
         if shifterEnv:
             del (os.environ["X509_USER_PROXY"])
         if not result["OK"]:
             gLogger.error(
                 "Job failed optimization step\n",
                 "\tJob: %s\n\tOptimizer: %s\n\tMessage: %s" % (jobId, self.optimizerName, result["Message"]),
             )
             self.dispatchFunction(jobId, jobAttrs, jobDef, False)
         else:
             # Job optimization was OK
             nextOptimizer = result["Value"]
             # Check if the JDL has changed
             newJDL = jobDef["classad"].asJDL()
             if newJDL != jobDef["jdl"]:
                 jobDef["jdl"] = newJDL
             # If there's a new optimizer set it!
             if nextOptimizer:
                 jobAttrs["Status"] = "Checking"
                 jobAttrs["MinorStatus"] = nextOptimizer
                 gLogger.info("Sending job %s to next optimizer: %s" % (jobId, nextOptimizer))
             else:
                 gLogger.info("Finished optimizing job %s" % jobId)
             self.dispatchFunction(jobId, jobAttrs, jobDef, nextOptimizer)
Example #12
0
 def optimizeJob(self, jobId, jobAttrs, jobDef):
     """ The method call for each Job to be optimized
 """
     #Get the next optimizer
     result = self._getNextOptimizer(jobAttrs)
     if not result['OK']:
         return result
     optimizer = result['Value']
     if not optimizer:
         return S_OK({'done': True})
     #If there's no job def then get it
     if not jobDef:
         result = optimizer.getJobDefinition(jobId, jobDef)
         if not result['OK']:
             optimizer.setFailedJob(jobId, result['Message'])
             return result
         jobDef = result['Value']
     #Does the optimizer require a proxy?
     shifterEnv = False
     if optimizer.am_getModuleParam('shifterProxy'):
         shifterEnv = True
         result = setupShifterProxyInEnv(
             optimizer.am_getModuleParam('shifterProxy'),
             optimizer.am_getShifterProxyLocation())
         if not result['OK']:
             return result
     #Call the initCycle function
     result = self.am_secureCall(optimizer.beginExecution,
                                 name="beginExecution")
     if not result['OK']:
         return result
     #Do the work
     result = optimizer.optimizeJob(jobId, jobDef['classad'])
     if not result['OK']:
         return result
     nextOptimizer = result['Value']
     #If there was a shifter proxy, unset it
     if shifterEnv:
         del (os.environ['X509_USER_PROXY'])
     #Check if the JDL has changed
     newJDL = jobDef['classad'].asJDL()
     if newJDL != jobDef['jdl']:
         jobDef['jdl'] = newJDL
     #If there's a new optimizer set it!
     if nextOptimizer:
         jobAttrs['Status'] = 'Checking'
         jobAttrs['MinorStatus'] = nextOptimizer
         return S_OK({'done': False, 'jobDef': jobDef})
     return S_OK({'done': True, 'jobDef': jobDef})
Example #13
0
 def optimizeJob( self, jobId, jobAttrs, jobDef ):
   """ The method call for each Job to be optimized
   """
   #Get the next optimizer
   result = self._getNextOptimizer( jobAttrs )
   if not result[ 'OK' ]:
     return result
   optimizer = result[ 'Value' ]
   if not optimizer:
     return S_OK( { 'done' : True } )
   #If there's no job def then get it
   if not jobDef:
     result = optimizer.getJobDefinition( jobId, jobDef )
     if not result['OK']:
       optimizer.setFailedJob( jobId, result[ 'Message' ] )
       return result
     jobDef = result[ 'Value' ]
   #Does the optimizer require a proxy?
   shifterEnv = False
   if optimizer.am_getModuleParam( 'shifterProxy' ):
     shifterEnv = True
     result = setupShifterProxyInEnv( optimizer.am_getModuleParam( 'shifterProxy' ),
                                      optimizer.am_getShifterProxyLocation() )
     if not result[ 'OK' ]:
       return result
   #Call the initCycle function
   result = self.am_secureCall( optimizer.beginExecution, name = "beginExecution" )
   if not result[ 'OK' ]:
     return result
   #Do the work
   result = optimizer.optimizeJob( jobId, jobDef[ 'classad' ] )
   if not result[ 'OK' ]:
     return result
   nextOptimizer = result[ 'Value' ]
   #If there was a shifter proxy, unset it
   if shifterEnv:
     del( os.environ[ 'X509_USER_PROXY' ] )
   #Check if the JDL has changed
   newJDL = jobDef[ 'classad' ].asJDL()
   if newJDL != jobDef[ 'jdl' ]:
     jobDef[ 'jdl' ] = newJDL
   #If there's a new optimizer set it!
   if nextOptimizer:
     jobAttrs[ 'Status' ] = 'Checking'
     jobAttrs[ 'MinorStatus' ] = nextOptimizer
     return S_OK( { 'done' : False, 'jobDef' : jobDef } )
   return S_OK( { 'done' : True, 'jobDef' : jobDef } )
Example #14
0
 def am_go( self ):
   #Set the shifter proxy if required
   if self.__moduleProperties[ 'shifterProxy' ]:
     result = setupShifterProxyInEnv( self.__moduleProperties[ 'shifterProxy' ],
                                      self.am_getShifterProxyLocation() )
     if not result[ 'OK' ]:
       self.log.error( result['Message'] )
       return result
   self.log.notice( "-"*40 )
   self.log.notice( "Starting cycle for module %s" % self.__moduleProperties[ 'fullName' ] )
   mD = self.am_getMaxCycles()
   if mD > 0:
     cD = self.__moduleProperties[ 'cyclesDone' ]
     self.log.notice( "Remaining %s of %s cycles" % ( mD - cD, mD ) )
   self.log.notice( "-"*40 )
   elapsedTime = time.time()
   cpuStats = self.__startReportToMonitoring()
   cycleResult = self.__executeModuleCycle()
   if cpuStats:
     self.__endReportToMonitoring( *cpuStats )
   #Increment counters
   self.__moduleProperties[ 'cyclesDone' ] += 1
   #Show status
   elapsedTime = time.time() - elapsedTime
   self.__moduleProperties[ 'totalElapsedTime' ] += elapsedTime
   self.log.notice( "-"*40 )
   self.log.notice( "Agent module %s run summary" % self.__moduleProperties[ 'fullName' ] )
   self.log.notice( " Executed %s times previously" % self.__moduleProperties[ 'cyclesDone' ] )
   self.log.notice( " Cycle took %.2f seconds" % elapsedTime )
   averageElapsedTime = self.__moduleProperties[ 'totalElapsedTime' ] / self.__moduleProperties[ 'cyclesDone' ]
   self.log.notice( " Average execution time: %.2f seconds" % ( averageElapsedTime ) )
   elapsedPollingRate = averageElapsedTime * 100 / self.am_getOption( 'PollingTime' )
   self.log.notice( " Polling time: %s seconds" % self.am_getOption( 'PollingTime' ) )
   self.log.notice( " Average execution/polling time: %.2f%%" % elapsedPollingRate )
   if cycleResult[ 'OK' ]:
     self.log.notice( " Cycle was successful" )
   else:
     self.log.error( " Cycle had an error:", cycleResult[ 'Message' ] )
   self.log.notice( "-"*40 )
   #Update number of cycles
   self.monitor.setComponentExtraParam( 'cycles', self.__moduleProperties[ 'cyclesDone' ] )
   return cycleResult