예제 #1
0
def main():
    params = Params()

    Script.registerSwitch("f:", "file=", "File to use as proxy",
                          params.setProxyLocation)
    Script.registerSwitch("D", "DN", "Use DN as myproxy username",
                          params.setDNAsUsername)
    Script.registerSwitch("i", "version", "Print version", params.showVersion)

    Script.addDefaultOptionValue("LogLevel", "always")
    Script.parseCommandLine()

    from DIRAC.Core.Security.MyProxy import MyProxy
    from DIRAC.Core.Security import Locations

    if not params.proxyLoc:
        params.proxyLoc = Locations.getProxyLocation()

    if not params.proxyLoc:
        print("Can't find any valid proxy")
        sys.exit(1)
    print("Uploading proxy file %s" % params.proxyLoc)

    mp = MyProxy()
    retVal = mp.uploadProxy(params.proxyLoc, params.dnAsUsername)
    if not retVal['OK']:
        print("Can't upload proxy:")
        print(" ", retVal['Message'])
        sys.exit(1)
    print("Proxy uploaded")
    sys.exit(0)
예제 #2
0
def main():
  Script.addDefaultOptionValue('/DIRAC/Security/SkipCAChecks', 'yes')
  Script.parseCommandLine(ignoreErrors=True)

  bdc = BundleDeliveryClient()

  result = bdc.syncCAs()
  if not result['OK']:
    DIRAC.gLogger.error("Error while updating CAs", result['Message'])
    DIRAC.exit(1)
  elif result['Value']:
    DIRAC.gLogger.notice("CAs got updated")
  else:
    DIRAC.gLogger.notice("CAs are already synchronized")

  result = bdc.syncCRLs()
  if not result['OK']:
    DIRAC.gLogger.error("Error while updating CRLs", result['Message'])
    DIRAC.exit(1)
  elif result['Value']:
    DIRAC.gLogger.notice("CRLs got updated")
  else:
    DIRAC.gLogger.notice("CRLs are already synchronized")

  DIRAC.exit(0)
예제 #3
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("D", "proxydebug",
                           "Enable debug output when generating proxy",
                           self.setDebug)
     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.addDefaultOptionValue("LogLevel", "always")
예제 #4
0
 def registerCLISwitches( self ):
   Script.registerSwitch( "v:", "valid=", "Valid HH:MM for the proxy. By default is one month", self.setProxyLifeTime )
   Script.registerSwitch( "g:", "group=", "DIRAC Group to embed in the proxy", self.setDIRACGroup )
   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" )
예제 #5
0
 def registerCLISwitches(self):
   Script.registerSwitch("v:", "valid=", "Valid HH:MM for the proxy. By default is one month", self.setProxyLifeTime)
   Script.registerSwitch("g:", "group=", "DIRAC Group to embed in the proxy", self.setDIRACGroup)
   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")
예제 #6
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( "D", "proxydebug", "Enable debug output when generating proxy", self.setDebug )
   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.addDefaultOptionValue( "LogLevel", "always" )
예제 #7
0
def main():
  cliParams = Params()

  Script.disableCS()
  Script.registerSwitch(
      "e",
      "exitOnError",
      "flag to exit on error of any component installation",
      cliParams.setExitOnError)

  Script.addDefaultOptionValue('/DIRAC/Security/UseServerCertificate', 'yes')
  Script.addDefaultOptionValue('LogLevel', 'INFO')
  Script.parseCommandLine()
  args = Script.getExtraCLICFGFiles()

  if len(args) > 1:
    Script.showHelp(exitCode=1)

  cfg = None
  if len(args):
    cfg = args[0]
  from DIRAC.FrameworkSystem.Client.ComponentInstaller import gComponentInstaller

  gComponentInstaller.exitOnError = cliParams.exitOnError

  result = gComponentInstaller.setupSite(Script.localCfg, cfg)
  if not result['OK']:
    print("ERROR:", result['Message'])
    exit(-1)

  result = gComponentInstaller.getStartupComponentStatus([])
  if not result['OK']:
    print('ERROR:', result['Message'])
    exit(-1)

  print("\nStatus of installed components:\n")
  result = gComponentInstaller.printStartupStatus(result['Value'])
  if not result['OK']:
    print('ERROR:', result['Message'])
    exit(-1)
