def _getProxyInfo( proxyPath = False ): if not proxyPath: proxyPath = _getProxyLocation( ) proxy_info = ProxyInfo.getProxyInfo( proxyPath, False ) return proxy_info
def __init__(self, *args, **kw): fuse.fuse_python_api = (0, 2) fuse.Fuse.__init__(self, *args, **kw) self.tmpdir = tmpdir self.SE = "DIRAC-USER" self.file = {} self.result = {} from DIRAC.Core.Security import ProxyInfo self.proxy = ProxyInfo.getProxyInfo()
def main(): """ main program entry point """ options = Params() options.registerCLISwitches() Script.parseCommandLine(ignoreErrors=True) if options.delete_all and options.vos: gLogger.error( "-a and -v options are mutually exclusive. Please pick one or the other." ) return 1 proxyLoc = Locations.getDefaultProxyLocation() if not os.path.exists(proxyLoc): gLogger.error("No local proxy found in %s, exiting." % proxyLoc) return 1 result = ProxyInfo.getProxyInfo(proxyLoc, True) if not result['OK']: raise RuntimeError('Failed to get local proxy info.') if result['Value']['secondsLeft'] < 60 and options.needsValidProxy(): raise RuntimeError( 'Lifetime of local proxy too short, please renew proxy.') userDN = result['Value']['identity'] if options.delete_all: # delete remote proxies remote_groups = getProxyGroups() if not remote_groups: gLogger.notice('No remote proxies found.') for vo_group in remote_groups: deleteRemoteProxy(userDN, vo_group) # delete local proxy deleteLocalProxy(proxyLoc) elif options.vos: vo_groups = set() for voname in options.vos: vo_groups.update(mapVoToGroups(voname)) # filter set of all groups to only contain groups for which there is a user proxy user_groups = getProxyGroups() vo_groups.intersection_update(user_groups) if not vo_groups: gLogger.notice( 'You have no proxies registered for any of the specified VOs.') for group in vo_groups: deleteRemoteProxy(userDN, group) else: deleteLocalProxy(proxyLoc) return 0
def _userInfo(): retVal = ProxyInfo.getProxyInfo() assert retVal["OK"], retVal proxyInfo = retVal["Value"] currentUser = proxyInfo["username"] currentDN = proxyInfo["DN"] currentGroup = proxyInfo["group"] userVO = Registry.getVOForGroup(currentGroup) return currentUser, currentDN, currentGroup, userVO
def main(): """ main program entry point """ options = Params() options.registerCLISwitches() Script.parseCommandLine( ignoreErrors = True ) if options.delete_all and options.vos: gLogger.error( "-a and -v options are mutually exclusive. Please pick one or the other." ) return 1 proxyLoc = Locations.getDefaultProxyLocation() if not os.path.exists( proxyLoc ): gLogger.error( "No local proxy found in %s, exiting." % proxyLoc ) return 1 result = ProxyInfo.getProxyInfo( proxyLoc, True ) if not result[ 'OK' ]: raise RuntimeError( 'Failed to get local proxy info.' ) if result[ 'Value' ][ 'secondsLeft' ] < 60 and options.needsValidProxy(): raise RuntimeError( 'Lifetime of local proxy too short, please renew proxy.' ) userDN=result[ 'Value' ][ 'identity' ] if options.delete_all: # delete remote proxies remote_groups = getProxyGroups() if not remote_groups: gLogger.notice( 'No remote proxies found.' ) for vo_group in remote_groups: deleteRemoteProxy( userDN, vo_group ) # delete local proxy deleteLocalProxy( proxyLoc ) elif options.vos: vo_groups = set() for voname in options.vos: vo_groups.update(mapVoToGroups( voname ) ) # filter set of all groups to only contain groups for which there is a user proxy user_groups = getProxyGroups() vo_groups.intersection_update( user_groups ) if not vo_groups: gLogger.notice( 'You have no proxies registered for any of the specified VOs.' ) for group in vo_groups: deleteRemoteProxy( userDN, group ) else: deleteLocalProxy( proxyLoc ) return 0
def setUpClass( cls ): # destroy kerberos token #try: # subprocess.call(['kdestroy']) #except subprocess.CalledProcessError as err: # print "WARNING: kdestroy did not succeed." # print err.output # Constants for the tests Script.parseCommandLine() user = ProxyInfo.getProxyInfo()['Value']['username'] SETestCase.lfntestfilepath += '%s/%s/setests/%s/' % (user[0], user, randomFolder()) print "Using lfn %s" % SETestCase.lfntestfilepath SETestCase.lfntestfile = SETestCase.lfntestfilepath + SETestCase.lfntestfilename
def setUpClass(cls): # destroy kerberos token #try: # subprocess.call(['kdestroy']) #except subprocess.CalledProcessError as err: # print "WARNING: kdestroy did not succeed." # print err.output # Constants for the tests Script.parseCommandLine() user = ProxyInfo.getProxyInfo()['Value']['username'] SETestCase.lfntestfilepath += '%s/%s/setests/%s/' % (user[0], user, randomFolder()) print "Using lfn %s" % SETestCase.lfntestfilepath SETestCase.lfntestfile = SETestCase.lfntestfilepath + SETestCase.lfntestfilename
def submitJob( self, executableFile, proxyObj, jobData ): """ Method to submit job """ self.log.info( "Executable file is %s" % executableFile ) self.__proxyObj = proxyObj self.__execFile = executableFile self.__jobData = jobData self.log.verbose( 'Setting up proxy for payload' ) result = self.writeProxyToFile( self.__proxyObj ) if not result['OK']: return result self.__payloadProxyLocation = result['Value'] glEnabled = True glOK = True if gConfig.getValue( "/DIRAC/Security/UseServerCertificate", False ): self.log.info( "Running with a certificate. Avoid using glexec" ) glEnabled = False else: result = ProxyInfo.getProxyInfo( self.__pilotProxyLocation, disableVOMS = True ) if result[ 'OK' ]: if not Properties.GENERIC_PILOT in result[ 'Value' ].get( 'groupProperties', [] ): self.log.info( "Pilot is NOT running with a generic pilot. Skipping glexec" ) glEnabled = False else: self.log.info( "Pilot is generic. Trying glexec" ) if not glEnabled: self.log.notice( "glexec is not enabled ") else: self.log.info( "Trying glexec..." ) for step in ( self.__check_credentials, self.__locate_glexec, self.__prepare_glenv, self.__prepare_tmpdir, self.__test, self.__construct_payload ): self.log.info( "Running step %s" % step.__name__ ) result = step() if not result[ 'OK' ]: self.log.error( "Step %s failed: %s" % ( step.__name__, result[ 'Message' ] ) ) if self.ceParameters.get( "RescheduleOnError", False ): result = S_ERROR( 'glexec CE failed on step %s : %s' % ( step.__name__, result[ 'Message' ] ) ) result['ReschedulePayload'] = True return result glOK = False break if not glOK: self.log.notice( "glexec failed miserably... Running without it." ) self.log.verbose( 'Starting process for monitoring payload proxy' ) result = gThreadScheduler.addPeriodicTask( self.proxyCheckPeriod, self.monitorProxy, taskArgs = ( self.__pilotProxyLocation, self.__payloadProxyLocation ), executions = 0, elapsedTime = 0 ) if not result[ 'OK' ]: return S_ERROR( "Could not schedule monitor proxy task: %s" % result[ 'Message' ] ) pTask = result[ 'Value' ] if glEnabled and glOK: result = self.__execute( [ self.__glCommand ] ) else: result = self.__executeInProcess( executableFile ) gThreadScheduler.removeTask( pTask ) self.__cleanup() return result