def registerSwitchs(self):
   Script.registerSwitch("T:", "To=", "mail To", self.setTo)
   Script.registerSwitch("F:","From=","mail from", self.setFrom)
   Script.registerSwitch("S:","Subject=","mail Subject",self.setSubject)
   Script.registerSwitch("B:","Body=","mail Body",self.setBody)
   Script.registerSwitch("f:","File=","Body content file",self.setFileName)
   Script.setUsageMessage( '$s -T [email protected] -F [email protected] -S subject -B "My Body\n is ace"' )
예제 #2
0
 def registerCLISwitches( self ):
   """
   add options to dirac option parser
   """
   Script.setUsageMessage( "Script to delete a dirac proxy. Default: delete local proxy only." )
   Script.registerSwitch( "a", "all", "Delete the local and all uploaded proxies (the nuclear option)", self.setDeleteAll )
   Script.registerSwitch( "v:", "vo=", "Delete uploaded proxy for vo name given", self.addVO )
 def registerSwitches(self):
   Script.registerSwitch("P:", "Platform=", "Platform ex. %s" % self.platform, self.setPlatform)
   Script.registerSwitch("N:", "Name=", "Application name", self.setName)
   Script.registerSwitch("V:", "Version=", "Version", self.setVersion)
   Script.registerSwitch("T:", "TarBall=", "Tar ball location", self.setTarBall)
   Script.registerSwitch("C:", "Comment=", "Comment", self.setComment)
   Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1],
                                        '\nUsage:',
                                        '  %s [option|cfgfile] ...\n' % Script.scriptName ] ) )
 def registerSwitch(self):
   """ Register all CLI switches
   """
   Script.registerSwitch("P:", "prods=", "Productions: greater than with gt1234, range with 32-56, list with 34,56", self.setProdID)
   Script.registerSwitch("p", "precise_detail", "Precise detail, slow", self.setFullDetail)
   Script.registerSwitch("v", "verbose", "Verbose output", self.setVerbose)
   Script.registerSwitch("t:", "types=", "Production Types, comma separated, default all", self.setProdTypes)
   Script.registerSwitch("S:", "Statuses=", "Statuses, comma separated, default all", self.setStatuses)
   Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1],
                                       '\nUsage:',
                                       '  %s [option|cfgfile] ...\n' % Script.scriptName ] ) )
예제 #5
0
def registerSwitches():
  '''
    Registers all switches that can be used while calling the script from the
    command line interface.
  '''

  switches = (
    ( 'init',     'Initialize the element to the status in the CS ( applicable for StorageElements )' ),
    ( 'element=', 'Element family to be Synchronized ( Site, Resource or Node ) or `all`' ),
             )

  for switch in switches:
    Script.registerSwitch( '', switch[ 0 ], switch[ 1 ] )
예제 #6
0
def processScriptSwitches():
  
  global vo, dry, doCEs, doSEs
  
  Script.registerSwitch( "V:", "vo=", "Virtual Organization" )
  Script.registerSwitch( "D", "dry", "Dry run" )
  Script.registerSwitch( "C", "ce", "Process Computing Elements" )
  Script.registerSwitch( "S", "se", "Process Storage Elements" )
  
  Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1],
                                       'Usage:',
                                       '  %s [option|cfgfile]' % Script.scriptName ] ) )
  Script.parseCommandLine( ignoreErrors = True )
  
  vo = ''
  dry = False
  doCEs = False
  doSEs = False
  for sw in Script.getUnprocessedSwitches():
    if sw[0] in ( "V", "vo" ):
      vo = sw[1]    
    if sw[0] in ( "D", "dry" ):
      dry = True  
    if sw[0] in ( "C", "ce" ):
      doCEs = True    
    if sw[0] in ( "S", "se" ):
      doSEs = True    
예제 #7
0
 def registerSwitches(self):
   Script.registerSwitch('P:', "Platform=", 'Platform to use', self.setPlatform)
   Script.registerSwitch('p:', "Path=", "Path to the Whizard results directory", self.setPath)
   Script.registerSwitch("V:", "Version=", "Whizard version", self.setVersion)
   Script.registerSwitch('b:', 'BeamSpectra=', 'Beam spectra version', self.setBeamSpectra)
   Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1],
                                        '\nUsage:',
                                        '  %s [option|cfgfile] ...\n' % Script.scriptName ] ) )
def registerSwitches():
  '''
    Registers all switches that can be used while calling the script from the
    command line interface.
  '''
  
  switches = (
    ( 'status=',     'Filter per file status=(New, Offline, Waiting, Failed, StageSubmitted, Staged). If not used, all status values will be taken into account' ),
    ( 'se=',        'Filter per Storage Element. If not used, all storage elements will be taken into account.' ),
    ( 'limit=',        'Limit the number of entries returned.' ),
    (  'showJobs=', 'Whether to ALSO list the jobs asking for these files to be staged'),
             )
  
  for switch in switches:
    Script.registerSwitch( '', switch[ 0 ], switch[ 1 ] )
예제 #9
0
def registerSwitches():
  '''
    Registers all switches that can be used while calling the script from the
    command line interface.
  '''

  Script.registerSwitch("H:", "host=", "BDII host")
  Script.registerSwitch("V:", "vo=", "vo")
  Script.setUsageMessage('\n'.join([__doc__.split('\n')[1],
                                    'Usage:',
                                    '  %s [option|cfgfile] ... <info> <Site|CE>' % Script.scriptName,
                                    'Arguments:',
                                    '  Site:     Name of the Site (i.e. CERN-PROD)',
                                    '  CE:       Name of the CE (i.e. cccreamceli05.in2p3.fr)',
                                    '  info:     Accepted values (ce|ce-state|ce-cluster|ce-vo|site|site-se)']))
예제 #10
0
def registerSwitches():
    """
  Registers all switches that can be used while calling the script from the
  command line interface.
  """

    switches = (
        ("element=", "Element family to be Synchronized ( Site, Resource or Node )"),
        ("name=", "Name, name of the element where the change applies"),
        ("statusType=", "StatusType, if none applies to all possible statusTypes"),
        ("reason=", "Reason to set the Status"),
        ("releaseToken", "Release the token and let the RSS go"),
    )

    for switch in switches:
        Script.registerSwitch("", switch[0], switch[1])
예제 #11
0
def registerSwitches():
  """
  Registers all switches that can be used while calling the script from the
  command line interface.
  """
  
  switches = (
    ( 'element=',     'Element family to be Synchronized ( Site, Resource or Node )' ),
    ( 'name=',        'Name, name of the element where the change applies' ),
    ( 'statusType=',  'StatusType, if none applies to all possible statusTypes' ),
    ( 'reason=',      'Reason to set the Status' ),
    ( 'releaseToken', 'Release the token and let the RSS go' )
             )
  
  for switch in switches:
    Script.registerSwitch( '', switch[ 0 ], switch[ 1 ] )
예제 #12
0
def registerSwitches():
  '''
    Registers all switches that can be used while calling the script from the
    command line interface.
  '''
  
  switches = (
    ( 'element=',     'Element family to be Synchronized ( Site, Resource or Node )' ),
    ( 'name=',        'Name (or comma-separeted list of names) of the element where the change applies' ),
    ( 'statusType=',  'StatusType (or comma-separeted list of names), if none applies to all possible statusTypes' ),
    ( 'status=',      'Status to be changed' ),
    ( 'reason=',      'Reason to set the Status' ),
             )
  
  for switch in switches:
    Script.registerSwitch( '', switch[ 0 ], switch[ 1 ] )
  def _setSwitches(self):
    Script.registerSwitch("S:", "system=", "Systems to check, by default all of them are checked", self._setSystems)
    Script.registerSwitch("M", "modified", "Show entries which differ from the default", self._setShowModified)
    Script.registerSwitch("A", "added", "Show entries which do not exist in ConfigTemplate", self._setShowAdded)
    Script.registerSwitch("U", "missingSection", "Show sections which do not exist in the current configuration",
                          self._setShowMissingSections)
    Script.registerSwitch("O", "missingOption", "Show options which do not exist in the current configuration",
                          self._setShowMissingOptions)

    Script.setUsageMessage('\n'.join([self.__doc__,
                                      'Usage:',
                                      '  %s [option|cfgfile] -[MAUO] [-S <system]' % Script.scriptName]))
    Script.parseCommandLine(ignoreErrors=True)
    if not any([self.showModified, self.showAdded, self.showMissingSections, self.showMissingOptions]):
      LOG.error("\nERROR: Set at least one of the flags M A U O")
      Script.showHelp()
