当前位置: 首页>>代码示例>>Python>>正文


Python Proxy.getProxyFilename方法代码示例

本文整理汇总了Python中WMCore.Credential.Proxy.Proxy.getProxyFilename方法的典型用法代码示例。如果您正苦于以下问题:Python Proxy.getProxyFilename方法的具体用法?Python Proxy.getProxyFilename怎么用?Python Proxy.getProxyFilename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WMCore.Credential.Proxy.Proxy的用法示例。


在下文中一共展示了Proxy.getProxyFilename方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Proxy

# 需要导入模块: from WMCore.Credential.Proxy import Proxy [as 别名]
# 或者: from WMCore.Credential.Proxy.Proxy import getProxyFilename [as 别名]
class Proxy(Configurable):

    """
    Wrapper around CMS credentials.

    Parameters
    ----------
        renew : bool
            Whether to renew proxy.  Defaults to `True`.
    """

    _mutable = {}

    def __init__(self, renew=True):
        self.renew = renew
        self.__proxy = WMProxy({'logger': logging.getLogger("WMCore"), 'proxyValidity': '192:00'})
        self.__setup()

    def __setup(self):
        if self.check() and self.__proxy.getTimeLeft() > 4 * 3600:
            if 'X509_USER_PROXY' not in os.environ:
                os.environ['X509_USER_PROXY'] = self.__proxy.getProxyFilename()
        elif self.renew:
            self.__proxy.renew()
            if self.__proxy.getTimeLeft() < 4 * 3600:
                raise AttributeError("could not renew proxy")
            os.environ['X509_USER_PROXY'] = self.__proxy.getProxyFilename()
        else:
            raise AttributeError("please renew or disable your proxy")

    def __getstate__(self):
        state = dict(self.__dict__)
        del state['_Proxy__proxy']
        return state

    def __setstate__(self, state):
        self.__dict__.update(state)
        with PartiallyMutable.unlock():
            self.__proxy = WMProxy({'logger': logging.getLogger("WMCore"), 'proxyValidity': '192:00'})
            self.__setup()

    def check(self):
        left = self.__proxy.getTimeLeft()
        if left == 0:
            return False
        elif left < 4 * 3600:
            logger.warn("only {0}:{1:02} left in proxy lifetime!".format(left / 3600, left / 60))
        return True

    def expires(self):
        return int(time.time()) + self.__proxy.getTimeLeft()

    def time_left(self):
        return self.__proxy.getTimeLeft()
开发者ID:khurtado,项目名称:lobster,代码行数:56,代码来源:proxy.py

示例2: Proxy

# 需要导入模块: from WMCore.Credential.Proxy import Proxy [as 别名]
# 或者: from WMCore.Credential.Proxy.Proxy import getProxyFilename [as 别名]
class Proxy(object):
    '''
    CMS uses proxies constantly. This class is a wrapper function around WMCore
    proxy handling, to allow the user to update/check/delete their proxy in
    myproxy and update/check the local proxy
    '''


    def __init__(self):
        '''
        Constructor
        '''
        self.helper = WMCoreProxy({'logger' : logging})

    def getProxyFilename(self):
        return self.helper.getProxyFilename()
            
    def initProxy(self):
        self.helper.create()
        
    def deleteProxy(self):
        self.helper.destroy()
    
    def uploadToMyproxy(self, allowedDN):
        self.helper.serverDN = allowedDN
        self.helper.delegate( None, True )
开发者ID:PerilousApricot,项目名称:CMSYAAT,代码行数:28,代码来源:Proxy.py

示例3: get_proxy

