Beispiel #1
0
    def serverInstance(self):
        """
        Deriving the correct instance to use and the server url. Client is allowed to propagate the instance name and corresponding url
        via crabconfig.py or crab option --instance. The variable passed via crab option will always be used over the variable
        in crabconfig.py. Instance name other than specify in the SERVICE_INSTANCE will be treated as a private instance.
        """

        if hasattr(self.options, 'instance') and self.options.instance is not None:
            if hasattr(self, 'configuration') and hasattr(self.configuration.General, 'instance') and self.configuration.General.instance is not None:
                msg  = "%sWarning%s: CRAB configuration parameter General.instance is overwritten by the command option --instance;" % (colors.RED, colors.NORMAL)
                msg += " %s intance will be used." % (self.options.instance)
                self.logger.info(msg)
            if self.options.instance in SERVICE_INSTANCES.keys():
                instance = self.options.instance
                serverurl = SERVICE_INSTANCES[instance]
            else:
                instance = 'private'
                serverurl = self.options.instance
        elif hasattr(self, 'configuration') and hasattr(self.configuration.General, 'instance') and self.configuration.General.instance is not None:
            if self.configuration.General.instance in SERVICE_INSTANCES.keys():
                instance = self.configuration.General.instance
                serverurl = SERVICE_INSTANCES[instance]
            else:
                instance = 'private'
                serverurl = self.configuration.General.instance
        else:
            instance = getParamDefaultValue('General.instance')
            serverurl = SERVICE_INSTANCES[instance]

        return instance, serverurl
Beispiel #2
0
    def serverInstance(self):
        """
        Deriving the correct instance to use and the server url. Client is allowed to propagate the instance name and corresponding url
        via crabconfig.py or crab option --instance. The variable passed via crab option will always be used over the variable
        in crabconfig.py. Instance name other than specify in the SERVICE_INSTANCE will be treated as a private instance.
        """

        if hasattr(self.options, 'instance') and self.options.instance is not None:
            if hasattr(self, 'configuration') and hasattr(self.configuration.General, 'instance') and self.configuration.General.instance is not None:
                msg  = "%sWarning%s: CRAB configuration parameter General.instance is overwritten by the command option --instance;" % (colors.RED, colors.NORMAL)
                msg += " %s intance will be used." % (self.options.instance)
                self.logger.info(msg)
            if self.options.instance in SERVICE_INSTANCES.keys():
                instance = self.options.instance
                serverurl = SERVICE_INSTANCES[instance]
            else:
                instance = 'private'
                serverurl = self.options.instance
        elif hasattr(self, 'configuration') and hasattr(self.configuration.General, 'instance') and self.configuration.General.instance is not None:
            if self.configuration.General.instance in SERVICE_INSTANCES.keys():
                instance = self.configuration.General.instance
                serverurl = SERVICE_INSTANCES[instance]
            else:
                instance = 'private'
                serverurl = self.configuration.General.instance
        else:
            instance = getParamDefaultValue('General.instance')
            serverurl = SERVICE_INSTANCES[instance]

        return instance, serverurl
Beispiel #3
0
 def getUrl(self, instance='prod', resource='workflow'):
     """
     Retrieve the url depending on the resource we are accessing and the instance.
     """
     if instance in SERVICE_INSTANCES.keys():
         return BASEURL + instance + '/' + resource
     elif instance == 'private':
         return BASEURL + 'dev' + '/' + resource
     raise ConfigurationException('Error: only %s instances can be used.' % str(SERVICE_INSTANCES.keys()))
Beispiel #4
0
 def getUrl(self, instance='prod', resource='workflow'):
     """
     Retrieve the url depending on the resource we are accessing and the instance.
     """
     if instance in SERVICE_INSTANCES.keys():
         return BASEURL + instance + '/' + resource
     elif instance == 'private':
         return BASEURL + 'dev' + '/' + resource
     raise ConfigurationException('Error: only %s instances can be used.' % str(SERVICE_INSTANCES.keys()))