예제 #14
0
def registerSwitches():
    """
    Registers all switches that can be used while calling the script from the
    command line interface.
  """

    switches = (
        ("element=", "Element family to be Synchronized ( Site, Resource or Node )"),
        ("elementType=", "ElementType narrows the search; None if default"),
        ("name=", "ElementName; None if default"),
        ("tokenOwner=", "Owner of the token; None if default"),
        ("statusType=", "StatusType; None if default"),
        ("status=", "Status; None if default"),
    )

    for switch in switches:
        Script.registerSwitch("", switch[0], switch[1])
예제 #15
0
def registerSwitches():
  '''
    Registers all switches that can be used while calling the script from the
    command line interface.
  '''
  
  switches = (
    ( 'element=',     'Element family to be Synchronized ( Site, Resource or Node )' ),
    ( 'elementType=', 'ElementType narrows the search; None if default' ),
    ( 'name=',        'ElementName; None if default' ),
    ( 'tokenOwner=',  'Owner of the token; None if default' ),
    ( 'statusType=',  'StatusType; None if default' ),
    ( 'status=',      'Status; None if default' ),
             )
  
  for switch in switches:
    Script.registerSwitch( '', switch[ 0 ], switch[ 1 ] )
예제 #16
0
def registerSwitches():
  '''
    Registers all switches that can be used while calling the script from the
    command line interface.
  '''

  switches = (('elementType=', 'ElementType narrows the search; None if default'),
              ('element=', 'Element family ( Site, Resource )'),
              ('name=', 'ElementName; None if default'),
              ('setup=', "Setup where the policy section should be retrieved from; 'Defaults' by default"),
              ('file=',
               "Fullpath config file location other then the default one (but for testing use only the original)"),
              ('policy=', "Policy name to be removed")
              )

  for switch in switches:
    Script.registerSwitch('', switch[0], switch[1])
def registerSwitches():
  '''
    Registers all switches that can be used while calling the script from the
    command line interface.
  '''

  switches = (( 'elementType=', 'ElementType narrows the search; None if default' ),
              ( 'element=', 'Element family ( Site, Resource )' ),
              ( 'name=', 'ElementName; None if default' ),
              ( 'setup=', "Setup where the policy section should be retrieved from; 'Defaults' by default" ),
              ( 'file=', "Fullpath config file location other then the default one (but for testing use only the original)" ),
              ( 'policy=', "Policy name to be removed" )
              #( 'statusType=', 'A valid StatusType argument (it admits a comma-separated list of statusTypes); None if default' ),
              #( 'status=', 'A valid Status argument ( Active, Probing, Degraded, Banned, Unknown, Error ); None if default' ),
             )

  for switch in switches:
    Script.registerSwitch( '', switch[ 0 ], switch[ 1 ] )
예제 #18
0
def registerSwitches():
  '''
    Registers all switches that can be used while calling the script from the
    command line interface.
  '''

  switches = ( 
    ( 'element=', 'Element family to be Synchronized ( Site, Resource, Node )' ),
    ( 'tableType=', 'A valid table type (Status, Log, History)' ),
    ( 'name=', 'ElementName; None if default' ),
    ( 'statusType=', 'A valid StatusType argument (it admits a comma-separated list of statusTypes); None if default' ),
    ( 'status=', 'A valid Status argument ( Active, Probing, Degraded, Banned, Unknown, Error ); None if default' ),
    ( 'elementType=', 'ElementType narrows the search; None if default' ),
    ( 'reason=', 'Decision that triggered the assigned status' ),
    ( 'lastCheckTime=', 'Time-stamp setting last time the status & status were checked' ),
    ( 'tokenOwner=', 'Owner of the token ( to specify only with select/delete queries )' ),
             )

  for switch in switches:
    Script.registerSwitch( '', switch[ 0 ], switch[ 1 ] )
예제 #19
0
def registerSwitches():
  '''
    Registers all switches that can be used while calling the script from the
    command line interface.
  '''

  switches = ( 
    ( 'downtimeID=', 'ID of the downtime' ),
    ( 'element=', 'Element (Site, Service) affected by the downtime' ),
    ( 'name=', 'Name of the element' ),
    ( 'startDate=', 'Starting date of the downtime' ),
    ( 'endDate=', 'Ending date of the downtime' ),
    ( 'severity=', 'Severity of the downtime (Warning, Outage)' ),
    ( 'description=', 'Description of the downtime' ),
    ( 'link=', 'URL of the downtime announcement' ),
    ( 'ongoing', 'To force "select" to return the ongoing downtimes' )
             )

  for switch in switches:
    Script.registerSwitch( '', switch[ 0 ], switch[ 1 ] )
예제 #20
0
 def registerCLISwitches(self):
     ProxyGeneration.CLIParams.registerCLISwitches(self)
     Script.registerSwitch("U", "upload", "Upload a long lived proxy to the ProxyManager", self.setUploadProxy)
     Script.registerSwitch(
         "P", "uploadPilot", "Upload a long lived pilot proxy to the ProxyManager", self.setUploadPilotProxy
     )
     Script.registerSwitch("M", "VOMS", "Add voms extension", self.setVOMSExt)
예제 #21
0
def registerSwitches():
  '''
    Registers all switches that can be used while calling the script from the
    command line interface.
  '''

  # Some of the switches have associated a callback, defined on Params class.
  cliParams = Params()

  switches = [
      ('', 'text=', 'Text to be printed'),
      ('u', 'upper', 'Print text on upper case'),
      ('r', 'showRaw', 'Show raw result from the query', cliParams.setRawResult),
      ('p:', 'numPings=', 'Number of pings to do (by default 1)', cliParams.setNumOfPingsToDo)
  ]

  # Register switches
  for switch in switches:
    Script.registerSwitch(*switch)

  # Define a help message
  Script.setUsageMessage(__doc__)
예제 #22
0
def registerSwitches():
    """
    Registers all switches that can be used while calling the script from the
    command line interface.
  """

    switches = (
        ("element=", "Element family to be Synchronized ( Site, Resource, Node )"),
        ("tableType=", "A valid table type (Status, Log, History)"),
        ("name=", "ElementName; None if default"),
        (
            "statusType=",
            "A valid StatusType argument (it admits a comma-separated list of statusTypes); None if default",
        ),
        ("status=", "A valid Status argument ( Active, Probing, Degraded, Banned, Unknown, Error ); None if default"),
        ("elementType=", "ElementType narrows the search; None if default"),
        ("reason=", "Decision that triggered the assigned status"),
        ("lastCheckTime=", "Time-stamp setting last time the status & status were checked"),
        ("tokenOwner=", "Owner of the token ( to specify only with select/delete queries )"),
    )

    for switch in switches:
        Script.registerSwitch("", switch[0], switch[1])
예제 #23
0
def registerSwitches():
  '''
    Registers all switches that can be used while calling the script from the
    command line interface.
  '''

  Script.registerSwitch('', 'init', 'Initialize the element to the status in the CS ( applicable for StorageElements )')
  Script.registerSwitch('', 'element=', 'Element family to be Synchronized ( Site, Resource or Node ) or `all`')
  Script.registerSwitch('', 'defaultStatus=', 'Default element status if not given in the CS')
예제 #24
0
xmlPostPandora = 'lcsimSteeringFiles/sid_dbd_postPandora.xml' # always use the overlay version to create the selected PFO files
marlinXml = 'marlinSteering/sid_dbd_vertexing.xml'
strategyFile = 'trackingStrategies/sidloi3_trackingStrategies_default.xml'
banlistFile = 'bannedSites.py'
gearFile = 'gearFiles/%s.gear'%(detector)
maxFiles = -1
lfnlist = None
lfnFile = None
process = None
debug = True
agentMode = False
destination = None
energy = 1000
preDefinedSetup = None