# 需要导入模块: from WMCore.Credential.Proxy import Proxy [as 别名]
# 或者: from WMCore.Credential.Proxy.Proxy import getProxyFilename [as 别名]
 def get_proxy(self, ad):
     result = None
     vo = 'cms'
     group = ''
     role = ''
     if 'CRAB_UserVO' in ad and ad['CRAB_UserVO']:
         vo = ad['CRAB_UserVO']
     if 'CRAB_UserGroup' in ad and ad['CRAB_UserGroup'] and ad['CRAB_UserGroup'] != classad.Value.Undefined:
         group = ad['CRAB_UserGroup']
     if 'CRAB_UserRole' in ad and ad['CRAB_UserRole'] and ad['CRAB_UserRole'] != classad.Value.Undefined:
         role = ad['CRAB_UserRole']
     proxycfg = {'vo': vo,
                 'logger': self.logger,
                 'myProxySvr': self.config.Services.MyProxy,
                 'myproxyAccount': self.config.TaskWorker.resturl,
                 'proxyValidity' : '144:0',
                 'min_time_left' : MINPROXYLENGTH, ## do we need this ? or should we use self.myproxylen? 
                 'userDN' : ad['CRAB_UserDN'],
                 'group' : group,
                 'role' : role,
                 'server_key': self.config.MyProxy.serverhostkey,
                 'server_cert': self.config.MyProxy.serverhostcert,
                 'serverDN': self.config.MyProxy.serverdn,
                 'uisource': getattr(self.config.MyProxy, 'uisource', ''),
                 'credServerPath': self.config.MyProxy.credpath,
                 'cleanEnvironment' : getattr(self.config.MyProxy, 'cleanEnvironment', False)}
     proxy = Proxy(proxycfg)
     userproxy = proxy.getProxyFilename(serverRenewer=True)
     proxy.logonRenewMyProxy()
     timeleft = proxy.getTimeLeft(userproxy)
     if timeleft is None or timeleft <= 0:
         self.logger.error("Impossible to retrieve proxy from %s for %s." %(proxycfg['myProxySvr'], proxycfg['userDN']))
         raise Exception("Failed to retrieve proxy.")
     return userproxy
开发者ID:belforte,项目名称:CRABServer,代码行数:36,代码来源:RenewRemoteProxies.py

示例4: execute

# 需要导入模块: from WMCore.Credential.Proxy import Proxy [as 别名]
# 或者: from WMCore.Credential.Proxy.Proxy import getProxyFilename [as 别名]
 def execute(self, *args, **kwargs):
     result = None
     proxycfg = {'vo': kwargs['task']['tm_user_vo'],
                 'logger': self.logger,
                 'myProxySvr': self.config.Services.MyProxy,
                 'proxyValidity' : '144:0',
                 'min_time_left' : 36000, ## do we need this ? or should we use self.myproxylen? 
                 'userDN' : kwargs['task']['tm_user_dn'],
                 'group' : kwargs['task']['tm_user_group'] if kwargs['task']['tm_user_group'] else '',
                 'role' : kwargs['task']['tm_user_role'] if kwargs['task']['tm_user_role'] else '',
                 'server_key': self.config.MyProxy.serverhostkey,
                 'server_cert': self.config.MyProxy.serverhostcert,
                 'serverDN': self.config.MyProxy.serverdn,
                 'uisource': getattr(self.config.MyProxy, 'uisource', ''),
                 'credServerPath': self.config.MyProxy.credpath,
                 'myproxyAccount' : self.server['host'],
                 'cleanEnvironment' : getattr(self.config.MyProxy, 'cleanEnvironment', False)
                }
     proxy = Proxy(proxycfg)
     userproxy = proxy.getProxyFilename(serverRenewer=True)
     proxy.logonRenewMyProxy()
     timeleft = proxy.getTimeLeft(userproxy)
     if timeleft is None or timeleft <= 0:
         msg = "Impossible to retrieve proxy from %s for %s." % (proxycfg['myProxySvr'], proxycfg['userDN'])
         raise TaskWorkerException(msg)
     else:
         kwargs['task']['user_proxy'] = userproxy
         result = Result(task=kwargs['task'], result='OK')
     return result
开发者ID:HassenRiahi,项目名称:CRABServer,代码行数:31,代码来源:MyProxyLogon.py

示例5: testMyProxyEnvironment

# 需要导入模块: from WMCore.Credential.Proxy import Proxy [as 别名]
# 或者: from WMCore.Credential.Proxy.Proxy import getProxyFilename [as 别名]
    def testMyProxyEnvironment(self):
        """
        Test the myProxyEnvironment context manager
        In this test a new Proxy and MyProxy are initialized
        """
        myProxy = Proxy(self.dict)

        # Create the proxy
        myProxy.create()
        proxyPath = myProxy.getProxyFilename()
        userDN = myProxy.getSubject()
        self.assertTrue(os.path.exists(proxyPath))

        # Delegate and check the proxy
        myProxy.delegate(credential=proxyPath, serverRenewer=True)
        valid = myProxy.checkMyProxy()
        self.assertTrue(valid)

        # Make sure X509_USER_PROXY exists only in the context manager and corresponds to a file
        if 'X509_USER_PROXY' in os.environ:
            del os.environ['X509_USER_PROXY']
        self.assertFalse('X509_USER_PROXY' in os.environ)
        with myProxyEnvironment(userDN=userDN, serverCert=serverCert, serverKey=serverKey,
                                myproxySrv='myproxy.cern.ch', proxyDir='/tmp/', logger=self.logger):
            self.assertTrue('X509_USER_PROXY' in os.environ)
            self.assertTrue(os.path.exists(os.environ['X509_USER_PROXY']))
        self.assertFalse('X509_USER_PROXY' in os.environ)

        return