Beispiel #5
0
    def getTaskDict(self):
        #getting information about the task
        inputlist = {'subresource':'search', 'workflow': self.config.JobType.copyCatTaskname}
        serverFactory = CRABClient.Emulator.getEmulator('rest')
        serverhost = SERVICE_INSTANCES.get(self.config.JobType.copyCatInstance)
        server = serverFactory(serverhost, self.proxyfilename, self.proxyfilename, version=__version__)
        uri = getUrl(self.config.JobType.copyCatInstance, resource='task')
        dictresult, dummyStatus, dummyReason = server.get(uri, data=inputlist)
        webdir = getProxiedWebDir(self.config.JobType.copyCatTaskname, serverhost, uri, self.proxyfilename, self.logger.debug)
        if not webdir:
            webdir = getColumn(dictresult, 'tm_user_webdir')

        return dictresult, webdir
Beispiel #6
0
    def setSuperOptions(self):
        try:
            self.setOptions()
        except NotImplementedError:
            pass

        self.parser.add_option(
            "--proxy",
            dest="proxy",
            default=False,
            help=
            "Use the given proxy. Skip Grid proxy creation and myproxy delegation."
        )

        if self.cmdconf['requiresTaskOption']:
            self.parser.add_option(
                "-d",
                "--dir",
                dest="task",
                default=None,
                help=
                "Path to the crab project directory for which the crab command should be executed."
            )
            self.parser.add_option(
                "-t",
                "--task",
                dest="oldtask",
                default=None,
                help="Deprecated option renamed to -d/--dir in CRAB v3.3.12.")

        self.parser.add_option("--voRole", dest="voRole", default=None)

        self.parser.add_option("--voGroup", dest="voGroup", default=None)
        if self.cmdconf['requiresREST']:

            self.parser.add_option(
                "--instance",
                dest="instance",
                type="string",
                help="Running instance of CRAB service. Valid values are %s." %
                str(SERVICE_INSTANCES.keys()))
Beispiel #7
0
    def addCommonOptions(self, cmdconf):
        """
            cmdconf:    the command configuration from the ClientMapping
        """
        self.add_option("--proxy",
                               dest = "proxy",
                               default = False,
                               help = "Use the given proxy. Skip Grid proxy creation and myproxy delegation.")

        if cmdconf['requiresDirOption']:
            self.add_option("-d", "--dir",
                                   dest = "projdir",
                                   default = None,
                                   help = "Path to the CRAB project directory for which the crab command should be executed.")

        if cmdconf['requiresProxyVOOptions']:
            self.add_option("--voRole",
                                   dest = "voRole",
                                   default = None)
            self.add_option("--voGroup",
                                   dest = "voGroup",
                                   default = None)

        if cmdconf['requiresREST']:
            self.add_option("--instance",
                                   dest = "instance",
                                   type = "string",
                                   help = "Running instance of CRAB service. Valid values are %s." % str(SERVICE_INSTANCES.keys()))
Beispiel #8
0
    def setSuperOptions(self):
        try:
            self.setOptions()
        except NotImplementedError:
            pass

        self.parser.add_option("--proxy",
                               dest = "proxy",
                               default = False,
                               help = "Use the given proxy. Skip Grid proxy creation and myproxy delegation.")

        if self.cmdconf['requiresTaskOption']:
            self.parser.add_option("-d", "--dir",
                                   dest = "task",
                                   default = None,
                                   help = "Path to the crab project directory for which the crab command should be executed.")
            self.parser.add_option("-t", "--task",
                                   dest = "oldtask",
                                   default = None,
                                   help = "Deprecated option renamed to -d/--dir in CRAB v3.3.12.")

        self.parser.add_option("--voRole",
                               dest = "voRole",
                               default = None)

        self.parser.add_option("--voGroup",
                               dest = "voGroup",
                               default = None)
        if self.cmdconf['requiresREST']:

            self.parser.add_option("--instance",
                                   dest = "instance",
                                   type = "string",
                                   help = "Running instance of CRAB service. Valid values are %s." %str(SERVICE_INSTANCES.keys()))