CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Public Attributes
o2olib.O2OTool Class Reference

Public Member Functions

def create
 
def disable
 
def dumpConf
 
def enable
 
def execute
 
def listConf
 
def listJobs
 
def run
 
def setConfig
 
def setFrequent
 
def setInterval
 
def setup
 

Public Attributes

 args
 
 mgr
 

Detailed Description

Definition at line 433 of file o2olib.py.

Member Function Documentation

def o2olib.O2OTool.create (   self)

Definition at line 509 of file o2olib.py.

References o2olib.checkConfiguration(), and o2olib.readConfiguration().

Referenced by o2olib.O2OTool.execute().

510  def create(self):
511  configJson = None
512  if self.args.configFile is not None:
513  if self.args.configString is not None:
514  logging.error('Ambigouous input provided: please specify a configFile OR a configString')
515  return False
516  else:
517  configJson = readConfiguration( self.args.configFile )
518  else:
519  if self.args.configString is None:
520  logging.error('No configuration has been provided: please specify "configFile" or "configString" param.')
521  return False
522  else:
523  configJson = checkConfiguration( self.args.configString )
524  self.mgr.add( self.args.name, configJson, self.args.interval, self.args.frequent, True )
def readConfiguration
Definition: o2olib.py:404
def checkConfiguration
Definition: o2olib.py:420
def o2olib.O2OTool.disable (   self)

Definition at line 547 of file o2olib.py.

Referenced by o2olib.O2OTool.execute().

548  def disable(self):
549  self.mgr.set( self.args.name, False )
def o2olib.O2OTool.dumpConf (   self)

Definition at line 559 of file o2olib.py.

Referenced by o2olib.O2OTool.execute().

560  def dumpConf(self):
561  self.mgr.dumpConfig( self.args.name, self.args.versionIndex, self.args.configFile )
def dumpConf
Definition: o2olib.py:559
def o2olib.O2OTool.enable (   self)

Definition at line 544 of file o2olib.py.

Referenced by o2olib.O2OTool.execute().

545  def enable(self):
546  self.mgr.set( self.args.name, True )
def o2olib.O2OTool.execute (   self)

Definition at line 435 of file o2olib.py.

