Proxy

Utilities to execute a function with a given proxy.

executeWithUserProxy decorator example usage:

@executeWithUserProxy
def testFcn( x, i, kw = 'qwerty' ):

  print "args", x, i
  print "kwargs", kw
  print os.environ.get( 'X509_USER_PROXY' )
  return S_OK()

...

result = testFcn( 1.0, 1, kw = 'asdfghj', proxyUserName = 'atsareg', proxyUserGroup = 'biomed_user' )
DIRAC.Core.Utilities.Proxy.executeWithUserProxy(fcn)

Decorator function to execute with a temporary user proxy

Parameters:fcn – function to be decorated
Returns:the result of the fcn execution

In order to be executed with a user proxy, the function must be called with the following parameters:

Parameters:
  • proxyUserName (str) – the user name of the proxy to be used
  • proxyUserGroup (str) – the user group of the proxy to be used
  • proxyUserDN (str) – the user DN of the proxy to be used
  • proxyWithVOMS (str) – optional flag to dress or not the user proxy with VOMS extension ( default True )
  • proxyFilePath (str) – optional file location for the temporary proxy
  • executionLock (bool) – flag to execute with a lock for the time of user proxy application ( default False )
DIRAC.Core.Utilities.Proxy.executeWithoutServerCertificate(fcn)

Decorator function to execute a call without the server certificate. This shows useful in Agents when we want to call a DIRAC service and use the shifter proxy (for example Write calls to the DFC).

The method does not fetch any proxy, it assumes it is already set up in the environment. Note that because it modifies the configuration for all thread, it uses a lock (the same as ExecuteWithUserProxy)

Potential problem:
  • there is a lock for this particular method, but any other method changing the UseServerCertificate value can clash with this.
Parameters:fcn – function to be decorated
Returns:the result of the fcn execution
DIRAC.Core.Utilities.Proxy.getProxy(userDNs, userGroup, vomsAttr, proxyFilePath)

do the actual download of the proxy, trying the different DNs