Script.registerSwitch( 'a:', 'alias=', 'name of the alias.properties file to use (default %s)'%(aliasFile) )
Script.registerSwitch( 'A:', 'agent', 'Submits the job in agent mode, which will run the job on the local machine' )
Script.registerSwitch( 'b:', 'banlist=', 'file with list of banned sites (default %s)'%(banlistFile) )
Script.registerSwitch( 'C:', 'destination=', 'jobs are only submitted to the given site (default %s)'%(destination) )
Script.registerSwitch( 'D:', 'detector=', 'name of the detector model (default %s)'%(detector) )
Script.registerSwitch( 'f:', 'file=', 'define a single lfn file as input' )
Script.registerSwitch( 'F:', 'config=', 'Pre-defined configuration (default %s)'%(preDefinedSetup) )
Script.registerSwitch( 'i:', 'input=', 'input python script holding the lfnlist to process' )
Script.registerSwitch( 'l:', 'prelcsimxml=', 'name of the lcsim steering file used pre pandora (default %s)'%(xmlPrePandora) )
Script.registerSwitch( 'L:', 'lcsim=', 'lcsim version to use (default %s)'%(lcsimVer) )
Script.registerSwitch( 'j:', 'jobs=', 'number of jobs that each input file gets split into (default %s)'%(nJobs) )
Script.registerSwitch( 'm:', 'macro=', 'name of the macro file used for SLIC (default %s)'%(macroFile) )
Script.registerSwitch( 'M:', 'merge=', 'number of slcio input files used per job, only used if no slic step (default %s)'%(mergeSlcioFiles) )
Script.registerSwitch( 'n:', 'events=', 'number of events per job, -1 for all in file (default %s)'%(nEvts) )
Script.registerSwitch( 'p:', 'process=', 'process name to be used for naming of path etc.' )
Script.registerSwitch( 'P:', 'pandora=', 'slicPandora version to use (default %s)'%(slicPandoraVer) )
예제 #25
0
#!/usr/bin/env python
########################################################################
# $HeadURL$
########################################################################
__RCSID__ = "$Id$"

import sys, os
import DIRAC
from DIRAC import gLogger
from DIRAC.Core.Base import Script

unit = 'GB'
Script.registerSwitch( "u:", "Unit=", "   Unit to use [default %s] (MB,GB,TB,PB)" % unit )

Script.setUsageMessage( """
Get the size of the given file or a list of files

Usage:
   %s <lfn | fileContainingLfns> <SE> <status>
""" % Script.scriptName )

Script.parseCommandLine( ignoreErrors = False )
for switch in Script.getUnprocessedSwitches():
  if switch[0].lower() == "u" or switch[0].lower() == "unit":
    unit = switch[1]
scaleDict = { 'MB' : 1000 * 1000.0,
              'GB' : 1000 * 1000 * 1000.0,
              'TB' : 1000 * 1000 * 1000 * 1000.0,
              'PB' : 1000 * 1000 * 1000 * 1000 * 1000.0}
if not unit in scaleDict.keys():
  gLogger.error( "Unit must be one of MB,GB,TB,PB" )
예제 #26
0
#!/usr/bin/env python
""" Get a proxy from the proxy manager
"""
import os

from DIRAC.Core.Base import Script
Script.setUsageMessage('\n'.join([
    __doc__.split('\n')[1], 'Usage:',
    '  %s [option|cfgFile] UserName Role' % Script.scriptName, 'Arguments:',
    '  UserName: User DN'
]))
Script.registerSwitch('R:', 'role=', "set the User DN.")
Script.parseCommandLine()

for unprocSw in Script.getUnprocessedSwitches():
    if unprocSw[0] in ("R", "role"):
        role = unprocSw[1]

args = Script.getPositionalArgs()
dn = ' '.join(args)

uid = os.getuid()
from DIRAC.FrameworkSystem.Client.ProxyManagerClient import gProxyManager

print "Getting proxy for User DN: %s, User role %s" % (dn, role)

res = gProxyManager.downloadProxyToFile(dn,
                                        role,
                                        limited=False,
                                        requiredTimeLeft=1200,
                                        cacheTime=43200,
예제 #27
0
 def registerCLISwitches( self ):
   Script.registerSwitch( "v:", "valid=", "Valid HH:MM for the proxy. By default is 24 hours", self.setProxyLifeTime )
   Script.registerSwitch( "l", "limited", "Get a limited proxy", self.setLimited )
   Script.registerSwitch( "u:", "out=", "File to write as proxy", self.setProxyLocation )
   Script.registerSwitch( "a", "voms", "Get proxy with VOMS extension mapped to the DIRAC group", self.automaticVOMS )
   Script.registerSwitch( "m:", "vomsAttr=", "VOMS attribute to require", self.setVOMSAttr )
예제 #28
0
#!/usr/bin/env python
########################################################################
# $HeadURL$
# File :    dirac-admin-modify-user
# Author :  Adrian Casajus
########################################################################
"""
  Modify a user in the CS.
"""
__RCSID__ = "$Id$"
import DIRAC
from DIRAC.Core.Base import Script

Script.registerSwitch("p:", "property=",
                      "Add property to the user <name>=<value>")
Script.registerSwitch("f", "force", "create the user if it doesn't exist")

Script.setUsageMessage('\n'.join([
    __doc__.split('\n')[1], 'Usage:',
    '  %s [option|cfgfile] ... user DN group [group] ...' % Script.scriptName,
    'Arguments:', '  user:     User name', '  DN:       DN of the User',
    '  group:    Add the user to the group'
]))
Script.parseCommandLine(ignoreErrors=True)

args = Script.getPositionalArgs()

if len(args) < 3:
    Script.showHelp()

from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin
예제 #29
0
 def registerCLISwitches(self):
     Script.registerSwitch("v:", "valid=", "Required HH:MM for the users",
                           self.setProxyLifeTime)
예제 #30
0
 def registerSwitch(self):
   """registers switches"""
   Script.registerSwitch('D:', 'LogFileDir=', 'Production log dir to download', self.setLogFileD)
   Script.registerSwitch('F:', 'LogFile=', 'Production log to download', self.setLogFileF)
   Script.registerSwitch('O:', 'OutputDir=', 'Output directory (default %s)' % self.outputdir, 
                         self.setOutputDir)
   Script.registerSwitch('P:', 'ProdID=', 'Production ID', self.setProdID)
   Script.registerSwitch('A', 'All', 'Get logs from all sub-directories', self.setAllGet)
   Script.registerSwitch('N', 'NoPrompt', 'No prompt before download', self.setNoPrompt)
   Script.setUsageMessage('%s -F /ilc/prod/.../LOG/.../somefile' % Script.scriptName)
예제 #31
0
import re
import ConfigParser
import json

from DIRAC import S_OK, S_ERROR, gLogger, exit
from DIRAC.Core.Base import Script

Script.setUsageMessage('''Create JUNO reconstruction from existing detsim datas

{0} [option|cfgfile] [process]

Example: {0} --example > rec.ini
Example: {0} --ini rec.ini
Example: {0} Chain
Example: {0} --ini rec.ini --dryrun'''.format(Script.scriptName))
Script.registerSwitch('i:', 'ini=', 'Ini file, default to "rec.ini"')
Script.registerSwitch(
    'r', 'dryrun',
    'Only parse the configuration, do not submit transformation')
Script.registerSwitch('e', 'example', 'Display rec.ini example')
Script.parseCommandLine(ignoreErrors=False)

from DIRAC.ConfigurationSystem.Client.Helpers import Registry
from DIRAC.Core.Security.ProxyInfo import getProxyInfo
from DIRAC.Resources.Catalog.FileCatalogClient import FileCatalogClient

from DIRAC.TransformationSystem.Client.Transformation import Transformation
from DIRAC.TransformationSystem.Client.TransformationClient import TransformationClient
from DIRAC.Core.Workflow.Parameter import Parameter

from DIRAC.Interfaces.API.Job import Job
# Author :  Stuart Paterson
########################################################################
"""
  Retrieve input sandbox for DIRAC Job
"""
__RCSID__ = "$Id$"
import DIRAC
from DIRAC.Core.Base import Script
import os

Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1],
                                     'Usage:',
                                     '  %s [option|cfgfile] ... JobID ...' % Script.scriptName,
                                     'Arguments:',
                                     '  JobID:    DIRAC Job ID' ] ) )
Script.registerSwitch( "D:", "Dir=", "Store the output in this directory" )
Script.parseCommandLine( ignoreErrors = True )
args = Script.getPositionalArgs()

if len( args ) < 1:
  Script.showHelp()

from DIRAC.Interfaces.API.Dirac                              import Dirac
dirac = Dirac()
exitCode = 0
errorList = []

outputDir = None
for sw, v in Script.getUnprocessedSwitches():
  if sw in ( 'D', 'Dir' ):
    outputDir = v
예제 #33
0
def setRegisterChecksum(arg):
    global registerChecksum
    registerChecksum = True
    return S_OK()


