Esempio 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)
Esempio 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))
Esempio 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))
Esempio 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)