예제 #8
0
#!/usr/bin/env python

""" Pipeline kill script - use host certificate and shifter credentials for killing a job
Created 03/2014
@author: S. Zimmer (OKC/SU)

"""

if __name__ == "__main__":
    from os import environ
    from DIRAC.Core.Base import Script
    # thanks to Stephane for suggesting this fix!
    Script.addDefaultOptionValue('/DIRAC/Security/UseServerCertificate','y')
    Script.parseCommandLine(ignoreErrors=True)
    Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1],
                                     'Usage:',
                                     '  %s [option|cfgfile] ... JobID ...' % Script.scriptName,
                                     'Arguments:',
                                     '  JobID:    DIRAC Job ID' ] ) )
    args = Script.getPositionalArgs() 
    from DIRAC import gLogger, exit as dexit
    from DIRAC.Interfaces.API.Dirac import Dirac
    from DIRAC.FrameworkSystem.Client.ProxyManagerClient import gProxyManager
    from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
    
    # get necessary credentials
    op = Operations("glast.org")
    shifter = op.getValue("Pipeline/Shifter","/DC=org/DC=doegrids/OU=People/CN=Stephan Zimmer 799865")
    shifter_group = op.getValue("Pipeline/ShifterGroup","glast_user")
    result = gProxyManager.downloadProxyToFile(shifter,shifter_group,requiredTimeLeft=10000)
    if not result['OK']:
예제 #9
0
                        os.path.join(cliParams.destination, fileName))
        outFiles = " ".join(filesToCopy)
        outFileNames = " ".join(
            [os.path.basename(filePath) for filePath in filesToCopy])

        if not upCmd:
            return "Upload to your installation source:\n'%s'\n" % "' '".join(
                filesToCopy)
        for inRep, outRep in (("%OUTLOCATION%", self.cliParams.destination),
                              ("%OUTFILES%", outFiles), ("%OUTFILENAMES%",
                                                         outFileNames)):
            upCmd = upCmd.replace(inRep, outRep)
        return upCmd


if __name__ == "__main__":
    cliParams = Params()
    Script.disableCS()
    Script.addDefaultOptionValue("/DIRAC/Setup", "Dummy")
    cliParams.registerSwitches()
    Script.parseCommandLine(ignoreErrors=False)
    if Script.localCfg.getDebugMode():
        cliParams.debug = True
    distMaker = DistributionMaker(cliParams)
    if not distMaker.doTheMagic():
        sys.exit(1)
    gLogger.notice("Everything seems ok. Tarballs generated in %s" %
                   cliParams.destination)
    upCmd = distMaker.getUploadCmd()
    gLogger.always(upCmd)
      return result
    result = self.__checkoutSource()
    if not result[ 'OK' ]:
      return result
    shutil.rmtree( "%s/tests" % self.params.destination, ignore_errors=True )
    shutil.rmtree( "%s/docs" % self.params.destination, ignore_errors=True )
    result = self.__generateReleaseNotes()
    if not result[ 'OK' ]:
      gLogger.error( "Won't generate release notes: %s" % result[ 'Message' ] )
    return self.__generateTarball()