References cond::CoralServiceWrapperBase.create(), cond::persistency::ITagTable.create(), cond::CoralServiceWrapper< T >.create(), cond::persistency::GLOBAL_TAG::Table.create(), cond::persistency::TAG::Table.create(), cond::CoralServiceFactory.create(), converter::helper::ConcreteCreator.create(), converter::helper::PolymorphicCreator.create(), cond::persistency::RUN_INFO::Table.create(), cond::persistency::IPayloadTable.create(), cond::persistency::GLOBAL_TAG_MAP::Table.create(), cond::persistency::RunInfoSchema.create(), cond::persistency::IIOVTable.create(), cond::persistency::GTSchema.create(), cond::persistency::PAYLOAD::Table.create(), cond::persistency::ITagAccessPermissionTable.create(), tkal_create_file_lists.FileListCreator.create(), cond::persistency::ITagLogTable.create(), cond::persistency::IIOVSchema.create(), cond::persistency::IOV::Table.create(), cond::persistency::IGTTable.create(), cond::persistency::IGTMapTable.create(), cond::persistency::IGTSchema.create(), cond::persistency::TAG_AUTHORIZATION::Table.create(), cond::persistency::IRunInfoTable.create(), cond::persistency::IRunInfoSchema.create(), cond::persistency::TAG_LOG::Table.create(), cond::persistency::IOVSchema.create(), o2olib.O2OTool.create(), o2olib.O2OTool.disable(), o2olib.O2OTool.dumpConf(), TritonService::FallbackOpts.enable, core.PileUpAnalyzer.PileUpAnalyzer.enable, o2olib.O2OTool.enable(), o2olib.O2OTool.listConf(), o2olib.O2OJobMgr.listJobs(), o2olib.O2OTool.listJobs(), splitter.FileObj.run, uploader.FileObj.run, uploadPayloads.FileObj.run, RPCRunIOV::RunIOV_Item.run, beamspot::BeamSpotContainer.run, TB06Reco.run, TB06RecoH2.run, RPCDQMObject.run, MultiEventFilter::Event.run, DTCalibrationWorker.DTCalibrationWorker.run(), L1Analysis::L1AnalysisEventDataFormat.run, cond::Utilities.run(), TrackInfoProducerAlgorithm.run(), PFEGammaToCandidateRemapper.run(), SurveyAlignmentAlgorithm.run(), EfficiencyPlotter.run, lumi::Lumi2DB::LumiSource.run, generateEDF.LumiInfo.run, WZInterestingEventSelector::event.run, MuonRecoTest.run, crabWrapper.CrabWrapper.run(), MatacqProducer::MatacqEventId.run, options.ConnectionHLTMenu.run, DTResolutionAnalysisTest.run, DTWorkflow.DTWorkflow.run(), Point.run, HIPAlignmentAlgorithm.run(), BeamSpotRcdReader::theBSfromDB.run, DTDataIntegrityTest.run, BeamSpotOnlineRecordsReader::theBSOfromDB.run, DTBlockedROChannelsTest.run, CSCOverlapsAlignmentAlgorithm.run(), ConstantStepOdeSolver.run(), DTChamberEfficiencyTest.run, DTResolutionTest.run, ME::Header.run, DTEfficiencyTest.run, ApeSettingAlgorithm.run(), MuonAlignmentFromReference.run(), DQMNet::CoreObject.run, personalPlayback.Playback.run, MillePedeAlignmentAlgorithm.run(), DTLocalTriggerBaseTest.run, MatrixUtil.InputInfo.run, EcalDeadCellDeltaRFilter.run, QIE8Simulator.run(), HitEff.run, cond::RunInfo_t.run, AlignmentAlgorithmBase.run(), SiPixelErrorEstimation.run, personalPlayback.FrameworkJob.run, SiPixelTrackingRecHitsValid.run, dqm_interfaces.DirWalkerFile.run, o2olib.O2OTool.run(), JsonOutputProducer::JsonEvent.run, SummaryOutputProducer.run, SummaryOutputProducer::Event.run, o2olib.O2OJobMgr.setConfig(), o2olib.O2OTool.setConfig(), o2olib.O2OTool.setFrequent(), o2olib.O2OJobMgr.setInterval(), o2olib.O2OTool.setInterval(), EcalGeomPhiSymHelper.setup(), HBHERecalibration.setup(), event.Event.setup, HcalTPGScale.setup(), HcalPedestalAnalysis.setup(), CastorPedestalAnalysis.setup(), CaloTPGTranscoderULUT.setup(), querying.connection.setup(), NamedCandCombinerBase.setup(), mps_alisetup.SetupAlignment.setup(), CandCombinerBase< OutputCollection, CandPtr >.setup(), CandCombiner< Selector, PairSelector, Cloner, OutputCollection, Setup >.setup(), looper.Looper.setup, options.HLTProcessOptions.setup, o2olib.O2OTool.setup(), and HcalObjRepresent::ADataRepr.setup().

