def uploadProxyToMyProxy( params, DNAsUsername ): """ Upload proxy to the MyProxy server """ myProxy = MyProxy() if DNAsUsername: gLogger.verbose( "Uploading pilot proxy with group %s to %s..." % ( params.getDIRACGroup(), myProxy.getMyProxyServer() ) ) else: gLogger.verbose( "Uploading user proxy with group %s to %s..." % ( params.getDIRACGroup(), myProxy.getMyProxyServer() ) ) retVal = myProxy.getInfo( proxyInfo[ 'path' ], useDNAsUserName = DNAsUsername ) if retVal[ 'OK' ]: remainingSecs = ( int( params.getProxyRemainingSecs() / 3600 ) * 3600 ) - 7200 myProxyInfo = retVal[ 'Value' ] if 'timeLeft' in myProxyInfo and remainingSecs < myProxyInfo[ 'timeLeft' ]: gLogger.verbose( " Already uploaded" ) return True retVal = generateProxy( params ) if not retVal[ 'OK' ]: gLogger.error( " There was a problem generating proxy to be uploaded to myproxy: %s" % retVal[ 'Message' ] ) return False retVal = getProxyInfo( retVal[ 'Value' ] ) if not retVal[ 'OK' ]: gLogger.error( " There was a problem generating proxy to be uploaded to myproxy: %s" % retVal[ 'Message' ] ) return False generatedProxyInfo = retVal[ 'Value' ] retVal = myProxy.uploadProxy( generatedProxyInfo[ 'path' ], useDNAsUserName = DNAsUsername ) if not retVal[ 'OK' ]: gLogger.error( " Can't upload to myproxy: %s" % retVal[ 'Message' ] ) return False gLogger.verbose( " Uploaded" ) return True
#!/usr/bin/env python ######################################################################## # $HeadURL$ # File : dirac-proxy-init.py # Author : Adrian Casajus ######################################################################## __RCSID__ = "$Id$" import sys import DIRAC from DIRAC.Core.Base import Script from DIRAC.FrameworkSystem.Client.ProxyGeneration import CLIParams, generateProxy if __name__ == "__main__": cliParams = CLIParams() cliParams.registerCLISwitches() Script.disableCS() Script.parseCommandLine(ignoreErrors=True) retVal = generateProxy(cliParams) if not retVal['OK']: print retVal['Message'] sys.exit(1) sys.exit(0)
# Example: # python test_wrapperScript.py | tee script.py && chmod +x script.py && ./script.py # __RCSID__ = "$Id: DIRACPilotDirector.py 28536 2010-09-23 06:08:40Z rgracian $" from DIRAC.Core.Base import Script from DIRAC.FrameworkSystem.Client.ProxyGeneration import CLIParams, generateProxy from DIRAC.Core.Security.Locations import getProxyLocation from DIRAC.Core.Security.X509Chain import X509Chain Script.disableCS() Script.parseCommandLine() proxyFile = getProxyLocation() if not proxyFile: retVal = generateProxy(CLIParams()) if not retVal['OK']: proxy = None else: proxy = X509Chain() proxy.loadChainFromFile(retVal['Value']) else: proxy = X509Chain() proxy.loadChainFromFile(proxyFile) from DIRAC.Resources.Computing import Pilot import os pilotFile = Pilot.__file__ print Pilot.wrapperScript(
# Example: # python test_wrapperScript.py | tee script.py && chmod +x script.py && ./script.py # __RCSID__ = "$Id: DIRACPilotDirector.py 28536 2010-09-23 06:08:40Z rgracian $" from DIRAC.Core.Base import Script from DIRAC.FrameworkSystem.Client.ProxyGeneration import CLIParams, generateProxy from DIRAC.Core.Security.Locations import getProxyLocation from DIRAC.Core.Security.X509Chain import X509Chain Script.disableCS() Script.parseCommandLine() proxyFile = getProxyLocation() if not proxyFile: retVal = generateProxy(CLIParams()) if not retVal['OK']: proxy = None else: proxy = X509Chain() proxy.loadChainFromFile(retVal['Value']) else: proxy = X509Chain() proxy.loadChainFromFile(proxyFile) from DIRAC.Resources.Computing import Pilot import os pilotFile = Pilot.__file__ print Pilot.wrapperScript( 'python' ,
if __name__ == "__main__": cliParams = CLIParams() cliParams.registerCLISwitches() Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1], 'Usage:', ' %s [option|cfgfile] ...' % Script.scriptName, ] ) ) Script.disableCS() Script.parseCommandLine() gConfig.setOptionValue( "/DIRAC/Security/UseServerCertificate", "no" ) diracGroup = cliParams.getDIRACGroup() time = cliParams.getProxyLifeTime() retVal = generateProxy( cliParams ) if not retVal[ 'OK' ]: gLogger.error( "Can't create a proxy: %s" % retVal[ 'Message' ] ) sys.exit( 1 ) gLogger.info( "Proxy created" ) Script.enableCS() retVal = getProxyInfo( retVal[ 'Value' ] ) if not retVal[ 'OK' ]: gLogger.error( "Can't create a proxy: %s" % retVal[ 'Message' ] ) sys.exit( 1 ) proxyInfo = retVal[ 'Value' ] if 'username' not in proxyInfo: print "Not authorized in DIRAC"