if __name__ == "__main__":
  cliParams = TarModuleCreator.Params()

  Script.disableCS()
  Script.addDefaultOptionValue( "/DIRAC/Setup", "Dummy" )
  Script.registerSwitch( "v:", "version=", "version to tar", cliParams.setVersion )
  Script.registerSwitch( "u:", "source=", "VCS path to retrieve sources from", cliParams.setSourceURL )
  Script.registerSwitch( "D:", "destination=", "Destination where to build the tar files", cliParams.setDestination )
  Script.registerSwitch( "n:", "name=", "Tarball name", cliParams.setName )
  Script.registerSwitch( "z:", "vcs=", "VCS to use to retrieve the sources (try to find out if not specified)", cliParams.setVCS )
  Script.registerSwitch( "b:", "branch=", "VCS branch (if needed)", cliParams.setVCSBranch )
  Script.registerSwitch( "p:", "path=", "VCS path (if needed)", cliParams.setVCSPath )
  Script.registerSwitch( "K:", "releasenotes=", "Path to the release notes", cliParams.setReleaseNotes )
  Script.registerSwitch( "A", "notesoutside", "Leave a copy of the compiled release notes outside the tarball", cliParams.setOutReleaseNotes )

  Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1],
                                      '\nUsage:',
                                      '  %s <option> ...\n' % Script.scriptName,
                                      '  A source, name and version are required to build the tarball',
                                      '  For instance:',
#!/usr/bin/env python
""" Get LogFile from Dirac Sandboxes
@author: V. Rolland (LUPM/IN2P3)
@author: S. Zimmer (UniGE/CERN)
"""
import sys, os, shutil, time

if __name__ == "__main__":

    from DIRAC.Core.Base import Script

    Script.addDefaultOptionValue("/DIRAC/Security/UseServerCertificate", "y")
    Script.parseCommandLine()

    from DIRAC.Core.DISET.RPCClient import RPCClient
    from DIRAC.Interfaces.API.Dirac import Dirac
    import DIRAC.Core.Utilities.Time as Time

    delay_job_handled = 3
    status_to_handle = ["Done", "Failed", "Killed", "Deleted"]
    status_to_ignore = ["Running", "Waiting", "Checking", "Stalled", "Received"]
    dir_temp = "/tmp"

    from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations

    op = Operations("glast.org")
    LogfileRetrievalSummaryPath = op.getValue(
        "Pipeline/LogfileRetrievalSummaryPath", "/glast_data/Pipeline2/grid-service"
    )
    filename_jobhandled = LogfileRetrievalSummaryPath + "/LogfileRetrievalSummaryIDjob"
    # filename_jobhandled = '/afs/in2p3.fr/home/g/glastpro/vrolland/logFile/jobidhandled.list'
예제 #12
0
# Author :  Ricardo Graciani
########################################################################
"""
Initial installation and configuration of a new DIRAC server (DBs, Services, Agents, Web Portal,...)
"""
__RCSID__ = "98724d4 (2011-12-01 14:09:11 +0100) Vanessa Hamar <*****@*****.**>"
#
from DIRAC.Core.Base import Script
Script.disableCS()
Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1],
                                     'Usage:',
                                     '  %s [option] ... [cfgfile]' % Script.scriptName,
                                     'Arguments:',
                                     '  cfgfile: DIRAC Cfg with description of the configuration (optional)' ] ) )

Script.addDefaultOptionValue( '/DIRAC/Security/UseServerCertificate', 'yes' )
Script.addDefaultOptionValue( 'LogLevel', 'INFO' )
Script.parseCommandLine()
args = Script.getExtraCLICFGFiles()
#
if len( args ) > 1:
  Script.showHelp()
  exit( -1 )
#
cfg = None
if len( args ):
  cfg = args[0]
from DIRAC.Core.Utilities import InstallTools
#
InstallTools.exitOnError = True
#
예제 #13
0
#!/usr/bin/env python

#
"""  check if a service or an agent is stalled """

__RCSID__ = "$Id$"

#
import os
import commands
from DIRAC.Core.Base import Script
Script.addDefaultOptionValue('LogLevel', 'verbose')
Script.parseCommandLine(ignoreErrors=True)

from DIRAC.Core.Utilities.Time import fromString, second, dateTime, timeInterval
from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin
from DIRAC import gLogger