436  def execute(self):
437  parser = argparse.ArgumentParser(description='CMS o2o command-line tool. For general help (manual page), use the help subcommand.')
438  parser.add_argument('--db', type=str, help='The target database: pro ( for prod ) or dev ( for prep ). default=pro')
439  parser.add_argument("--auth","-a", type=str, help="The path of the authentication file")
440  parser.add_argument('--verbose', '-v', action='count', help='The verbosity level')
441  parser_subparsers = parser.add_subparsers(title='Available subcommands')
442  parser_create = parser_subparsers.add_parser('create', description='Create a new O2O job')
443  parser_create.add_argument('--name', '-n', type=str, help='The o2o job name',required=True)
444  parser_create.add_argument('--configFile', '-c', type=str, help='the JSON configuration file path')
445  parser_create.add_argument('--configString', '-s', type=str, help='the JSON configuration string')
446  parser_create.add_argument('--interval', '-i', type=int, help='the chron job interval',default=0)
447  parser_create.add_argument('--frequent', '-f',action='store_true',help='set the "frequent" flag for this job ("false" by default)')
448  parser_create.set_defaults(func=self.create,role=auth.admin_role)
449  parser_setConfig = parser_subparsers.add_parser('setConfig', description='Set a new configuration for the specified job. The configuration is expected as a list of entries "param": "value" (dictionary). The "param" labels will be used to inject the values in the command to execute. The dictionary is stored in JSON format.')
450  parser_setConfig.add_argument('--name', '-n', type=str, help='The o2o job name',required=True)
451  parser_setConfig.add_argument('--configFile', '-c', type=str, help='the JSON configuration file path')
452  parser_setConfig.add_argument('--configString', '-s', type=str, help='the JSON configuration string')
453  parser_setConfig.set_defaults(func=self.setConfig,role=auth.admin_role)
454  parser_setFrequent = parser_subparsers.add_parser('setFrequent',description='Set the "frequent" flag for the specified job')
455  parser_setFrequent.add_argument('--name', '-n', type=str, help='The o2o job name',required=True)
456  parser_setFrequent.add_argument('--flag', '-f', choices=['0','1'], help='the flag value to set',required=True)
457  parser_setFrequent.set_defaults(func=self.setFrequent,role=auth.admin_role)
458  parser_setInterval = parser_subparsers.add_parser('setInterval',description='Set a new execution interval for the specified job')
459  parser_setInterval.add_argument('--name', '-n', type=str, help='The o2o job name',required=True)
460  parser_setInterval.add_argument('--interval', '-i', type=int, help='the chron job interval',required=True)
461  parser_setInterval.set_defaults(func=self.setInterval,role=auth.admin_role)
462  parser_enable = parser_subparsers.add_parser('enable',description='enable the O2O job')
463  parser_enable.add_argument('--name', '-n', type=str, help='The o2o job name',required=True)
464  parser_enable.set_defaults(func=self.enable,role=auth.admin_role)
465  parser_disable = parser_subparsers.add_parser('disable',description='disable the O2O job')
466  parser_disable.add_argument('--name', '-n', type=str, help='The o2o job name',required=True)
467  parser_disable.set_defaults(func=self.disable,role=auth.admin_role)
468  parser_listJobs = parser_subparsers.add_parser('listJobs', description='list the registered jobs')
469  parser_listJobs.set_defaults(func=self.listJobs,role=auth.reader_role)
470  parser_listConf = parser_subparsers.add_parser('listConfig', description='shows the configurations for the specified job')
471  parser_listConf.add_argument('--name', '-n', type=str, help='The o2o job name',required=True)
472  parser_listConf.add_argument('--dump', type=int, help='Dump the specified config.',default=0)
473  parser_listConf.set_defaults(func=self.listConf,role=auth.reader_role)
474  parser_dumpConf = parser_subparsers.add_parser('dumpConfig', description='dumps a specific job configuration version')
475  parser_dumpConf.add_argument('versionIndex', type=str,help='the version to dump')
476  parser_dumpConf.add_argument('--name', '-n', type=str, help='The o2o job name',required=True)
477  parser_dumpConf.add_argument('--configFile', '-c', type=str, help='the JSON configuration file name - default:[jobname]_[version].json')
478  parser_dumpConf.set_defaults(func=self.dumpConf,role=auth.reader_role)
479  parser_run = parser_subparsers.add_parser('run', description='Wrapper for O2O jobs execution. Supports input parameter injection from the configuration file associated to the job. The formatting syntax supported are the python ones: "command -paramName {paramLabel}" or "command -paramName %(paramLabel)s". where [paramName] is the name of the parameter required for the command, and [paramLabel] is the key of the parameter entry in the config dictionary (recommended to be equal for clarity!"')
480  parser_run.add_argument('executable', type=str,help='command to execute')
481  parser_run.add_argument('--name', '-n', type=str, help='The o2o job name',required=True)
482  parser_run.set_defaults(func=self.run,role=auth.writer_role)
483 
484  args = parser.parse_args()
485 
486  if args.verbose is not None and args.verbose >=1:
487  self.setup(args)
488  return args.func()
489  else:
490  try:
491  self.setup(args)
492  sys.exit( args.func())
493  except Exception as e:
494  logging.error(e)
495  sys.exit(1)
def listConf
Definition: o2olib.py:556
def listJobs
Definition: o2olib.py:553
def dumpConf
Definition: o2olib.py:559
def setInterval
Definition: o2olib.py:541
def setConfig
Definition: o2olib.py:525
def setFrequent
Definition: o2olib.py:550
def o2olib.O2OTool.listConf (   self)