# Define a help message
Script.setUsageMessage("""
Eiscat file catalog client to work in the top of EISCAT filesystem

Usage:
   %s [option]
""" % Script.scriptName)

# Register accepted switches and their callbacks
Script.registerSwitch("y:", "listyear=", "Year folder to process (mandatory)",
                      setlistyear)
Script.registerSwitch(
    "u", "updatemeta",
    "If entry in catalogue, update metadata information (optional)",
    setupdatemeta)
Script.registerSwitch("p", "progressbar", "Show progress bar (optional)",
                      setpbar)
Script.registerSwitch("C", "checksum", "Register file checksum",
                      setRegisterChecksum)

Script.parseCommandLine(ignoreErrors=False)

# Check that year was given
if listyear == None:
    Script.showHelp()
    DIRAC.exit(-1)
#! /usr/bin/env python
########################################################################
# $HeadURL$
# File :    dirac-admin-bdii-ce-state
# Author :  Adria Casajus
########################################################################
"""
  Check info on BDII for CE state
"""
__RCSID__ = "$Id$"
import DIRAC
from DIRAC.Core.Base                                         import Script
from DIRAC.ConfigurationSystem.Client.Helpers                import getVO

Script.registerSwitch( "H:", "host=", "BDII host" )
Script.registerSwitch( "V:", "vo=", "vo" )
Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1],
                                     'Usage:',
                                     '  %s [option|cfgfile] ... CE' % Script.scriptName,
                                     'Arguments:',
                                     '  CE:       Name of the CE(ie: ce111.cern.ch)'] ) )

Script.parseCommandLine( ignoreErrors = True )
args = Script.getPositionalArgs()

from DIRAC.Interfaces.API.DiracAdmin                         import DiracAdmin

if not len( args ) == 1:
  Script.showHelp()

ce = args[0]
예제 #35
0
 def registerCLISwitches( self ):
   ProxyGeneration.CLIParams.registerCLISwitches( self )
   Script.registerSwitch( "U", "upload", "Upload a long lived proxy to the ProxyManager", self.setUploadProxy )
   Script.registerSwitch( "P", "uploadPilot", "Upload a long lived pilot proxy to the ProxyManager", self.setUploadPilotProxy )
   Script.registerSwitch( "M", "VOMS", "Add voms extension", self.setVOMSExt )
예제 #36
0
    global vo
    vo = optionValue
    Script.localCfg.addDefaultEntry('/DIRAC/VirtualOrganization', vo)
    DIRAC.gConfig.setOptionValue(cfgInstallPath('VirtualOrganization'), vo)
    return DIRAC.S_OK()


def forceUpdate(optionValue):
    global update
    update = True
    return DIRAC.S_OK()


Script.disableCS()

Script.registerSwitch("S:", "Setup=", "Set <setup> as DIRAC setup", setSetup)
Script.registerSwitch("C:", "ConfigurationServer=",
                      "Set <server> as DIRAC configuration server", setServer)
Script.registerSwitch("I", "IncludeAllServers",
                      "include all Configuration Servers", setAllServers)
Script.registerSwitch("n:", "SiteName=", "Set <sitename> as DIRAC Site Name",
                      setSiteName)
Script.registerSwitch("N:", "CEName=", "Determiner <sitename> from <cename>",
                      setCEName)
Script.registerSwitch("V:", "VO=", "Set the VO name", setVO)

Script.registerSwitch("W:", "gateway=",
                      "Configure <gateway> as DIRAC Gateway for the site",
                      setGateway)