开发者ID:AndresTanasijczuk,项目名称:WMCore,代码行数:31,代码来源:MyProxy_t.py

示例6: execute

# 需要导入模块: from WMCore.Credential.Proxy import Proxy [as 别名]
# 或者: from WMCore.Credential.Proxy.Proxy import getProxyFilename [as 别名]
 def execute(self, *args, **kwargs):
     result = None
     proxycfg = {'vo': kwargs['task']['tm_user_vo'],
                 'logger': self.logger,
                 'myProxySvr': self.config.Services.MyProxy,
                 'proxyValidity' : '144:0',
                 'min_time_left' : 36000, ## do we need this ? or should we use self.myproxylen? 
                 'userDN' : kwargs['task']['tm_user_dn'],
                 'group' : kwargs['task']['tm_user_group'] if kwargs['task']['tm_user_group'] else '',
                 'role' : kwargs['task']['tm_user_role'] if kwargs['task']['tm_user_role'] else '',
                 'server_key': self.config.MyProxy.serverhostkey,
                 'server_cert': self.config.MyProxy.serverhostcert,
                 'serverDN': self.config.MyProxy.serverdn,
                 'uisource': getattr(self.config.MyProxy, 'uisource', ''),
                 'credServerPath': self.config.MyProxy.credpath,
                 'myproxyAccount' : self.server['host'],
                 'cleanEnvironment' : getattr(self.config.MyProxy, 'cleanEnvironment', False)
                }
     # WMCore proxy methods are awfully verbode, reduce logging level when using them
     with tempSetLogLevel(logger=self.logger, level=logging.ERROR):
         proxy = Proxy(proxycfg)
         userproxy = proxy.getProxyFilename(serverRenewer=True)
         proxy.logonRenewMyProxy()
         timeleft = proxy.getTimeLeft(userproxy)
         usergroups = set(proxy.getAllUserGroups(userproxy))
     if timeleft is None or timeleft <= 0:
         msg = "Impossible to retrieve proxy from %s for %s." % (proxycfg['myProxySvr'], proxycfg['userDN'])
         self.logger.error(msg)
         self.logger.error("\n Will try again in verbose mode")
         self.logger.error("===========PROXY ERROR START ==========================")
         with tempSetLogLevel(logger=self.logger, level=logging.DEBUG):
             userproxy = proxy.getProxyFilename(serverRenewer=True)
             proxy.logonRenewMyProxy()
             timeleft = proxy.getTimeLeft(userproxy)
             usergroups = set(proxy.getAllUserGroups(userproxy))
         self.logger.error("===========PROXY ERROR END   ==========================")
         raise TaskWorkerException(msg)
     else:
         kwargs['task']['user_proxy'] = userproxy
         kwargs['task']['user_groups'] = usergroups
         self.logger.debug("Valid proxy for %s now in %s", proxycfg['userDN'], userproxy)
         result = Result(task=kwargs['task'], result='OK')
     return result
开发者ID:belforte,项目名称:CRABServer,代码行数:45,代码来源:MyProxyLogon.py

示例7: __init__