Definition at line 556 of file o2olib.py.

Referenced by o2olib.O2OTool.execute().

557  def listConf(self):
558  self.mgr.listConfig( self.args.name )
def listConf
Definition: o2olib.py:556
def o2olib.O2OTool.listJobs (   self)

Definition at line 553 of file o2olib.py.

Referenced by o2olib.O2OTool.execute().

554  def listJobs(self):
555  self.mgr.listJobs()
def listJobs
Definition: o2olib.py:553
def o2olib.O2OTool.run (   self)

Definition at line 562 of file o2olib.py.

References o2olib.O2OTool.args.

Referenced by Types.EventID.cppID(), Types.LuminosityBlockID.cppID(), and o2olib.O2OTool.execute().

563  def run(self):
564  rmgr = self.mgr.runManager()
565  return rmgr.executeJob( self.args )
def o2olib.O2OTool.setConfig (   self)

Definition at line 525 of file o2olib.py.

References o2olib.checkConfiguration(), and o2olib.readConfiguration().

Referenced by o2olib.O2OTool.execute().

526  def setConfig(self):
527  configJson = None
528  if self.args.configFile is not None:
529  if self.args.configString is not None:
530  logging.error('Ambigouous input provided: please specify a configFile OR a configString')
531  return False
532  else:
533  configJson = readConfiguration( self.args.configFile )
534  else:
535  if self.args.configString is None:
536  logging.error('No configuration has been provided: please specify "configFile" or "configString" param.')
537  return False
538  else:
539  configJson = checkConfiguration( self.args.configString )
540  self.mgr.setConfig( self.args.name, configJson )
def readConfiguration
Definition: o2olib.py:404
def setConfig
Definition: o2olib.py:525
def checkConfiguration
Definition: o2olib.py:420
def o2olib.O2OTool.setFrequent (   self)

Definition at line 550 of file o2olib.py.

Referenced by o2olib.O2OTool.execute().

551  def setFrequent(self):
552  self.mgr.set( self.args.name, None, int(self.args.flag) )
def setFrequent
Definition: o2olib.py:550
def o2olib.O2OTool.setInterval (   self)

Definition at line 541 of file o2olib.py.

Referenced by o2olib.O2OTool.execute().

542  def setInterval(self):
543  self.mgr.setInterval( self.args.name, self.args.interval )
def setInterval
Definition: o2olib.py:541
def o2olib.O2OTool.setup (   self,
  args 
)

Definition at line 496 of file o2olib.py.

Referenced by o2olib.O2OTool.execute().

497  def setup(self, args):
498  self.args = args
499  db_service = prod_db_service
500  if args.db is not None:
501  if args.db == 'dev' or args.db == 'oradev' :
502  db_service = dev_db_service
503  elif args.db != 'orapro' and args.db != 'onlineorapro' and args.db != 'pro':
504  raise Exception("Database '%s' is not known." %args.db )
505 
506  logLevel = logging.DEBUG if args.verbose is not None and args.verbose >= 1 else logging.INFO
507  self.mgr = O2OJobMgr( logLevel )
508  return self.mgr.connect( db_service, args )

Member Data Documentation

o2olib.O2OTool.args

Definition at line 497 of file o2olib.py.

Referenced by tier0.ResponseError.__init__(), tier0.ResponseError.__str__(), and o2olib.O2OTool.run().

o2olib.O2OTool.mgr

Definition at line 506 of file o2olib.py.