now = dateTime()
runit_dir = '/opt/dirac/startup'
logfile = 'log/current'
pollingtime = 60
diracAdmin = DiracAdmin()
mailadress = '*****@*****.**'
subject = 'CheckStalled'
host = os.uname()[1]
msg = 'List of Services / agents which could be stalled on ' + host + ' \n\n'


def write_log(mesg):
    """ create the log file """
예제 #14
0
    def showVersion(self, arg):
        print "Version:"
        print " ", __RCSID__
        sys.exit(0)
        return DIRAC.S_OK()


params = Params()

Script.registerSwitch("f:", "file=", "File to use as proxy",
                      params.setProxyLocation)
Script.registerSwitch("D", "DN", "Use DN as myproxy username",
                      params.setDNAsUsername)
Script.registerSwitch("i", "version", "Print version", params.showVersion)

Script.addDefaultOptionValue("LogLevel", "always")
Script.parseCommandLine()

from DIRAC.FrameworkSystem.Client.ProxyManagerClient import gProxyManager
from DIRAC.Core.Security.MyProxy import MyProxy
from DIRAC.Core.Security.X509Chain import X509Chain
from DIRAC.Core.Security import Locations, CS

if not params.proxyLoc:
    params.proxyLoc = Locations.getProxyLocation()

if not params.proxyLoc:
    print "Can't find any valid proxy"
    sys.exit(1)
print "Uploading proxy file %s" % params.proxyLoc
예제 #15
0
import DIRAC
from DIRAC.Core.Base import Script

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(
    "", "Date=",
    "Date in YYYY-MM-DD format, if not specified default is today")
Script.registerSwitch("", "JobGroup=", "Select jobs for specified job group")
Script.registerSwitch(
    "", "Verbose=",
    "For more detailed information about file and job states. Default False.")
Script.addDefaultOptionValue("LogLevel", "ALWAYS")
Script.parseCommandLine(ignoreErrors=True)

from DIRAC.Interfaces.API.Dirac import Dirac

args = Script.getPositionalArgs()

wmsStatus = None
minorStatus = None
appStatus = None
site = None
owner = None
jobGroup = None
date = None
verbose = False
예제 #16
0
#!/usr/bin/env python
########################################################################
# $HeadURL$
# File :    dirac-admin-get-CAs
# Author :  Ricardo Graciani
########################################################################
__RCSID__ = "$Id$"
import os
import DIRAC
from DIRAC.Core.Base import Script
from DIRAC.FrameworkSystem.Client.BundleDeliveryClient import BundleDeliveryClient

Script.addDefaultOptionValue('/DIRAC/Security/SkipCAChecks', 'yes')
Script.parseCommandLine(ignoreErrors=True)

bdc = BundleDeliveryClient()

result = bdc.syncCAs()
if not result['OK']:
    DIRAC.gLogger.error("Error while updating CAs", result['Message'])
    DIRAC.exit(1)
elif result['Value']:
    DIRAC.gLogger.info("CAs got updated")
else:
    DIRAC.gLogger.info("CAs are already synchronized")

result = bdc.syncCRLs()
if not result['OK']:
    DIRAC.gLogger.error("Error while updating CRLs", result['Message'])
    DIRAC.exit(1)
elif result['Value']:
예제 #17
0
        print " ", __RCSID__
        sys.exit(0)
        return DIRAC.S_OK()

    def debugMsg(self, msg):
        if self.debug:
            print msg


params = Params()

Script.registerSwitch("f:", "file=", "File to use as proxy", params.setProxyLocation)
Script.registerSwitch("D", "DN", "Use DN as myproxy username", params.setDNAsUsername)
Script.registerSwitch("i", "version", "Print version", params.showVersion)

Script.addDefaultOptionValue("LogLevel", "always")
Script.parseCommandLine()

from DIRAC.FrameworkSystem.Client.ProxyManagerClient import gProxyManager
from DIRAC.Core.Security.MyProxy import MyProxy
from DIRAC.Core.Security.X509Chain import X509Chain
from DIRAC.Core.Security import Locations, CS