# 需要导入模块: from WMCore.Credential.Proxy import Proxy [as 别名]
# 或者: from WMCore.Credential.Proxy.Proxy import getProxyFilename [as 别名]
    def __init__(self, config):
        BasePlugin.__init__(self, config)

        self.locationDict = {}

        myThread = threading.currentThread()
        daoFactory = DAOFactory(package="WMCore.WMBS", logger=myThread.logger,
                                dbinterface=myThread.dbi)
        self.locationAction = daoFactory(classname="Locations.GetSiteInfo")

        self.packageDir = None

        if os.path.exists(os.path.join(getWMBASE(),
                                       'src/python/WMCore/WMRuntime/Unpacker.py')):
            self.unpacker = os.path.join(getWMBASE(),
                                         'src/python/WMCore/WMRuntime/Unpacker.py')
        else:
            self.unpacker = os.path.join(getWMBASE(),
                                         'WMCore/WMRuntime/Unpacker.py')

        self.agent = getattr(config.Agent, 'agentName', 'WMAgent')
        self.sandbox = None

        self.scriptFile = config.JobSubmitter.submitScript

        self.defaultTaskPriority = getattr(config.BossAir, 'defaultTaskPriority', 0)
        self.maxTaskPriority = getattr(config.BossAir, 'maxTaskPriority', 1e7)
        self.jobsPerSubmit = getattr(config.JobSubmitter, 'jobsPerSubmit', 200)
        self.extraMem = getattr(config.JobSubmitter, 'extraMemoryPerCore', 500)

        # Required for global pool accounting
        self.acctGroup = getattr(config.BossAir, 'acctGroup', "production")
        self.acctGroupUser = getattr(config.BossAir, 'acctGroupUser', "cmsdataops")

        # Build a requirement string.  All CMS resources match DESIRED_Sites on the START
        # expression side; however, there are currently some resources (T2_CH_CERN_HLT)
        # that are missing the REQUIRED_OS logic.  Hence, we duplicate it here.
        # TODO(bbockelm): Remove reqStr once HLT has upgraded.
        self.reqStr = ('((REQUIRED_OS=?="any") || '
                       '(GLIDEIN_REQUIRED_OS =?= "any") || '
                       'stringListMember(GLIDEIN_REQUIRED_OS, REQUIRED_OS)) && '
                       '(AuthenticatedIdentity =!= "[email protected]")')
        if hasattr(config.BossAir, 'condorRequirementsString'):
            self.reqStr = config.BossAir.condorRequirementsString

        # x509 proxy handling
        proxy = Proxy({'logger': myThread.logger})
        self.x509userproxy = proxy.getProxyFilename()
        self.x509userproxysubject = proxy.getSubject()
        self.x509userproxyfqan = proxy.getAttributeFromProxy(self.x509userproxy)
        # Remove the x509 ads if the job is matching a volunteer resource
        self.x509Expr = 'ifThenElse("$$(GLIDEIN_CMSSite)" =?= "T3_CH_Volunteer",undefined,"%s")'

        return
开发者ID:belforte,项目名称:WMCore,代码行数:56,代码来源:SimpleCondorPlugin.py

示例8: query_database

# 需要导入模块: from WMCore.Credential.Proxy import Proxy [as 别名]
# 或者: from WMCore.Credential.Proxy.Proxy import getProxyFilename [as 别名]
    def query_database(self):
        cred = Proxy({'logger': logging.getLogger("WMCore")})
        dbs = DASWrapper(self.dbs_instance, ca_info=cred.getProxyFilename())

        baseinfo = dbs.listFileSummaries(dataset=self.dataset)
        if baseinfo is None or (len(baseinfo) == 1 and baseinfo[0] is None):
            raise ValueError('unable to retrive information for dataset {}'.format(self.dataset))

        if not self.file_based:
            result = self.__cache.cached(self.dataset, self.lumi_mask, baseinfo)
            if result:
                return result
        total_lumis = sum([info['num_lumi'] for info in baseinfo])

        result = DatasetInfo()
        result.total_events = sum([info['num_event'] for info in baseinfo])

        for info in dbs.listFiles(dataset=self.dataset, detail=True):
            fn = info['logical_file_name']
            result.files[fn].events = info['event_count']
            result.files[fn].size = info['file_size']

        if self.file_based:
            for info in dbs.listFiles(dataset=self.dataset):
                fn = info['logical_file_name']
                result.files[fn].lumis = [(-2, -2)]
        else:
            blocks = dbs.listBlocks(dataset=self.dataset)
            if self.lumi_mask:
                unmasked_lumis = LumiList(filename=self.lumi_mask)
            for block in blocks:
                runs = dbs.listFileLumis(block_name=block['block_name'])
                for run in runs:
                    fn = run['logical_file_name']
                    for lumi in run['lumi_section_num']:
                        if not self.lumi_mask or ((run['run_num'], lumi) in unmasked_lumis):
                            result.files[fn].lumis.append((run['run_num'], lumi))
                        elif self.lumi_mask and ((run['run_num'], lumi) not in unmasked_lumis):
                            result.masked_units += 1

        result.unmasked_units = sum([len(f.lumis) for f in result.files.values()])
        result.total_units = result.unmasked_units + result.masked_units

        if not self.file_based:
            self.__cache.cache(self.dataset, self.lumi_mask, baseinfo, result)

        result.stop_on_file_boundary = (result.total_units != total_lumis) and not self.file_based
        if result.stop_on_file_boundary:
            logger.debug("split lumis detected in {} - "
                         "{} unique (run, lumi) but "
                         "{} unique (run, lumi, file) - "
                         "enforcing a limit of one file per task".format(self.dataset, total_lumis, result.total_units))

        return result
