def getVOMSProxy( self, userDN, userGroup, requiredLifeTime = False, requestedVOMSAttr = False ): """ Get proxy string from the Proxy Repository for use with userDN in the userGroup and VOMS attr """ retVal = self.__getVOMSAttribute( userGroup, requestedVOMSAttr ) if not retVal[ 'OK' ]: return retVal vomsAttr = retVal[ 'Value' ][ 'attribute' ] vomsVO = retVal[ 'Value' ][ 'VOMSVO' ] #Look in the cache retVal = self.__getPemAndTimeLeft( userDN, userGroup, vomsAttr ) if retVal[ 'OK' ]: pemData = retVal[ 'Value' ][0] vomsTime = retVal[ 'Value' ][1] chain = X509Chain() retVal = chain.loadProxyFromString( pemData ) if retVal[ 'OK' ]: retVal = chain.getRemainingSecs() if retVal[ 'OK' ]: remainingSecs = retVal[ 'Value' ] if requiredLifeTime and requiredLifeTime <= vomsTime and requiredLifeTime <= remainingSecs: return S_OK( ( chain, min( vomsTime, remainingSecs ) ) ) retVal = self.getProxy( userDN, userGroup, requiredLifeTime ) if not retVal[ 'OK' ]: return retVal chain, secsLeft = retVal[ 'Value' ] if requiredLifeTime and requiredLifeTime > secsLeft: return S_ERROR( "Stored proxy is not long lived enough" ) vomsMgr = VOMS() retVal = vomsMgr.getVOMSAttributes( chain ) if retVal[ 'OK' ]: attrs = retVal[ 'Value' ] if len( attrs ) > 0: if attrs[0] != vomsAttr: return S_ERROR( "Stored proxy has already a different VOMS attribute %s than requested %s" % ( vomsAttr, attrs[0] ) ) else: result = self.__storeVOMSProxy( userDN, userGroup, vomsAttr, chain ) if not result[ 'OK' ]: return result secsLeft = result[ 'Value' ] if requiredLifeTime and requiredLifeTime <= secsLeft: return S_OK( ( chain, secsLeft ) ) return S_ERROR( "Stored proxy has already a different VOMS attribute and is not long lived enough" ) retVal = vomsMgr.setVOMSAttributes( chain , vomsAttr, vo = vomsVO ) if not retVal[ 'OK' ]: return S_ERROR( "Cannot append voms extension: %s" % retVal[ 'Message' ] ) chain = retVal[ 'Value' ] result = self.__storeVOMSProxy( userDN, userGroup, vomsAttr, chain ) if not result[ 'OK' ]: return result secsLeft = result[ 'Value' ] return S_OK( ( chain, secsLeft ) )
def getVOMSProxy(self, userDN, userGroup, requiredLifeTime=False, requestedVOMSAttr=False): """ Get proxy string from the Proxy Repository for use with userDN in the userGroup and VOMS attr """ retVal = self.__getVOMSAttribute(userGroup, requestedVOMSAttr) if not retVal['OK']: return retVal vomsAttr = retVal['Value']['attribute'] vomsVO = retVal['Value']['VOMSVO'] #Look in the cache retVal = self.__getPemAndTimeLeft(userDN, userGroup, vomsAttr) if retVal['OK']: pemData = retVal['Value'][0] vomsTime = retVal['Value'][1] chain = X509Chain() retVal = chain.loadProxyFromString(pemData) if retVal['OK']: retVal = chain.getRemainingSecs() if retVal['OK']: remainingSecs = retVal['Value'] if requiredLifeTime and requiredLifeTime <= vomsTime and requiredLifeTime <= remainingSecs: return S_OK((chain, min(vomsTime, remainingSecs))) retVal = self.getProxy(userDN, userGroup, requiredLifeTime) if not retVal['OK']: return retVal chain, secsLeft = retVal['Value'] if requiredLifeTime and requiredLifeTime > secsLeft: return S_ERROR("Stored proxy is not long lived enough") vomsMgr = VOMS() retVal = vomsMgr.getVOMSAttributes(chain) if retVal['OK']: attrs = retVal['Value'] if len(attrs) > 0: if attrs[0] != vomsAttr: return S_ERROR( "Stored proxy has already a different VOMS attribute %s than requested %s" % (vomsAttr, attrs[0])) else: result = self.__storeVOMSProxy(userDN, userGroup, vomsAttr, chain) if not result['OK']: return result secsLeft = result['Value'] if requiredLifeTime and requiredLifeTime <= secsLeft: return S_OK((chain, secsLeft)) return S_ERROR( "Stored proxy has already a different VOMS attribute and is not long lived enough" ) retVal = vomsMgr.setVOMSAttributes(chain, vomsAttr, vo=vomsVO) if not retVal['OK']: return S_ERROR("Cannot append voms extension: %s" % retVal['Message']) chain = retVal['Value'] result = self.__storeVOMSProxy(userDN, userGroup, vomsAttr, chain) if not result['OK']: return result secsLeft = result['Value'] return S_OK((chain, secsLeft))
sys.exit( 1 ) cliParams.setDIRACGroup( proxyInfo[ 'group' ] ) if myProxyFlag: uploadProxyToMyProxy( cliParams, False ) success = uploadProxyToDIRACProxyManager( cliParams ) if not success and cliParams.strict: sys.exit( 1 ) finalChain = proxyInfo[ 'chain' ] vomsMapping = CS.getVOMSAttributeForGroup( proxyInfo[ 'group' ] ) vo = CS.getVOMSVOForGroup( proxyInfo[ 'group' ] ) if vomsMapping: voms = VOMS() retVal = voms.setVOMSAttributes( finalChain, vomsMapping, vo ) if not retVal[ 'OK' ]: #print "Cannot add voms attribute %s to proxy %s: %s" % ( attr, proxyInfo[ 'path' ], retVal[ 'Message' ] ) msg = "Warning : Cannot add voms attribute %s to proxy\n" % ( vomsMapping ) msg += " Accessing data in the grid storage from the user interface will not be possible.\n" msg += " The grid jobs will not be affected." if cliParams.strict: gLogger.error( msg ) sys.exit( 1 ) gLogger.warn( msg ) else: finalChain = retVal[ 'Value' ] retVal = finalChain.dumpAllToFile( proxyInfo[ 'path' ] ) if not retVal[ 'OK' ]: gLogger.error( "Cannot write proxy to file %s" % proxyInfo[ 'path' ] )
success = uploadProxyToDIRACProxyManager(cliParams) if not success and cliParams.strict: sys.exit(1) cliParams.setDIRACGroup(proxyInfo['group']) #uploadProxyToMyProxy( cliParams, False ) success = uploadProxyToDIRACProxyManager(cliParams) if not success and cliParams.strict: sys.exit(1) finalChain = proxyInfo['chain'] vomsMapping = CS.getVOMSAttributeForGroup(proxyInfo['group']) if vomsMapping: voms = VOMS() retVal = voms.setVOMSAttributes(finalChain, vomsMapping, 'vo.cta.in2p3.fr') if not retVal['OK']: #print "Cannot add voms attribute %s to proxy %s: %s" % ( attr, proxyInfo[ 'path' ], retVal[ 'Message' ] ) print "Warning : Cannot add voms attribute %s to proxy" % (vomsMapping) print " Accessing data in the grid storage from the user interface will not be possible." print " The grid jobs will not be affected." if cliParams.strict: sys.exit(1) else: finalChain = retVal['Value'] retVal = finalChain.dumpAllToFile(proxyInfo['path']) if not retVal['OK']: print "Cannot write proxy to file %s" % proxyInfo['path'] sys.exit(1) cliParams.debugMsg("done")