if not params.proxyLoc:
    params.proxyLoc = Locations.getProxyLocation()

if not params.proxyLoc:
    print "Can't find any valid proxy"
    sys.exit(1)
print "Uploading proxy file %s" % params.proxyLoc
예제 #18
0
#!/usr/bin/env python
########################################################################
# $HeadURL$
# File :    dirac-admin-get-CAs
# Author :  Ricardo Graciani
########################################################################
__RCSID__ = "3f976ee (2010-12-04 11:15:58 +0000) Ricardo Graciani <*****@*****.**>"
import os
import DIRAC
from DIRAC.Core.Base import Script
from DIRAC.FrameworkSystem.Client.BundleDeliveryClient import BundleDeliveryClient

Script.addDefaultOptionValue( '/DIRAC/Security/SkipCAChecks', 'yes' )
Script.parseCommandLine( ignoreErrors = True )

bdc = BundleDeliveryClient()

result = bdc.syncCAs()
if not result[ 'OK' ]:
  DIRAC.gLogger.error( "Error while updating CAs", result[ 'Message' ] )
  DIRAC.exit( 1 )
elif result[ 'Value' ]:
  DIRAC.gLogger.info( "CAs got updated" )
else:
  DIRAC.gLogger.info( "CAs are already synchronized" )

result = bdc.syncCRLs()
if not result[ 'OK' ]:
  DIRAC.gLogger.error( "Error while updating CRLs", result[ 'Message' ] )
  DIRAC.exit( 1 )
elif result[ 'Value' ]:
예제 #19
0
        thisLine = line.replace("\n", "")
        file_list.append(thisLine)
    return file_list


if __name__ == "__main__":
    import sys, os, shutil, glob
    from DIRAC.Core.Base import Script
    from DIRAC import gLogger, exit as dexit
    specialOptions = {}
    Script.registerSwitch(
        "p:", "parameter=",
        "Special option (currently supported: release, cpu, site, stagein, name, debug, mailDebug, env, bannedSites, group) ",
        setSpecialOption)
    # thanks to Stephane for suggesting this fix!
    Script.addDefaultOptionValue('/DIRAC/Security/UseServerCertificate', 'y')
    Script.parseCommandLine()
    args = Script.getPositionalArgs()
    #from DIRAC.Interfaces.API.Job import Job
    from GlastDIRAC.PipelineSystem.Interface.GlastJob import GlastJob as Job
    from DIRAC.Interfaces.API.Dirac import Dirac
    from DIRAC.FrameworkSystem.Client.ProxyManagerClient import gProxyManager
    from GlastDIRAC.ResourceStatusSystem.Client.SoftwareTagClient import SoftwareTagClient
    from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
    opts = options(
        specialOptions
    )  # converts the "DIRAC registerSwitch()" to something similar to OptionParser
    pipeline = False
    pipeline_dict = None
    if not opts.env is None:
        import json
예제 #20
0
cliParams = Params()

Script.disableCS()
Script.setUsageMessage('\n'.join([__doc__.split('\n')[1],
                                  'Usage:',
                                  '  %s [option] ... [cfgfile]' % Script.scriptName,
                                  'Arguments:',
                                  '  cfgfile: DIRAC Cfg with description of the configuration (optional)']))

Script.registerSwitch(
    "e",
    "exitOnError",
    "flag to exit on error of any component installation",
    cliParams.setExitOnError)

Script.addDefaultOptionValue('/DIRAC/Security/UseServerCertificate', 'yes')
Script.addDefaultOptionValue('LogLevel', 'INFO')
Script.parseCommandLine()
args = Script.getExtraCLICFGFiles()
#
if len(args) > 1:
  Script.showHelp(exitCode=1)
#
cfg = None
if len(args):
  cfg = args[0]
from DIRAC.FrameworkSystem.Client.ComponentInstaller import gComponentInstaller
#
gComponentInstaller.exitOnError = cliParams.exitOnError
#
result = gComponentInstaller.setupSite(Script.localCfg, cfg)