Script.registerSwitch("U", "UseServerCertificate",
예제 #37
0
from DIRAC.Core.Base import Script

read = True
write = True
check = True
site = ''
mute = False

Script.setUsageMessage("""
Enable using one or more Storage Elements

Usage:
   %s SE1 [SE2 ...]
""" % Script.scriptName)

Script.registerSwitch("r", "AllowRead",
                      "     Allow only reading from the storage element")
Script.registerSwitch("w", "AllowWrite",
                      "     Allow only writing to the storage element")
Script.registerSwitch("k", "AllowCheck",
                      "     Allow only check access to the storage element")
Script.registerSwitch("m", "Mute", "     Do not send email")
Script.registerSwitch("S:", "Site=", "     Allow all SEs associated to site")

Script.parseCommandLine(ignoreErrors=True)

ses = Script.getPositionalArgs()
for switch in Script.getUnprocessedSwitches():
    if switch[0].lower() == "r" or switch[0].lower() == "allowread":
        write = False
        check = False
    if switch[0].lower() == "w" or switch[0].lower() == "allowwrite":
예제 #38
0
    if not arg:
        Script.showHelp()
        DIRAC.exit(-1)
    if not arg in hostProperties:
        hostProperties.append(arg)


Script.setUsageMessage('\n'.join([
    'Add or Modify a Host info in DIRAC',
    'Usage:',
    '%s [option|cfgfile] ... Property=<Value> ...' % Script.scriptName,
    'Arguments:',
    ' Property=<Value>: Other properties to be added to the User like (Responsible=XXXX)',
]))

Script.registerSwitch('H:', 'HostName:', 'Name of the Host (Mandatory)',
                      setHostName)
Script.registerSwitch('D:', 'HostDN:',
                      'DN of the Host Certificate (Mandatory)', setHostDN)
Script.registerSwitch(
    'P:', 'Property:',
    'Property to be added to the Host (Allow Multiple instances or None)',
    addProperty)

Script.parseCommandLine(ignoreErrors=True)

if hostName == None or hostDN == None:
    Script.showHelp()
    DIRAC.exit(-1)

args = Script.getPositionalArgs()
예제 #39
0
  """
    global uuid
    uuid = optVal
    return S_OK()


def setJobID(optVal):
    """
  Set JobID from arguments
  """
    global jobid
    jobid = optVal
    return S_OK()


Script.registerSwitch('u:', 'uuid=', 'get PilotsLogging for given Pilot UUID',
                      setUUID)
Script.registerSwitch('j:', 'jobid=', 'get PilotsLogging for given Job ID',
                      setJobID)

Script.setUsageMessage('\n'.join([
    __doc__.split('\n')[1], 'Usage:',
    '  %s option value ' % Script.scriptName,
    'Only one option (either uuid or jobid) should be used.'
]))

Script.parseCommandLine()

from DIRAC.WorkloadManagementSystem.Client.PilotManagerClient import PilotManagerClient

if jobid:
    result = PilotManagerClient().getPilots(jobid)
예제 #40
0
from DIRAC import S_OK
#
InstallTools.exitOnError = True
#
from DIRAC.Core.Base import Script
Script.disableCS()
Script.setUsageMessage('\n'.join([
    __doc__.split('\n')[1],
    'Usage:',
    '  %s [option|cfgfile] ...' % Script.scriptName,
    'Arguments:',
]))

old = False


def setOld(opVal):
    global old
    old = True
    return S_OK()


Script.registerSwitch("O", "--old", "install old Pylons based portal", setOld)

Script.parseCommandLine()

if old:
    result = InstallTools.setupPortal()
else:
    result = InstallTools.setupNewPortal()
예제 #41
0
#!/usr/bin/env python
########################################################################
# $HeadURL$
# File :    dirac-wms-job-get-jdl
# Author :  Stuart Paterson
########################################################################
"""
  Retrieve the current JDL of a DIRAC job
"""
from __future__ import print_function
__RCSID__ = "$Id$"
import DIRAC
from DIRAC.Core.Base import Script

original = False
Script.registerSwitch('O', 'Original', 'Gets the original JDL')
Script.setUsageMessage('\n'.join([
    __doc__.split('\n')[1], 'Usage:',
    '  %s [option|cfgfile] ... JobID ...' % Script.scriptName, 'Arguments:',
    '  JobID:    DIRAC Job ID'
]))
Script.parseCommandLine(ignoreErrors=True)
args = Script.getPositionalArgs()

for switch in Script.getUnprocessedSwitches():
    if switch[0] == 'Original' or switch[0] == 'O':
        original = True

for switch in Script.getUnprocessedSwitches():
    if switch[0] == 'Original':
        original = True
예제 #42
0
"""Create and put 'ReplicateAndRegister' request."""
__RCSID__ = "$Id$"
import os
from DIRAC.Core.Base import Script
from DIRAC import gLogger
import DIRAC
Script.setUsageMessage( '\n'.join( [ __doc__,
                                     'Usage:',
                                     ' %s [option|cfgfile] requestName LFNs targetSE1 [targetSE2 ...]' % Script.scriptName,
                                     'Arguments:',
                                     ' requestName: a request name',
                                     '        LFNs: single LFN or file with LFNs',
                                     '    targetSE: target SE' ] ) )

catalog = None
Script.registerSwitch("C:", "Catalog=", "Catalog to use")
Script.parseCommandLine()
for switch in Script.getUnprocessedSwitches():
  if switch[0] == "C" or switch[0].lower() == "catalog":
    catalog = switch[1]

def getLFNList( arg ):
  """ get list of LFNs """
  lfnList = []
  if os.path.exists( arg ):
     lfnList = [line.split()[0] for line in open( arg ).read().splitlines()]
  else:
    lfnList = [ arg ]
  return list( set ( lfnList ) )

# # execution
예제 #43
0
def main():

    from DIRAC.Core.Base import Script

    Script.registerSwitch("p:", "inputfile=", "Input File", setInputFile)
    Script.registerSwitch("E:", "simtelExecName=", "SimtelExecName",
                          setExecutable)
    Script.registerSwitch("S:", "simtelConfig=", "SimtelConfig", setConfig)
    Script.registerSwitch("V:", "version=", "Version", setVersion)
    Script.registerSwitch("D:", "storage_element=", "Storage Element",
                          setStorageElement)

    from DIRAC.Resources.Catalog.FileCatalogClient import FileCatalogClient
    from DIRAC.Resources.Catalog.FileCatalog import FileCatalog

    Script.parseCommandLine()
    DIRAC.gLogger.setLevel('INFO')

    global fcc, fcL, storage_element

    from CTADIRAC.Core.Utilities.SoftwareInstallation import checkSoftwarePackage
    from CTADIRAC.Core.Utilities.SoftwareInstallation import installSoftwarePackage
    from CTADIRAC.Core.Utilities.SoftwareInstallation import installSoftwareEnviron
    from CTADIRAC.Core.Utilities.SoftwareInstallation import localArea
    from CTADIRAC.Core.Utilities.SoftwareInstallation import sharedArea
    from CTADIRAC.Core.Utilities.SoftwareInstallation import workingArea
    from DIRAC.Core.Utilities.Subprocess import systemCall
    from DIRAC.WorkloadManagementSystem.Client.JobReport import JobReport

    jobID = os.environ['JOBID']
    jobID = int(jobID)
    jobReport = JobReport(jobID)

    ###########
    ## Checking MD coherence
    fc = FileCatalog('LcgFileCatalog')
    res = fc._getCatalogConfigDetails('DIRACFileCatalog')
    print 'DFC CatalogConfigDetails:', res
    res = fc._getCatalogConfigDetails('LcgFileCatalog')
    print 'LCG CatalogConfigDetails:', res

    fcc = FileCatalogClient()
    fcL = FileCatalog('LcgFileCatalog')

    from DIRAC.Interfaces.API.Dirac import Dirac
    dirac = Dirac()
    ############################

    #############
    # simtelConfigFile should be built from ???
    #simtelConfigFilesPath = 'sim_telarray/multi'
    #simtelConfigFile = simtelConfigFilesPath + '/multi_cta-ultra5.cfg'
    #createGlobalsFromConfigFiles(simtelConfigFile)
    #createGlobalsFromConfigFiles(current_version)
    #######################
    ## files spread in 1000-runs subDirectories

    corsikaFileName = os.path.basename(corsikaFileLFN)
    run_number = corsikaFileName.split('run')[1].split('.corsika.gz')[
        0]  # run001412.corsika.gz

    runNum = int(run_number)
    subRunNumber = '%03d' % runNum
    runNumModMille = runNum % 1000
    runNumTrunc = (runNum - runNumModMille) / 1000
    runNumSeriesDir = '%03dxxx' % runNumTrunc
    print 'runNumSeriesDir=', runNumSeriesDir

    f = open('DISABLE_WATCHDOG_CPU_WALLCLOCK_CHECK', 'w')
    f.close()

    ##### If storage element is IN2P3-tape save simtel file on disk ###############
    if storage_element == 'CC-IN2P3-Tape':
        storage_element = 'CC-IN2P3-Disk'

############ Producing SimTel File
######################Building simtel Directory Metadata #######################

    cfg_dict = {
        "4MSST": 'cta-prod2-4m-dc',
        "SCSST": 'cta-prod2-sc-sst',
        "STD": 'cta-prod2',
        "NSBX3": 'cta-prod2',
        "ASTRI": 'cta-prod2-astri',
        "SCMST": 'cta-prod2-sc3'
    }

    if simtelConfig == "6INROW":
        all_configs = ["SCMST", "4MSST", "SCSST", "ASTRI", "NSBX3", "STD"]
    elif simtelConfig == "5INROW":
        all_configs = ["4MSST", "SCSST", "ASTRI", "NSBX3", "STD"]
    else:
        all_configs = [simtelConfig]

    for current_conf in all_configs:

        DIRAC.gLogger.notice('current conf is', current_conf)

        if current_conf == "SCMST":
            current_version = version + '_sc3'
        else:
            current_version = version
            if os.path.isdir('sim_telarray'):
                DIRAC.gLogger.notice(
                    'Package found in the local area. Removing package...')
                cmd = 'rm -R sim_telarray corsika-6990 hessioxxx corsika-run'
                if (os.system(cmd)):
                    DIRAC.exit(-1)

        DIRAC.gLogger.notice('current version is', current_version)
        CorsikaSimtelPack = 'corsika_simhessarray/' + current_version + '/corsika_simhessarray'

        packs = [CorsikaSimtelPack]

        for package in packs:
            DIRAC.gLogger.notice('Checking:', package)
            if sharedArea:
                if checkSoftwarePackage(package, sharedArea())['OK']:
                    DIRAC.gLogger.notice('Package found in Shared Area:',
                                         package)
                    installSoftwareEnviron(package, workingArea())
                    packageTuple = package.split('/')
                    corsika_subdir = sharedArea(
                    ) + '/' + packageTuple[0] + '/' + current_version
                    cmd = 'cp -u -r ' + corsika_subdir + '/* .'
                    os.system(cmd)
                    continue

            DIRAC.gLogger.error('Check Failed for software package:', package)
            DIRAC.gLogger.error('Software package not available')
            DIRAC.exit(-1)

        createGlobalsFromConfigFiles(current_version)

        resultCreateSimtelDirMD = createSimtelFileSystAndMD(
            current_conf, current_version)
        if not resultCreateSimtelDirMD['OK']:
            DIRAC.gLogger.error('Failed to create simtelArray Directory MD')
            jobReport.setApplicationStatus(
                'Failed to create simtelArray Directory MD')
            DIRAC.gLogger.error(
                'Metadata coherence problem, no simtelArray File produced')
            DIRAC.exit(-1)
        else:
            print 'simtel Directory MD successfully created'

############## introduce file existence check here ########################
        simtelFileName = particle + '_' + str(thetaP) + '_' + str(
            phiP) + '_alt' + str(
                obslev) + '_' + 'run' + run_number + '.simtel.gz'
        simtelDirPath_conf = simtelDirPath + '_' + current_conf
        simtelOutFileDir = os.path.join(simtelDirPath_conf, 'Data',
                                        runNumSeriesDir)
        simtelOutFileLFN = os.path.join(simtelOutFileDir, simtelFileName)

        res = CheckCatalogCoherence(simtelOutFileLFN)
        if res == DIRAC.S_OK:
            DIRAC.gLogger.notice('Current conf already done', current_conf)
            continue

#### execute simtelarray ################
        fd = open('run_sim.sh', 'w')
        fd.write("""#! /bin/sh  
  export SVNPROD2=$PWD
  export SVNTAG=SVN-PROD2_rev1869
  export CORSIKA_IO_BUFFER=800MB
  ./grid_prod2-repro.sh %s %s""" % (corsikaFileName, current_conf))
        fd.close()

        os.system('chmod u+x run_sim.sh')

        cmdTuple = ['./run_sim.sh']
        ret = systemCall(0, cmdTuple, sendOutputSimTel)
        simtelReturnCode, stdout, stderr = ret['Value']

        if (os.system('grep Broken simtel.log')):
            DIRAC.gLogger.notice('not broken')
        else:
            DIRAC.gLogger.notice('broken')

            # Tag corsika File if Broken Pipe
            corsikaTagMD = {}
            corsikaTagMD['CorsikaToReprocess'] = 'CorsikaToReprocess'
            result = fcc.setMetadata(corsikaFileLFN, corsikaTagMD)
            print "result setMetadata=", result
            if not result['OK']:
                print 'ResultSetMetadata:', result['Message']

            jobReport.setApplicationStatus('Broken pipe')
            DIRAC.exit(-1)

        if not ret['OK']:
            DIRAC.gLogger.error('Failed to execute run_sim.sh')
            DIRAC.gLogger.error('run_sim.sh status is:', simtelReturnCode)
            DIRAC.exit(-1)

## putAndRegister simtel data/log/histo Output File:
        cfg = cfg_dict[current_conf]
        cmd = 'mv Data/sim_telarray/' + cfg + '/0.0deg/Data/*.simtel.gz ' + simtelFileName
        if (os.system(cmd)):
            DIRAC.exit(-1)

############################################
        simtelRunNumberSeriesDirExist = fcc.isDirectory(
            simtelOutFileDir)['Value']['Successful'][simtelOutFileDir]
        newSimtelRunFileSeriesDir = (
            simtelRunNumberSeriesDirExist != True
        )  # if new runFileSeries, will need to add new MD

        simtelLogFileName = particle + '_' + str(thetaP) + '_' + str(
            phiP) + '_alt' + str(obslev) + '_' + 'run' + run_number + '.log.gz'
        cmd = 'mv Data/sim_telarray/' + cfg + '/0.0deg/Log/*.log.gz ' + simtelLogFileName
        if (os.system(cmd)):
            DIRAC.exit(-1)
        simtelOutLogFileDir = os.path.join(simtelDirPath_conf, 'Log',
                                           runNumSeriesDir)
        simtelOutLogFileLFN = os.path.join(simtelOutLogFileDir,
                                           simtelLogFileName)

        simtelHistFileName = particle + '_' + str(thetaP) + '_' + str(
            phiP) + '_alt' + str(
                obslev) + '_' + 'run' + run_number + '.hdata.gz'
        cmd = 'mv Data/sim_telarray/' + cfg + '/0.0deg/Histograms/*.hdata.gz ' + simtelHistFileName
        if (os.system(cmd)):
            DIRAC.exit(-1)
        simtelOutHistFileDir = os.path.join(simtelDirPath_conf, 'Histograms',
                                            runNumSeriesDir)
        simtelOutHistFileLFN = os.path.join(simtelOutHistFileDir,
                                            simtelHistFileName)

        ################################################
        DIRAC.gLogger.notice('Put and register simtel File in LFC and DFC:',
                             simtelOutFileLFN)
        ret = dirac.addFile(simtelOutFileLFN, simtelFileName, storage_element)

        res = CheckCatalogCoherence(simtelOutFileLFN)
        if res != DIRAC.S_OK:
            DIRAC.gLogger.error('Job failed: Catalog Coherence problem found')
            jobReport.setApplicationStatus('OutputData Upload Error')
            DIRAC.exit(-1)

        if not ret['OK']:
            DIRAC.gLogger.error('Error during addFile call:', ret['Message'])
            jobReport.setApplicationStatus('OutputData Upload Error')
            DIRAC.exit(-1)
######################################################################

        res = CheckCatalogCoherence(simtelOutLogFileLFN)
        if res == DIRAC.S_OK:
            DIRAC.gLogger.notice('Log file already exists. Removing:',
                                 simtelOutLogFileLFN)
            ret = dirac.removeFile(simtelOutLogFileLFN)

        DIRAC.gLogger.notice(
            'Put and register simtel Log File in LFC and DFC:',
            simtelOutLogFileLFN)
        ret = dirac.addFile(simtelOutLogFileLFN, simtelLogFileName,
                            storage_element)

        res = CheckCatalogCoherence(simtelOutLogFileLFN)
        if res != DIRAC.S_OK:
            DIRAC.gLogger.error('Job failed: Catalog Coherence problem found')
            jobReport.setApplicationStatus('OutputData Upload Error')
            DIRAC.exit(-1)

        if not ret['OK']:
            DIRAC.gLogger.error('Error during addFile call:', ret['Message'])
            jobReport.setApplicationStatus('OutputData Upload Error')
            DIRAC.exit(-1)
######################################################################

        res = CheckCatalogCoherence(simtelOutHistFileLFN)
        if res == DIRAC.S_OK:
            DIRAC.gLogger.notice('Histo file already exists. Removing:',
                                 simtelOutHistFileLFN)
            ret = dirac.removeFile(simtelOutHistFileLFN)

        DIRAC.gLogger.notice(
            'Put and register simtel Histo File in LFC and DFC:',
            simtelOutHistFileLFN)
        ret = dirac.addFile(simtelOutHistFileLFN, simtelHistFileName,
                            storage_element)

        res = CheckCatalogCoherence(simtelOutHistFileLFN)
        if res != DIRAC.S_OK:
            DIRAC.gLogger.error('Job failed: Catalog Coherence problem found')
            jobReport.setApplicationStatus('OutputData Upload Error')
            DIRAC.exit(-1)

        if not ret['OK']:
            DIRAC.gLogger.error('Error during addFile call:', ret['Message'])
            jobReport.setApplicationStatus('OutputData Upload Error')
            DIRAC.exit(-1)
######################################################################

        if newSimtelRunFileSeriesDir:
            insertRunFileSeriesMD(simtelOutFileDir, runNumTrunc)
            insertRunFileSeriesMD(simtelOutLogFileDir, runNumTrunc)
            insertRunFileSeriesMD(simtelOutHistFileDir, runNumTrunc)


###### simtel File level metadata ############################################
        simtelFileMD = {}
        simtelFileMD['runNumber'] = int(run_number)
        simtelFileMD['jobID'] = jobID
        simtelFileMD['simtelReturnCode'] = simtelReturnCode

        result = fcc.setMetadata(simtelOutFileLFN, simtelFileMD)
        print "result setMetadata=", result
        if not result['OK']:
            print 'ResultSetMetadata:', result['Message']

        result = fcc.setMetadata(simtelOutLogFileLFN, simtelFileMD)
        print "result setMetadata=", result
        if not result['OK']:
            print 'ResultSetMetadata:', result['Message']

        result = fcc.setMetadata(simtelOutHistFileLFN, simtelFileMD)
        print "result setMetadata=", result
        if not result['OK']:
            print 'ResultSetMetadata:', result['Message']

        result = fcc.addFileAncestors(
            {simtelOutFileLFN: {
                'Ancestors': [corsikaFileLFN]
            }})
        print 'result addFileAncestor:', result

        result = fcc.addFileAncestors(
            {simtelOutLogFileLFN: {
                'Ancestors': [corsikaFileLFN]
            }})
        print 'result addFileAncestor:', result

        result = fcc.addFileAncestors(
            {simtelOutHistFileLFN: {
                'Ancestors': [corsikaFileLFN]
            }})
        print 'result addFileAncestor:', result

        result = fcc.setMetadata(simtelOutFileLFN, simtelFileMD)
        if not result['OK']:
            print 'ResultSetMetadata:', result['Message']

    DIRAC.exit()
예제 #44
0
  Retrieve output sandbox for a DIRAC job
"""
__RCSID__ = "$Id$"

import DIRAC
from DIRAC.Core.Base import Script

import os, shutil, datetime

Script.setUsageMessage('\n'.join([
    __doc__.split('\n')[1], 'Usage:',
    '  %s [option|cfgfile] ... JobID ...' % Script.scriptName, 'Arguments:',
    '  JobID:    DIRAC Job ID or a name of the file with JobID per line'
]))

Script.registerSwitch("D:", "Dir=", "Store the output in this directory")
Script.registerSwitch("f:", "File=",
                      "Get output for jobs with IDs from the file")
Script.registerSwitch("g:", "JobGroup=",
                      "Get output for jobs in the given group")

Script.parseCommandLine(ignoreErrors=True)
args = Script.getPositionalArgs()

from DIRAC.Interfaces.API.Dirac import Dirac
from DIRAC.Core.Utilities.Time import toString, date, day

dirac = Dirac()
exitCode = 0
errorList = []
예제 #45
0
#!/usr/bin/env python
########################################################################
# $HeadURL$
# File :    dirac-admin-allow-site
# Author :  Stuart Paterson
########################################################################
"""
  Add Site to Active mask for current Setup
"""
__RCSID__ = "$Id$"

from DIRAC.Core.Base import Script

Script.registerSwitch( "E:", "email=", "Boolean True/False (True by default)" )
Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1],
                                     'Usage:',
                                     '  %s [option|cfgfile] ... Site Comment' % Script.scriptName,
                                     'Arguments:',
                                     '  Site:     Name of the Site',
                                     '  Comment:  Reason of the action' ] ) )