开发者ID:khurtado,项目名称:lobster,代码行数:56,代码来源:dataset.py

示例9: validate

# 需要导入模块: from WMCore.Credential.Proxy import Proxy [as 别名]
# 或者: from WMCore.Credential.Proxy.Proxy import getProxyFilename [as 别名]
    def validate(self):
        if self.dataset in Dataset.__dsets:
            return True

        if self.lumi_mask:
            self.lumi_mask = self.__get_mask(self.lumi_mask)

        cred = Proxy({'logger': logging.getLogger("WMCore")})
        dbs = DASWrapper(self.dbs_instance, ca_info=cred.getProxyFilename())

        baseinfo = dbs.listFileSummaries(dataset=self.dataset)
        if baseinfo is None or (len(baseinfo) == 1 and baseinfo[0] is None):
            return False
        return True
开发者ID:khurtado,项目名称:lobster,代码行数:16,代码来源:dataset.py

示例10: getProxy

# 需要导入模块: from WMCore.Credential.Proxy import Proxy [as 别名]
# 或者: from WMCore.Credential.Proxy.Proxy import getProxyFilename [as 别名]
def getProxy(userdn, group, role, defaultDelegation, logger):
    """
    _getProxy_
    """
    log.debug("Retrieving proxy for %s" % userdn)
    proxy = Proxy(defaultDelegation)
    proxyPath = proxy.getProxyFilename( True )
    timeleft = proxy.getTimeLeft( proxyPath )
    if timeleft is not None and timeleft > 3600:
        return (True, proxyPath)
    proxyPath = proxy.logonRenewMyProxy()
    timeleft = proxy.getTimeLeft( proxyPath )
    if timeleft is not None and timeleft > 0:
        return (True, proxyPath)
    return (False, None)
开发者ID:TonyWildish,项目名称:ASO-monitor,代码行数:17,代码来源:__init__.py

示例11: createNewVomsProxy

# 需要导入模块: from WMCore.Credential.Proxy import Proxy [as 别名]
# 或者: from WMCore.Credential.Proxy.Proxy import getProxyFilename [as 别名]
    def createNewVomsProxy(self, timeleftthreshold=0):
        """
        Handles the proxy creation:
           - checks if a valid proxy still exists
           - performs the creation if it is expired
        """
        ## TODO add the change to have user-cert/key defined in the config.
        userproxy = Proxy( self.defaultDelegation )
        userproxy.userDN = userproxy.getSubject()

        proxytimeleft = 0
        self.logger.debug("Getting proxy life time left")
        # does it return an integer that indicates?
        proxytimeleft = userproxy.getTimeLeft()
        self.logger.debug("Proxy is valid: %i" % proxytimeleft)

        #if it is not expired I check if role and/or group are changed
        if not proxytimeleft < timeleftthreshold and self.defaultDelegation['role']!=None and  self.defaultDelegation['group']!=None:
            group , role = userproxy.getUserGroupAndRoleFromProxy( userproxy.getProxyFilename())
            if group != self.defaultDelegation['group'] or role != self.defaultDelegation['role']:
                self.proxyChanged = True

        #if the proxy is expired, or we changed role and/or group, we need to create a new one
        if proxytimeleft < timeleftthreshold or self.proxyChanged:
            # creating the proxy
            self.logger.debug("Creating a proxy for %s hours" % self.defaultDelegation['proxyValidity'] )
            userproxy.create()
            proxytimeleft = userproxy.getTimeLeft()
            group , role = userproxy.getUserGroupAndRoleFromProxy( userproxy.getProxyFilename())

            if proxytimeleft > 0 and group == self.defaultDelegation['group'] and role == self.defaultDelegation['role']:
                self.logger.debug("Proxy created.")
            else:
                raise ProxyCreationException("Problems creating proxy.")

        return userproxy.getSubject( ), userproxy.getProxyFilename()
开发者ID:bbockelm,项目名称:CRABClient,代码行数:38,代码来源:CredentialInteractions.py

示例12: __init__

# 需要导入模块: from WMCore.Credential.Proxy import Proxy [as 别名]
# 或者: from WMCore.Credential.Proxy.Proxy import getProxyFilename [as 别名]
    def __init__(self, config):
        BasePlugin.__init__(self, config)

        self.locationDict = {}

        myThread = threading.currentThread()
        daoFactory = DAOFactory(package="WMCore.WMBS", logger=myThread.logger,
                                dbinterface=myThread.dbi)
        self.locationAction = daoFactory(classname="Locations.GetSiteInfo")

        self.packageDir = None

        if os.path.exists(os.path.join(getWMBASE(),
                                       'src/python/WMCore/WMRuntime/Unpacker.py')):
            self.unpacker = os.path.join(getWMBASE(),
                                         'src/python/WMCore/WMRuntime/Unpacker.py')
        else:
            self.unpacker = os.path.join(getWMBASE(),
                                         'WMCore/WMRuntime/Unpacker.py')

        self.agent = getattr(config.Agent, 'agentName', 'WMAgent')
        self.sandbox = None

        self.scriptFile = config.JobSubmitter.submitScript

        self.defaultTaskPriority = getattr(config.BossAir, 'defaultTaskPriority', 0)
        self.maxTaskPriority = getattr(config.BossAir, 'maxTaskPriority', 1e7)
        self.jobsPerSubmit = getattr(config.JobSubmitter, 'jobsPerSubmit', 200)
        self.extraMem = getattr(config.JobSubmitter, 'extraMemoryPerCore', 500)

        # Required for global pool accounting
        self.acctGroup = getattr(config.BossAir, 'acctGroup', "production")
        self.acctGroupUser = getattr(config.BossAir, 'acctGroupUser', "cmsdataops")

        # Build a requirement string
        self.reqStr = ('stringListMember(GLIDEIN_CMSSite, DESIRED_Sites) '
                       '&& ((REQUIRED_OS=?="any") || stringListMember(GLIDEIN_REQUIRED_OS, REQUIRED_OS))'
                       '&& (TARGET.Cpus >= RequestCpus)')
        if hasattr(config.BossAir, 'condorRequirementsString'):
            self.reqStr = config.BossAir.condorRequirementsString

        # x509 proxy handling
        proxy = Proxy({'logger': myThread.logger})
        self.x509userproxy = proxy.getProxyFilename()
        self.x509userproxysubject = proxy.getSubject()

        return
开发者ID:PerilousApricot,项目名称:WMCore,代码行数:49,代码来源:SimpleCondorPlugin.py

示例13: getProxy

# 需要导入模块: from WMCore.Credential.Proxy import Proxy [as 别名]
# 或者: from WMCore.Credential.Proxy.Proxy import getProxyFilename [as 别名]
def getProxy(config, userdn, group, role):
    """
    _getProxy_
    """
    defaultDelegation = getDefaultDelegation(config, "cms", "myproxy.cern.ch", threading.currentThread().logger)
    defaultDelegation['userDN'] = userdn
    defaultDelegation['group'] = group
    defaultDelegation['role'] = role

    logging.debug("Retrieving proxy for %s" % userdn)
    proxy = Proxy(defaultDelegation)
    proxyPath = proxy.getProxyFilename( True )
    timeleft = proxy.getTimeLeft( proxyPath )
    if timeleft is not None and timeleft > 3600:
        return (True, proxyPath)
    proxyPath = proxy.logonRenewMyProxy()
    timeleft = proxy.getTimeLeft( proxyPath )
    if timeleft is not None and timeleft > 0:
        return (True, proxyPath)
    return (False, None)
开发者ID:stuartw,项目名称:WMCore,代码行数:22,代码来源:TaskArchiverPoller.py

示例14: get_proxy

