Exemplo n.º 1
0
    def _chooseUploadMode(self):
        # check if we have enough informations to reach the client
        client = self.get_client("transfert")

        if not client["host"]:  # We couldn't get an IP address for the target host
            err = defer.fail(Exception("Not enough information about client to perform upload"))
            err.addErrback(self.parsePushError, error_code=PULSE2_TARGET_NOTENOUGHINFO_ERROR)
            err.addErrback(self.got_error_in_error)
            return err

        # first attempt to guess is mirror is local (push) or remove (pull) or through a proxy
        if self.coh.isProxyClient():
            # proxy client
            d = self._runProxyClientPhase(client)
        elif re_file_prot.match(self.target.mirrors):
            # local mirror starts by "file://" : prepare a remote_push
            d = self._runPushPhase(client)
        else:  # remote push/pull

            try:
                # mirror is formated like this:
                # https://localhost:9990/mirror1||https://localhost:9990/mirror1
                mirrors = self.target.mirrors.split("||")
            except:
                self.logger.warn(
                    "Circuit #%s: target.mirror do not seems to be as expected, got '%s', skipping command"
                    % (self.coh.getId(), self.target.mirrors)
                )
                err = defer.fail(Exception("Mirror uri %s is not well-formed" % self.target.mirrors))
                err.addErrback(self.parsePushError)
                err.addErrback(self.got_error_in_error)
                return err

            # Check mirrors
            if len(mirrors) != 2:
                self.logger.warn("Circuit #%s: we need two mirrors ! '%s'" % (self.coh.getId(), self.target.mirrors))
                err = defer.fail(Exception("Mirror uri %s do not contains two mirrors" % self.target.mirrors))
                err.addErrback(self.parsePushError)
                err.addErrback(self.got_error_in_error)
                return err
            mirror = mirrors[0]
            fbmirror = mirrors[1]

            try:
                ma = Mirror(mirror)
                ma.errorback = self._eb_mirror_check
                d = ma.isAvailable(self.cmd.package_id)
                d.addCallback(self._cbRunPushPullPhaseTestMainMirror, mirror, fbmirror, client)
            except Exception, e:
                self.logger.error(
                    "Circuit #%s: exception while gathering information about %s on primary mirror %s : %s"
                    % (self.coh.getId(), self.cmd.package_id, mirror, e)
                )
                return self._cbRunPushPullPhaseTestMainMirror(False, mirror, fbmirror, client)
Exemplo n.º 2
0
 def _cbRunPushPullPhaseTestFallbackMirror(self, result, mirror, fbmirror, client):
     if fbmirror != mirror:
         # Test the fallback mirror only if the URL is the different than the
         # primary mirror
         try:
             ma = Mirror(mirror, fbmirror)
             ma.errorback = self._eb_mirror_check
             d = ma.isAvailable(self.cmd.package_id)
             d.addCallback(self._cbRunPushPullPhase, mirror, fbmirror, client, True)
             return d
         except Exception, e:
             self.logger.error("Circuit #%s: exception while gathering information about %s on fallback mirror %s : %s" % (self.coh.getId(), self.cmd.package_id, fbmirror, e))
Exemplo n.º 3
0
 def _cbRunPushPullPhaseTestFallbackMirror(self, result, mirror, fbmirror, client):
     if fbmirror != mirror:
         # Test the fallback mirror only if the URL is the different than the
         # primary mirror
         try:
             ma = Mirror(mirror, fbmirror)
             ma.errorback = self._eb_mirror_check
             d = ma.isAvailable(self.cmd.package_id)
             d.addCallback(self._cbRunPushPullPhase, mirror, fbmirror, client, True)
             return d
         except Exception, e:
             self.logger.error("Circuit #%s: exception while gathering information about %s on fallback mirror %s : %s" % (self.coh.getId(), self.cmd.package_id, fbmirror, e))
Exemplo n.º 4
0
    def _chooseUploadMode(self):
        # check if we have enough informations to reach the client
        client = self.get_client("transfert")

        if not client['host']: # We couldn't get an IP address for the target host
            err = defer.fail(Exception("Not enough information about client to perform upload"))
            err.addErrback(self.parsePushError,
                           error_code = PULSE2_TARGET_NOTENOUGHINFO_ERROR)
            err.addErrback(self.got_error_in_error)
            return err

        # first attempt to guess is mirror is local (push) or remove (pull) or through a proxy
        if self.coh.isProxyClient():
            # proxy client
            d = self._runProxyClientPhase(client)
        elif re_file_prot.match(self.target.mirrors):
            # local mirror starts by "file://" : prepare a remote_push
            d = self._runPushPhase(client)
        else: # remote push/pull

            try:
                # mirror is formated like this:
                # https://localhost:9990/mirror1||https://localhost:9990/mirror1
                mirrors = self.target.mirrors.split('||')
            except:
                self.logger.warn("Circuit #%s: target.mirror do not seems to be as expected, got '%s', skipping command" % (self.coh.getId(), self.target.mirrors))
                err = defer.fail(Exception("Mirror uri %s is not well-formed" % self.target.mirrors))
                err.addErrback(self.parsePushError)
                err.addErrback(self.got_error_in_error)
                return err

            # Check mirrors
            if len(mirrors) != 2:
                self.logger.warn("Circuit #%s: we need two mirrors ! '%s'" % (self.coh.getId(), self.target.mirrors))
                err = defer.fail(Exception("Mirror uri %s do not contains two mirrors" % self.target.mirrors))
                err.addErrback(self.parsePushError)
                err.addErrback(self.got_error_in_error)
                return err
            mirror = mirrors[0]
            fbmirror = mirrors[1]

            try:
                ma = Mirror(mirror)
                ma.errorback = self._eb_mirror_check
                d = ma.isAvailable(self.cmd.package_id)
                d.addCallback(self._cbRunPushPullPhaseTestMainMirror, mirror, fbmirror, client)
            except Exception, e:
                self.logger.error("Circuit #%s: exception while gathering information about %s on primary mirror %s : %s" % (self.coh.getId(), self.cmd.package_id, mirror, e))
                return self._cbRunPushPullPhaseTestMainMirror(False, mirror, fbmirror, client)
Exemplo n.º 5
0
    def _runPushPullPhase(self, mirror, fbmirror, client, useFallback = False):
        if useFallback:
            self.update_history_in_progress(PULSE2_PSERVER_ISAVAILABLE_FALLBACK, 
                                            '%s\n%s\n%s\n%s' % (self.cmd.package_id, 
                                                                mirror, 
                                                                self.cmd.package_id, 
                                                                fbmirror))
            mirror = fbmirror
        else:
            self.update_history_in_progress(PULSE2_PSERVER_ISAVAILABLE_MIRROR, 
                                            '%s\n%s' % (self.cmd.package_id, mirror))
        self.logger.debug("Circuit #%s: Package '%s' is available on %s" % (self.coh.getId(), self.cmd.package_id, mirror))

        ma = Mirror(mirror)
        ma.errorback = self._eb_mirror_check
        fids = []
        for line in self.cmd.files.split("\n"):
            fids.append(line.split('##')[0])
        d = ma.getFilesURI(fids)
        d.addCallback(self._cbRunPushPullPhasePushPull, mirror, fbmirror, client, useFallback)

        return d
Exemplo n.º 6
0
    def _runPushPullPhase(self, mirror, fbmirror, client, useFallback = False):
        if useFallback:
            self.update_history_in_progress(PULSE2_PSERVER_ISAVAILABLE_FALLBACK,
                                            '%s\n%s\n%s\n%s' % (self.cmd.package_id,
                                                                mirror,
                                                                self.cmd.package_id,
                                                                fbmirror))
            mirror = fbmirror
        else:
            self.update_history_in_progress(PULSE2_PSERVER_ISAVAILABLE_MIRROR,
                                            '%s\n%s' % (self.cmd.package_id, mirror))
        self.logger.debug("Circuit #%s: Package '%s' is available on %s" % (self.coh.getId(), self.cmd.package_id, mirror))

        ma = Mirror(mirror)
        ma.errorback = self._eb_mirror_check
        fids = []
        for line in self.cmd.files.split("\n"):
            fids.append(line.split('##')[0])
        d = ma.getFilesURI(fids)
        d.addCallback(self._cbRunPushPullPhasePushPull, mirror, fbmirror, client, useFallback)

        return d