Script.parseCommandLine( ignoreErrors = True )

from DIRAC.Interfaces.API.DiracAdmin                     import DiracAdmin
from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
from DIRAC                                               import exit as DIRACExit, gConfig, gLogger

import time

def getBoolean( value ):
  if value.lower() == 'true':
    return True
예제 #46
0
 def registerCLISwitches( self ):
   Script.registerSwitch( "v:", "valid=", "Valid HH:MM for the proxy. By default is 24 hours", self.setProxyLifeTime )
   Script.registerSwitch( "g:", "group=", "DIRAC Group to embed in the proxy", self.setDIRACGroup )
   Script.registerSwitch( "b:", "strength=", "Set the proxy strength in bytes", self.setProxyStrength )
   Script.registerSwitch( "l", "limited", "Generate a limited proxy", self.setProxyLimited )
   Script.registerSwitch( "t", "strict", "Fail on each error. Treat warnings as errors.", self.setStrict )
   Script.registerSwitch( "S", "summary", "Enable summary output when generating proxy", self.setSummary )
   Script.registerSwitch( "C:", "Cert=", "File to use as user certificate", self.setCertLocation )
   Script.registerSwitch( "K:", "Key=", "File to use as user key", self.setKeyLocation )
   Script.registerSwitch( "u:", "out=", "File to write as proxy", self.setProxyLocation )
   Script.registerSwitch( "x", "nocs", "Disable CS check", self.setDisableCSCheck )
   Script.registerSwitch( "p", "pwstdin", "Get passwd from stdin", self.setStdinPasswd )
   Script.registerSwitch( "i", "version", "Print version", self.showVersion )
   Script.registerSwitch( "j", "noclockcheck", "Disable checking if time is ok", self.disableClockCheck )
   Script.registerSwitch( "r", "rfc", "Create an RFC proxy", self.setRFC )
예제 #47
0
    '  GUID:     GUID to use in the registration (optional)', '', '**OR**', '',
    'Usage:',
    '  %s [option|cfgfile] ... LocalFile' % Script.scriptName, '\nArguments:',
    '  LocalFile: Path to local file containing all the above, i.e.:',
    '  lfn1 localfile1 SE [GUID1]', '  lfn2 localfile2 SE [GUID2]'
]))
overwrite = False


def setOverwrite(arg):
    global overwrite
    overwrite = True
    return S_OK()


Script.registerSwitch("f", "force", "Force overwrite of existing file",
                      setOverwrite)
Script.parseCommandLine(ignoreErrors=True)
args = Script.getPositionalArgs()
if len(args) < 1 or len(args) > 4:
    Script.showHelp()


def getDict(item_list):
    """
    From the input list, populate the dictionary
  """
    lfn_dict = {}
    lfn_dict['lfn'] = item_list[0].replace('LFN:', '').replace('lfn:', '')
    lfn_dict['localfile'] = item_list[1]
    lfn_dict['SE'] = item_list[2]
    guid = None
예제 #48
0
#!/usr/bin/env python
########################################################################
# File :    dirac-admin-list-users
# Author :  Adrian Casajus
########################################################################
"""
  Lists the users in the Configuration. If no group is specified return all users.
"""
from __future__ import print_function
__RCSID__ = "$Id$"
import DIRAC
from DIRAC.Core.Base import Script

Script.registerSwitch("e", "extended", "Show extended info")
Script.setUsageMessage('\n'.join([
    __doc__.split('\n')[1], 'Usage:',
    '  %s [option|cfgfile] ... [Group] ...' % Script.scriptName, 'Arguments:',
    '  Group:    Only users from this group (default: all)'
]))
Script.parseCommandLine(ignoreErrors=True)
args = Script.getPositionalArgs()

if len(args) == 0:
    args = ['all']

from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin
diracAdmin = DiracAdmin()
exitCode = 0
errorList = []
extendedInfo = False
예제 #49
0
 def registerSwitches(self):
     Script.registerSwitch("S:", "Site=", "Site to probe", self.setSite)
     Script.registerSwitch("C:", "CE=", "Computing Element to probe",
                           self.setCE)
     Script.setUsageMessage("%s --Site LCG.CERN.ch" % Script.scriptName)
예제 #50
0
#!/usr/bin/env python
########################################################################
# File :    dirac-wms-select-jobs
# Author :  Stuart Paterson
########################################################################
"""
  Select DIRAC jobs matching the given conditions
"""
__RCSID__ = "$Id$"

import DIRAC
from DIRAC import gLogger
from DIRAC.Core.Base import Script

maxJobs = 100
Script.registerSwitch("", "Status=", "Primary status")
Script.registerSwitch("", "MinorStatus=", "Secondary status")
Script.registerSwitch("", "ApplicationStatus=", "Application status")
Script.registerSwitch("", "Site=", "Execution site")
Script.registerSwitch("", "Owner=", "Owner (DIRAC nickname)")
Script.registerSwitch("", "JobGroup=", "Select jobs for specified job group")
Script.registerSwitch("", "Date=", "Date in YYYY-MM-DD format, if not specified default is today")
Script.registerSwitch("", "Maximum=", "Maximum number of jobs shown (default %d, 0 means all)" % maxJobs)
Script.setUsageMessage('\n'.join([__doc__.split('\n')[1],
                                  'Usage:',
                                  '  %s [option|cfgfile] ... JobID ...' % Script.scriptName]))
Script.parseCommandLine(ignoreErrors=True)

args = Script.getPositionalArgs()

# Default values
예제 #51
0
def main():
    Script.registerSwitch("", "Status=", "Primary status")
    Script.registerSwitch("", "MinorStatus=", "Secondary status")
    Script.registerSwitch("", "ApplicationStatus=", "Application status")
    Script.registerSwitch("", "Site=", "Execution site")
    Script.registerSwitch("", "Owner=", "Owner (DIRAC nickname)")
    Script.registerSwitch("", "JobGroup=",
                          "Select jobs for specified job group")
    Script.registerSwitch(
        "", "Date=",
        "Date in YYYY-MM-DD format, if not specified default is today")
    Script.registerSwitch("", "File=",
                          "File name,if not specified default is std.out ")
    Script.parseCommandLine(ignoreErrors=True)
    args = Script.getPositionalArgs()

    # Default values
    status = None
    minorStatus = None
    appStatus = None
    site = None
    owner = None
    jobGroup = None
    date = None
    filename = 'std.out'

    if len(args) != 1:
        Script.showHelp()

    searchstring = str(args[0])

    for switch in Script.getUnprocessedSwitches():
        if switch[0].lower() == "status":
            status = switch[1]
        elif switch[0].lower() == "minorstatus":
            minorStatus = switch[1]
        elif switch[0].lower() == "applicationstatus":
            appStatus = switch[1]
        elif switch[0].lower() == "site":
            site = switch[1]
        elif switch[0].lower() == "owner":
            owner = switch[1]
        elif switch[0].lower() == "jobgroup":
            jobGroup = switch[1]
        elif switch[0].lower() == "date":
            date = switch[1]
        elif switch[0].lower() == "file":
            filename = switch[1]

    selDate = date
    if not date:
        selDate = 'Today'

    from DIRAC.Interfaces.API.Dirac import Dirac

    dirac = Dirac()
    exitCode = 0
    errorList = []
    resultDict = {}

    result = dirac.selectJobs(status=status,
                              minorStatus=minorStatus,
                              applicationStatus=appStatus,
                              site=site,
                              owner=owner,
                              jobGroup=jobGroup,
                              date=date)
    if result['OK']:
        jobs = result['Value']
    else:
        print("Error in selectJob", result['Message'])
        DIRAC.exit(2)

    for job in jobs:

        result = dirac.getOutputSandbox(job)
        if result['OK']:
            if os.path.exists('%s' % job):

                lines = []
                try:
                    lines = open(os.path.join(job, filename)).readlines()
                except Exception as x:
                    errorList.append((job, x))
                for line in lines:
                    if line.count(searchstring):
                        resultDict[job] = line
                rmtree("%s" % (job))
        else:
            errorList.append((job, result['Message']))
            exitCode = 2

    for result in resultDict.items():
        print(result)

    DIRAC.exit(exitCode)