# 需要导入模块: from WMCore.Credential.Proxy import Proxy [as 别名]
# 或者: from WMCore.Credential.Proxy.Proxy import getProxyFilename [as 别名]
 def get_proxy(self, ad):
     result = None
     vo = "cms"
     group = ""
     role = ""
     if "CRAB_UserVO" in ad and ad["CRAB_UserVO"]:
         vo = ad["CRAB_UserVO"]
     if "CRAB_UserGroup" in ad and ad["CRAB_UserGroup"] and ad["CRAB_UserGroup"] != classad.Value.Undefined:
         group = ad["CRAB_UserGroup"]
     if "CRAB_UserRole" in ad and ad["CRAB_UserRole"] and ad["CRAB_UserRole"] != classad.Value.Undefined:
         role = ad["CRAB_UserRole"]
     print vo, group, role
     proxycfg = {
         "vo": vo,
         "logger": self.logger,
         "myProxySvr": self.config.Services.MyProxy,
         "myproxyAccount": self.config.TaskWorker.resturl,
         "proxyValidity": "144:0",
         "min_time_left": MINPROXYLENGTH,  ## do we need this ? or should we use self.myproxylen?
         "userDN": ad["CRAB_UserDN"],
         "group": group,
         "role": role,
         "server_key": self.config.MyProxy.serverhostkey,
         "server_cert": self.config.MyProxy.serverhostcert,
         "serverDN": self.config.MyProxy.serverdn,
         "uisource": getattr(self.config.MyProxy, "uisource", ""),
         "credServerPath": self.config.MyProxy.credpath,
         "cleanEnvironment": getattr(self.config.MyProxy, "cleanEnvironment", False),
     }
     proxy = Proxy(proxycfg)
     userproxy = proxy.getProxyFilename(serverRenewer=True)
     proxy.logonRenewMyProxy()
     timeleft = proxy.getTimeLeft(userproxy)
     if timeleft is None or timeleft <= 0:
         self.logger.error(
             "Impossible to retrieve proxy from %s for %s." % (proxycfg["myProxySvr"], proxycfg["userDN"])
         )
         raise Exception("Failed to retrieve proxy.")
     return userproxy
开发者ID:nizamyusli,项目名称:CRABServer,代码行数:41,代码来源:RenewRemoteProxies.py

示例15: execute

# 需要导入模块: from WMCore.Credential.Proxy import Proxy [as 别名]
# 或者: from WMCore.Credential.Proxy.Proxy import getProxyFilename [as 别名]
 def execute(self, *args, **kwargs):
     result = None
     proxycfg = {
         "vo": kwargs["task"]["tm_user_vo"],
         "logger": self.logger,
         "myProxySvr": self.config.Services.MyProxy,
         "proxyValidity": "24:0",
         "min_time_left": 36000,  ## do we need this ? or should we use self.myproxylen?
         "userDN": kwargs["task"]["tm_user_dn"],
         "group": kwargs["task"]["tm_user_group"] if kwargs["task"]["tm_user_group"] else "",
         "role": kwargs["task"]["tm_user_role"] if kwargs["task"]["tm_user_role"] else "",
         "server_key": self.config.MyProxy.serverhostkey,
         "server_cert": self.config.MyProxy.serverhostcert,
         "serverDN": self.config.MyProxy.serverdn,
         "uisource": self.config.MyProxy.uisource,
         "credServerPath": self.config.MyProxy.credpath,
     }
     proxy = Proxy(proxycfg)
     userproxy = proxy.getProxyFilename(serverRenewer=True)
     proxy.logonRenewMyProxy()
     timeleft = proxy.getTimeLeft(userproxy)
     if timeleft is None or timeleft <= 0:
         msg = "Impossible to retrieve proxy from %s for %s." % (proxycfg["myProxySvr"], proxycfg["userDN"])
         self.logger.error("Setting %s as failed" % str(kwargs["task"]["tm_taskname"]))
         configreq = {
             "workflow": kwargs["task"]["tm_taskname"],
             "status": "FAILED",
             "subresource": "failure",
             "failure": b64encode(msg),
         }
         self.logger.error(str(configreq))
         self.server.post(self.resturl, data=urllib.urlencode(configreq))
         raise StopHandler(msg)
     else:
         kwargs["task"]["user_proxy"] = userproxy
         result = Result(task=kwargs["task"], result="OK")
     return result
开发者ID:bbockelm,项目名称:CAFTaskWorker,代码行数:39,代码来源:MyProxyLogon.py


注:本文中的WMCore.Credential.Proxy.Proxy.getProxyFilename方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。