Beispiel #1
0
    def __init__(self, serverName, serverPort, cfg_params, proxyPath=None):
        """
        Open the communication with an Analysis Server by passing the server URL and the port
        """

        self.ServerTwiki = 'https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideCrabServerForUsers#Server_available_for_users'

        self.asSession = C_AS_Session(serverName, serverPort)
        self.cfg_params = cfg_params
        self.userSubj = ''
        self.serverName = serverName
        credentialType = 'Proxy'
        if common.scheduler.name().upper() in ['CAF','LSF']:
            credentialType = 'Token'
        CliServerParams(self)
        self.crab_task_name = common.work_space.topDir().split('/')[-2] # nice task name "crab_0_..."

        configAPI = {'credential' : credentialType, \
                     'logger' : common.logger() }

        CredAPI =  CredentialAPI( configAPI )
        try:
            self.userSubj = CredAPI.getSubject()
        except Exception, err:
            common.logger.debug("Getting Credential Subject: " +str(traceback.format_exc()))
            raise CrabException("Error Getting Credential Subject")
Beispiel #2
0
class CredentialRenew(Actor):
    def __init__(self, cfg_params):
        self.cfg_params = cfg_params
        self.credentialType = 'Proxy'
        if common.scheduler.name().upper() in ['LSF', 'CAF']:
            self.credentialType = 'Token'

        # init client server params...
        CliServerParams(self)

    def run(self):
        """
        """

        common.logger.debug("CredentialRenew::run() called")

        # FIXME With MyProxy delegation this part is completely overlapped with the method manageDelegation
        # in SubmitServer. We should to maintain just one version of the method in a common part

        try:
            myproxyserver = Downloader(
                "http://cmsdoc.cern.ch/cms/LCG/crab/config/").config(
                    "myproxy_server.conf")
            myproxyserver = myproxyserver.strip()
            if myproxyserver is None:
                raise CrabException("myproxy_server.conf retrieved but empty")
        except Exception, e:
            common.logger.info(
                "Problem setting myproxy server endpoint: using myproxy.cern.ch"
            )
            common.logger.debug(e)
            myproxyserver = 'myproxy.cern.ch'

        configAPI = {'credential' : self.credentialType, \
                     'myProxySvr' : myproxyserver,\
                     'serverDN'   : self.server_dn,\
                     'shareDir'   : common.work_space.shareDir() ,\
                     'userName'   : getUserName(),\
                     'serverName' : self.server_name, \
                     'logger' : common.logger() \
                     }
        try:
            CredAPI = CredentialAPI(configAPI)
        except Exception, err:
            common.logger.debug("Configuring Credential API: " +
                                str(traceback.format_exc()))
            raise CrabException(
                "ERROR: Unable to configure Credential Client API  %s\n" %
                str(err))
Beispiel #3
0
    def checkProxy(self, minTime=10):
        """
        Function to check the Globus proxy.
        """
        if (self.proxyValid): return

        ### Just return if asked to do so
        if (self.dontCheckProxy == 1):
            self.proxyValid = 1
            return
        CredAPI_config =  { 'credential':'Proxy',\
                            'myProxySvr': self.proxyServer, \
                            'logger': common.logger() \
                          }
        from ProdCommon.Credential.CredentialAPI import CredentialAPI
        CredAPI = CredentialAPI(CredAPI_config)

        if not CredAPI.checkCredential(Time=int(minTime)) or \
           not CredAPI.checkAttribute(group=self.group, role=self.role):
            try:
                CredAPI.ManualRenewCredential(group=self.group, role=self.role)
            except Exception, ex:
                raise CrabException(str(ex))
Beispiel #4
0
            )
            common.logger.debug(e)
            myproxyserver = 'myproxy.cern.ch'

        configAPI = {'credential' : self.credentialType, \
                     'myProxySvr' : myproxyserver,\
                     'serverDN'   : self.server_dn,\
                     'shareDir'   : common.work_space.shareDir() ,\
                     'userName'   : getUserName(),\
                     'serverName' : self.server_name, \
                     'proxyPath'  : self.proxy_path, \
                     'logger'     : common.logger() \
                     }

        try:
            CredAPI = CredentialAPI(configAPI)
        except Exception, err:
            common.logger.debug("Configuring Credential API: " +
                                str(traceback.format_exc()))
            raise CrabException(
                "ERROR: Unable to configure Credential Client API  %s\n" %
                str(err))

        if self.credentialType == 'Proxy':
            # Proxy delegation through MyProxy, 4 days lifetime minimum
            if not CredAPI.checkMyProxy(Time=4, checkRetrieverRenewer=True):
                common.logger.info("Please renew MyProxy delegated proxy:\n")
                try:
                    CredAPI.credObj.serverDN = self.server_dn
                    CredAPI.ManualRenewMyProxy()
                except Exception, ex: