def initialize(self, jobDB=None, logDB=None): """Initialization of the Optimizer Agent.""" self.jobDB = JobDB() if jobDB is None else jobDB if not self.jobDB.isValid(): dExit(1) useESForJobParametersFlag = Operations().getValue( "/Services/JobMonitoring/useESForJobParametersFlag", False) if useESForJobParametersFlag: try: result = ObjectLoader().loadObject( "WorkloadManagementSystem.DB.ElasticJobParametersDB", "ElasticJobParametersDB") if not result["OK"]: return result self.elasticJobParametersDB = result["Value"]() except RuntimeError as excp: return S_ERROR("Can't connect to DB: %s" % excp) self.logDB = JobLoggingDB() if logDB is None else logDB optimizerName = self.am_getModuleParam("agentName") if optimizerName.endswith("Agent"): optimizerName = optimizerName[:-len("Agent")] self.am_setModuleParam("optimizerName", optimizerName) self.startingMinorStatus = self.am_getModuleParam("optimizerName") self.failedStatus = self.am_getOption("FailedJobStatus", JobStatus.FAILED) self.am_setOption("PollingTime", 30) return self.initializeOptimizer()
def initialize(self, jobDB=None, logDB=None): """ Initialization of the Optimizer Agent. """ self.jobDB = JobDB() if jobDB is None else jobDB if not self.jobDB.isValid(): dExit(1) self.logDB = JobLoggingDB() if logDB is None else logDB optimizerName = self.am_getModuleParam('agentName') if optimizerName.endswith('Agent'): optimizerName = optimizerName[:-len('Agent')] self.am_setModuleParam('optimizerName', optimizerName) self.startingMinorStatus = self.am_getModuleParam('optimizerName') self.failedStatus = self.am_getOption("FailedJobStatus", 'Failed') self.am_setOption("PollingTime", 30) return self.initializeOptimizer()
from DIRAC import gLogger, exit as dExit import LbPlatformUtils parList = Script.getUnprocessedSwitches() for switch, _val in parList: if switch == 'BinaryTag': try: # Get the binaryTag name. If an error occurs, an exception is thrown binaryTag = LbPlatformUtils.host_binary_tag() if not binaryTag: gLogger.fatal( "There is no binaryTag corresponding to this machine") sendMail( "There is no binaryTag corresponding to this machine") dExit(1) print binaryTag dExit(0) except Exception as e: msg = "Exception getting binaryTag: " + repr(e) gLogger.exception(msg, lException=e) sendMail(msg) dExit(1) try: # Get the platform name. If an error occurs, an exception is thrown platform = LbPlatformUtils.dirac_platform() if not platform: gLogger.fatal("There is no platform corresponding to this machine") sendMail("There is no platform corresponding to this machine") dExit(1)
__doc__.split('\n')[1], 'Usage:', ' %s [option|cfgfile]' % Script.scriptName, ])) Script.parseCommandLine(ignoreErrors=False) dumpList = False for switch in Script.getUnprocessedSwitches(): if switch[0] == 'List': dumpList = True bkQuery = dmScript.getBKQuery() lfns = dmScript.getOption('LFNs', []) if not bkQuery and not lfns: gLogger.error("No BKQuery and no files given...") dExit(1) # Invert the visibility flag as want to set Invisible those that are visible and vice-versa from LHCbDIRAC.BookkeepingSystem.Client.BookkeepingClient import BookkeepingClient bk = BookkeepingClient() visibilityFlag = dmScript.getOption('Visibility', None) if visibilityFlag is None: gLogger.error('Visibility option should be given') dExit(2) visibilityFlag = str(visibilityFlag).lower() == 'yes' if bkQuery: # Query with visibility opposite to what is requested to be set ;-) bkQuery.setOption('Visible', 'No' if visibilityFlag else 'Yes') gLogger.notice("BQ query:", bkQuery) lfns += bkQuery.getLFNs() if not lfns: