Exemple #1
0
#!/usr/bin/env python
########################################################################
# File :    dirac-bookkeeping-get-tck
# Author :  Zoltan Mathe
########################################################################
"""
  Returns list of TCKs for a run range, by default only if there is a FULL stream
"""
__RCSID__ = "$Id$"

from LHCbDIRAC.DataManagementSystem.Client.DMScript import Script

if __name__ == "__main__":
    Script.registerSwitch('', 'Runs=', 'Run range or list')
    Script.registerSwitch('', 'ByRange',
                          'List by range rather than by item value')
    Script.registerSwitch('', 'Force',
                          'Include runs even if no FULL stream is present')
    Script.registerSwitch('', 'DQFlag=', 'Specify the DQ flag (default: all)')
    Script.setUsageMessage('\n'.join([
        __doc__.split('\n')[1], 'Usage:',
        '  %s [option|cfgfile] ... ' % Script.scriptName
    ]))

    Script.parseCommandLine(ignoreErrors=True)

    from LHCbDIRAC.BookkeepingSystem.Client.ScriptExecutors import executeRunInfo
    executeRunInfo('Tck')
Exemple #2
0
"""
__RCSID__ = "$Id$"

from LHCbDIRAC.DataManagementSystem.Client.DMScript import DMScript, Script

if __name__ == "__main__":
    dmScript = DMScript()
    dmScript.registerFileSwitches()
    Script.registerSwitch('', 'All',
                          'Do not restrict to descendants with replicas')
    Script.registerSwitch('', 'Full',
                          'Get full metadata information on descendants')
    level = 1
    Script.registerSwitch('', 'Depth=',
                          'Number of processing levels (default:%d)' % level)
    Script.registerSwitch(
        '', 'Production=',
        'Restrict to descendants in a given production (at any depth)')
    Script.setUsageMessage('\n'.join([
        __doc__.split('\n')[1], 'Usage:',
        '  %s [option|cfgfile] ... [LFN|File] [Depth]' % Script.scriptName,
        'Arguments:', '  LFN:      Logical File Name',
        '  File:     Name of the file with a list of LFNs',
        '  Depth:    Number of levels to search (default: %d)' % level
    ]))

    Script.parseCommandLine(ignoreErrors=True)

    from LHCbDIRAC.BookkeepingSystem.Client.ScriptExecutors import executeFileDescendants
    executeFileDescendants(dmScript, level)
#!/usr/bin/env python
'''
    Check if all files have a replica in a certain (set of) SE )Tier1-Archive default)
    List the files that don't have a replica in the specified SE (group)
'''
__RCSID__ = "$Id$"


if __name__ == '__main__':

  # Script initialization
  from LHCbDIRAC.DataManagementSystem.Client.DMScript import DMScript, Script

  Script.registerSwitch('', 'FixIt', '   Take action to fix the catalogs')
  Script.setUsageMessage('\n'.join([__doc__,
                                    'Usage:',
                                    '  %s [option|cfgfile] [values]' % Script.scriptName, ]))
  dmScript = DMScript()
  dmScript.registerDMSwitches()  # Directory
  Script.parseCommandLine(ignoreErrors=True)
  fixIt = False
  for opt, val in Script.getUnprocessedSwitches():
    if opt == 'FixIt':
      fixIt = True

  # imports
  from DIRAC import gLogger
  from LHCbDIRAC.DataManagementSystem.Client.ConsistencyChecks import ConsistencyChecks
  cc = ConsistencyChecks()
  cc.directories = dmScript.getOption('Directory', [])
  cc.lfns = dmScript.getOption('LFNs', []) + [lfn for arg in Script.getPositionalArgs() for lfn in arg.split(',')]
"""
    Show replicas for a (set of) LFNs
"""
__RCSID__ = "$Id$"
__VERSION__ = "$Revision: 86918 $"

from LHCbDIRAC.DataManagementSystem.Client.DMScript import DMScript, Script

if __name__ == "__main__":

    dmScript = DMScript()
    dmScript.registerFileSwitches()
    Script.registerSwitch('a', "All", "  Also show inactive replicas")
    Script.registerSwitch('', 'DiskOnly', '  Show only disk replicas')
    Script.registerSwitch('', 'PreferDisk',
                          "  If disk replica, don't show tape replicas")
    Script.registerSwitch('', 'ForJobs',
                          '  Select only replicas that can be used for jobs')

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

    Script.parseCommandLine(ignoreErrors=False)

    from LHCbDIRAC.DataManagementSystem.Client.ScriptExecutors import executeLfnReplicas
    from DIRAC import exit
    exit(executeLfnReplicas(dmScript))
#!/usr/bin/env python
########################################################################
# File :    dirac-dms-replicate-to-run-destination
# Author  : Philippe Charpentier
########################################################################
"""
  Replicate a (list of) existing LFN(s) to Ses defined by the run destination
"""
__RCSID__ = "$Id$"

from LHCbDIRAC.DataManagementSystem.Client.DMScript import DMScript, Script

if __name__ == "__main__":
    dmScript = DMScript()
    dmScript.registerFileSwitches()
    dmScript.registerSiteSwitches()

    Script.registerSwitch('', 'RemoveSource',
                          '   If set, the source replica(s) will be removed')

    Script.setUsageMessage('\n'.join([
        __doc__, 'Usage:',
        '  %s [option|cfgfile] ...  [LFN1[,LFN2,[...]]] Dest[,Dest2[,...]] [Source [Cache]]'
        % Script.scriptName, 'Arguments:', '  Dest:     Valid DIRAC SE(s)'
    ]))
    Script.parseCommandLine(ignoreErrors=True)

    from LHCbDIRAC.DataManagementSystem.Client.ScriptExecutors import executeReplicateToRunDestination
    from DIRAC import exit
    exit(executeReplicateToRunDestination(dmScript))
Exemple #6
0
########################################################################
# File :    dirac-bookkeeping-file-path
# Author :  Zoltan Mathe
########################################################################
"""
  Return the BK path for the directories of a (list of) files
"""
__RCSID__ = "$Id$"
from LHCbDIRAC.DataManagementSystem.Client.DMScript import DMScript, Script

if __name__ == "__main__":
  dmScript = DMScript()
  dmScript.registerFileSwitches()
  Script.registerSwitch('', 'Full', '   Print out full BK dictionary (default: print out BK path)')
  Script.registerSwitch('', 'GroupBy=', '   Return a list of files per <metadata item>')
  Script.registerSwitch('', 'GroupByPath', '   Return a list of files per BK path')
  Script.registerSwitch('', 'GroupByProduction', '   Return a list of files per production')
  Script.registerSwitch('', 'Summary', '   Only give the number of files in each group (default: GroupByPath)')
  Script.registerSwitch('', 'List', '   Print a list of group keys')
  Script.registerSwitch('', 'IgnoreFileType', '   Ignore file type in path (useful for stripping)')
  Script.setUsageMessage('\n'.join([__doc__.split('\n')[1],
                                    'Usage:',
                                    '  %s [option|cfgfile] ... LFN|File' % Script.scriptName,
                                    'Arguments:',
                                    '  LFN:      Logical File Name',
                                    '  File:     Name of the file with a list of LFNs']))
  Script.parseCommandLine()

  from LHCbDIRAC.BookkeepingSystem.Client.ScriptExecutors import executeFilePath
  executeFilePath(dmScript)
#!/usr/bin/env python
"""
  Retrieve an access URL for an LFN replica given a valid DIRAC SE.
"""

__RCSID__ = "$Id$"

from LHCbDIRAC.DataManagementSystem.Client.DMScript import DMScript, Script

if __name__ == "__main__":

    dmScript = DMScript()
    dmScript.registerFileSwitches()
    dmScript.registerSiteSwitches()
    Script.registerSwitch(
        '', 'Protocol=',
        '   Define the protocol for which a tURL is requested (default:root)')
    Script.setUsageMessage('\n'.join(
        __doc__.split('\n') + [
            'Usage:',
            '  %s [option|cfgfile] ... [LFN[,LFN2[,LFN3...]]] SE[,SE2...]' %
            Script.scriptName, 'Arguments:',
            '  LFN:      Logical File Name or file containing LFNs',
            '  SE:       Valid DIRAC SE'
        ]))
    Script.parseCommandLine(ignoreErrors=True)

    from LHCbDIRAC.DataManagementSystem.Client.ScriptExecutors import executeAccessURL
    from DIRAC import exit
    exit(executeAccessURL(dmScript))
# File :    dirac-dms-replicate-lfn
# Author  : Stuart Paterson
########################################################################
"""
  Replicate a (list of) existing LFN(s) to (set of) Storage Element(s)
"""
__RCSID__ = "$Id$"

from LHCbDIRAC.DataManagementSystem.Client.DMScript import DMScript, Script

if __name__ == "__main__":
    dmScript = DMScript()
    dmScript.registerFileSwitches()
    dmScript.registerSiteSwitches()

    Script.registerSwitch('', 'RemoveSource',
                          '   If set, the source replica(s) will be removed')

    Script.setUsageMessage('\n'.join([
        __doc__, 'Usage:',
        '  %s [option|cfgfile] ...  [LFN1[,LFN2,[...]]] Dest[,Dest2[,...]] [Source [Cache]]'
        % Script.scriptName, 'Arguments:', '  Dest:     Valid DIRAC SE(s)',
        '  Source:   Valid DIRAC SE',
        '  Cache:    Local directory to be used as cache'
    ]))
    Script.parseCommandLine(ignoreErrors=True)

    from LHCbDIRAC.DataManagementSystem.Client.ScriptExecutors import executeReplicateLfn
    from DIRAC import exit
    exit(executeReplicateLfn(dmScript))
#!/usr/bin/env python
"""
Remove replicas of a (list of) LFNs from all non-ARCHIVE storage elements
"""

__RCSID__ = "$Id$"

from LHCbDIRAC.DataManagementSystem.Client.DMScript import DMScript, Script

if __name__ == "__main__":
  dmScript = DMScript()
  dmScript.registerFileSwitches()
  dmScript.registerBKSwitches()

  Script.registerSwitch("", "Force", " use this option for force the removal of files without ARCHIVE")
  Script.setUsageMessage('\n'.join(__doc__.split('\n') + [
      'Usage:',
      '  %s [option|cfgfile] ... [LFN[,LFN2[,LFN3...]]] SE[,SE2...]' % Script.scriptName]))
  Script.parseCommandLine()

  from LHCbDIRAC.DataManagementSystem.Client.ScriptExecutors import executeRemoveReplicas
  from DIRAC import exit
  exit(executeRemoveReplicas(dmScript, allDisk=True))
# File :    dirac-dms-pfn-metadata.py
# Author :  Ph. Charpentier
########################################################################
"""
  Check existence of a (list of) LHCb LFNs/PFNs given a valid DIRAC SE (or for all replicas)
  Only the LFN contained in the PFN is considered, unlike the DIRAC similar script
"""
__RCSID__ = "$Id$"

from LHCbDIRAC.DataManagementSystem.Client.DMScript import DMScript, Script, printDMResult

if __name__ == "__main__":

    dmScript = DMScript()
    dmScript.registerFileSwitches()
    dmScript.registerSiteSwitches()
    Script.registerSwitch('', 'Summary',
                          '   Only prints a summary on existing files')
    Script.setUsageMessage('\n'.join([
        __doc__, 'Usage:',
        '  %s [option|cfgfile] ... [URL[,URL2[,URL3...]]] SE[ SE2...]' %
        Script.scriptName, 'Arguments:',
        '  URL:      Logical/Physical File Name or file containing URLs',
        '  SE:       Valid DIRAC SE'
    ]))
    Script.parseCommandLine(ignoreErrors=True)

    from LHCbDIRAC.DataManagementSystem.Client.ScriptExecutors import executePfnMetadata
    from DIRAC import exit
    exit(executePfnMetadata(dmScript, check=True, exists=True))
#!/usr/bin/env python
########################################################################
# File :    dirac-dms-lfn-metadata
# Author :  Philippe Charpentier
########################################################################
"""
  Get the metadata of a (list of) LFNs from the FC
"""
__RCSID__ = "$Id$"
from LHCbDIRAC.DataManagementSystem.Client.DMScript import DMScript, Script

if __name__ == "__main__":

    dmScript = DMScript()
    dmScript.registerFileSwitches()
    dmScript.registerSiteSwitches()
    Script.setUsageMessage('\n'.join([
        __doc__.split('\n')[1], 'Usage:',
        '  %s [option|cfgfile] ... [LFN[,LFN2[,LFN3...]]]' % Script.scriptName,
        'Arguments:', '  LFN:      Logical File Name or file containing LFNs'
    ]))
    Script.parseCommandLine(ignoreErrors=True)

    from LHCbDIRAC.DataManagementSystem.Client.ScriptExecutors import executeLfnMetadata
    from DIRAC import exit
    exit(executeLfnMetadata(dmScript))
Exemple #12
0
"""
  Retrieve parameters associated to the given DIRAC job
"""

# FIXME: this is almost the same of vanilla DIRAC script that has the same name

__RCSID__ = "$Id$"

import DIRAC
from LHCbDIRAC.DataManagementSystem.Client.DMScript import Script, printDMResult

Script.registerSwitch('', 'Parameters=',
                      '   If present, print out only those parameters')
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()

if len(args) < 1:
    Script.showHelp()
parameters = None
for switch in Script.getUnprocessedSwitches():
    if switch[0] == 'Parameters':
        parameters = switch[1].split(',')

from DIRAC.Interfaces.API.Dirac import Dirac, parseArguments

dirac = Dirac()