예제 #52
0
 def registerCLISwitches(self):
     Script.registerSwitch(
         "v:", "valid=",
         "Valid HH:MM for the proxy. By default is one month",
         self.setProxyLifeTime)
     Script.registerSwitch("C:", "Cert=", "File to use as user certificate",
                           self.setCertLocation)
     Script.registerSwitch("K:", "Key=", "File to use as user key",
                           self.setKeyLocation)
     Script.registerSwitch("P:", "Proxy=", "File to use as proxy",
                           self.setProxyLocation)
     Script.registerSwitch("f", "onthefly", "Generate a proxy on the fly",
                           self.setOnTheFly)
     Script.registerSwitch("p", "pwstdin", "Get passwd from stdin",
                           self.setStdinPasswd)
     Script.registerSwitch("i", "version", "Print version",
                           self.showVersion)
     Script.addDefaultOptionValue("LogLevel", "always")
예제 #53
0
def setCEName(args):
    global ceName
    ceName = args


def setSite(args):
    global Site
    Site = args


def setQueue(args):
    global Queue
    Queue = args


Script.registerSwitch("N:", "Name=", "Computing Element Name (Mandatory)",
                      setCEName)
Script.registerSwitch("S:", "Site=", "Site Name (Mandatory)", setSite)
Script.registerSwitch("Q:", "Queue=", "Queue Name (Mandatory)", setQueue)

Script.parseCommandLine(ignoreErrors=True)
args = Script.getExtraCLICFGFiles()

if len(args) > 1:
    Script.showHelp()
    exit(-1)

result = Resources.getQueue(Site, ceName, Queue)

if not result['OK']:
    gLogger.error("Could not retrieve resource parameters",
                  ": " + result['Message'])
예제 #54
0
def setModule(optVal):
    global specialOptions, module
    specialOptions['Module'] = optVal
    module = optVal
    return S_OK()


def setSpecialOption(optVal):
    global specialOptions
    option, value = optVal.split('=')
    specialOptions[option] = value
    return S_OK()


Script.registerSwitch("w", "overwrite",
                      "Overwrite the configuration in the global CS",
                      setOverwrite)
Script.registerSwitch("m:", "module=",
                      "Python module name for the component code", setModule)
Script.registerSwitch("p:", "parameter=", "Special component option ",
                      setSpecialOption)
Script.setUsageMessage('\n'.join([
    __doc__.split('\n')[1], 'Usage:',
    '  %s [option|cfgfile] ... System Component|System/Component' %
    Script.scriptName, 'Arguments:',
    '  System:  Name of the DIRAC system (ie: WorkloadManagement)',
    '  Service: Name of the DIRAC component (ie: Matcher)'
]))

Script.parseCommandLine()
args = Script.getPositionalArgs()
 def registerSwitches(self):
   Script.registerSwitch( 'O', 'Outputdata', 'retrieve also the outputdata', self.setOuputData)
   Script.registerSwitch( 'r:', 'Repository=', 'repository file to use', self.setRepo)
   Script.setUsageMessage('\n'.join( [ __doc__.split( '\n' )[1],
                                       '\nUsage:',
                                       '  %s [option|cfgfile] ...\n' % Script.scriptName ] )  )
#!/usr/bin/env python
"""
  For a given LFN directory, check the files that are registered in the FC and checks that they exist on the SE, and in Bookkeeping, with the  correct ReplicaFlag """

__RCSID__ = "$Id$"

import DIRAC
from DIRAC.Core.Base import Script
unit = 'TB'
sites = []
dir = ''
fileType = ''
prods = []
prodID = ''
verbose = False
Script.registerSwitch("u:", "Unit=",
                      "   Unit to use [%s] (MB,GB,TB,PB)" % unit)
Script.registerSwitch("D:", "Dir=",
                      "  directory to be checked: mandatory argument")
Script.registerSwitch("f:", "Output=",
                      " output file name [dirac-dms-chec-dir-cont.out]")
Script.registerSwitch("v", "Verbose",
                      " use this option for verbose output [False]")

Script.setUsageMessage('\n'.join([
    __doc__.split('\n')[1],
    'Usage:',
    '  %s [option|cfgfile] ...' % Script.scriptName,
]))

Script.parseCommandLine(ignoreErrors=False)
 def registerSwitches(self):
   Script.registerSwitch("x", "enable", "perform delete operations on file catalog", self.setEnabled)
   Script.setUsageMessage("""%s <transformationID> -x""" % Script.scriptName)
예제 #58
0
def addProperty( arg ):
  global groupProperties
  if not arg:
    Script.showHelp()
    DIRAC.exit( -1 )
  if not arg in groupProperties:
    groupProperties.append( arg )

Script.setUsageMessage( '\n'.join( ['Add or Modify a Group info in DIRAC',
                                    '\nUsage:\n',
                                    '  %s [option|cfgfile] ... Property=<Value> ...' % Script.scriptName,
                                    '\nArguments:\n',
                                    '  Property=<Value>: Other properties to be added to the User like (VOMSRole=XXXX)', ] ) )

Script.registerSwitch( 'G:', 'GroupName:', 'Name of the Group (Mandatory)', setGroupName )
Script.registerSwitch( 'U:', 'UserName:'******'Short Name of user to be added to the Group (Allow Multiple instances or None)', addUserName )
Script.registerSwitch( 'P:', 'Property:', 'Property to be added to the Group (Allow Multiple instances or None)', addProperty )

Script.parseCommandLine( ignoreErrors = True )

if groupName == None:
  Script.showHelp()
  DIRAC.exit( -1 )

args = Script.getPositionalArgs()

from DIRAC.Interfaces.API.DiracAdmin                         import DiracAdmin
diracAdmin = DiracAdmin()
exitCode = 0
errorList = []
예제 #59
0
""" The dirac-jobexec script is equipped to execute workflows that
    are specified via their XML description.  The main client of
    this script is the Job Wrapper.
"""

__RCSID__ = "$Id$"

import os
import os.path
import sys

import DIRAC
from DIRAC.Core.Base import Script

# Register workflow parameter switch
Script.registerSwitch('p:', 'parameter=', 'Parameters that are passed directly to the workflow')
Script.parseCommandLine()

# from DIRAC.Core.Workflow.Parameter import *
from DIRAC import gLogger
from DIRAC.Core.Workflow.Workflow import fromXMLFile
from DIRAC.WorkloadManagementSystem.Client.JobReport import JobReport
from DIRAC.AccountingSystem.Client.DataStoreClient import DataStoreClient
from DIRAC.RequestManagementSystem.Client.Request import Request

# Forcing the current directory to be the first in the PYTHONPATH
sys.path.insert(0, os.path.realpath('.'))
gLogger.showHeaders(True)


def jobexec(jobxml, wfParameters):
예제 #60
0
    def registerSwitches(self):
        Script.registerSwitch(
            "r:", "releases=",
            "releases to build (mandatory, comma separated)",
            cliParams.setReleases)
        Script.registerSwitch(
            "l:", "project=",
            "Project to build the release for (DIRAC by default)",
            cliParams.setProject)
        Script.registerSwitch("D:", "destination=",
                              "Destination where to build the tar files",
                              cliParams.setDestination)
        Script.registerSwitch("i:", "pythonVersion=",
                              "Python version to use (27)",
                              cliParams.setPythonVersion)
        Script.registerSwitch("P", "ignorePackages",
                              "Do not make tars of python packages",
                              cliParams.setIgnorePackages)
        Script.registerSwitch("C:", "relcfg=",
                              "Use <file> as the releases.cfg",
                              cliParams.setReleasesCFG)
        Script.registerSwitch(
            "b", "buildExternals",
            "Force externals compilation even if already compiled",
            cliParams.setForceExternals)
        Script.registerSwitch("B", "ignoreExternals",
                              "Skip externals compilation",
                              cliParams.setIgnoreExternals)
        Script.registerSwitch("t:", "buildType=",
                              "External type to build (client/server)",
                              cliParams.setExternalsBuildType)
        Script.registerSwitch(
            "x:", "externalsLocation=",
            "Use externals location instead of downloading them",
            cliParams.setExternalsLocation)
        Script.registerSwitch("j:", "makeJobs=", "Make jobs (default is 1)",
                              cliParams.setMakeJobs)
        Script.registerSwitch('M:', 'defaultsURL=',
                              'Where to retrieve the global defaults from',
                              cliParams.setGlobalDefaults)

        Script.setUsageMessage('\n'.join([
            __doc__.split('\n')[1], '\nUsage:',
            '  %s [option|cfgfile] ...\n' % Script.scriptName
        ]))