Esempio n. 1
0
    def method_ref(self, method):
        log_debug(3, self.server, method)

        # Init the repository
        server_id = rhnFlags.get("AUTH_SESSION_TOKEN")['X-RHN-Server-Id']
        username = rhnFlags.get("AUTH_SESSION_TOKEN")['X-RHN-Auth-User-Id']
        repository = rhnRepository.Repository(self.channel, server_id,
                                              username)
        repository.set_qos()

        f = repository.get_function(method)
        if f is None:
            raise UnknownXML("function '%s' invalid; path_info is %s" % (
                method, self.req.path_info))
        return f
Esempio n. 2
0
    def __callLocalRepository(self, channelName, funct, params):
        """ Contacts the local repository and retrieves files

            URI looks like:
              /$RHN/<channel>/<function>/<params>
        """

        log_debug(2, channelName, funct, params)

        # Find the channel version
        version = None
        for c in self.authChannels:
            ch, ver = c[:2]
            if ch == channelName:
                version = ver
                break

        # NOTE: X-RHN-Proxy-Auth described in broker/rhnProxyAuth.py
        if rhnFlags.get('outputTransportOptions').has_key('X-RHN-Proxy-Auth'):
            self.cachedClientInfo['X-RHN-Proxy-Auth'] = rhnFlags.get('outputTransportOptions')['X-RHN-Proxy-Auth']
        if rhnFlags.get('outputTransportOptions').has_key('Host'):
            self.cachedClientInfo['Host'] = rhnFlags.get('outputTransportOptions')['Host']

        # We already know he's subscribed to this channel
        # channel, so the version is non-null
        rep = rhnRepository.Repository(channelName, version,
                                       self.cachedClientInfo,
                                       rhnParent=self.rhnParent,
                                       rhnParentXMLRPC=self.rhnParentXMLRPC,
                                       httpProxy=self.httpProxy,
                                       httpProxyUsername=self.httpProxyUsername,
                                       httpProxyPassword=self.httpProxyPassword,
                                       caChain=self.caChain)

        f = rep.get_function(funct)
        if not f:
            raise rhnFault(1000,
                _("Spacewalk Proxy configuration error: invalid function %s") % funct)

        log_debug(3, "Calling %s(%s)" % (funct, params))
        if params is None:
            params = ()
        try:
            ret = f(*params)
        except rhnRepository.NotLocalError:
            # The package is not local
            return None
        return ret
Esempio n. 3
0
    def __callLocalRepository(self, req_type, identifier, funct, params):
        """ Contacts the local repository and retrieves files"""

        log_debug(2, req_type, identifier, funct, params)

        # NOTE: X-RHN-Proxy-Auth described in broker/rhnProxyAuth.py
        if rhnFlags.get('outputTransportOptions').has_key('X-RHN-Proxy-Auth'):
            self.cachedClientInfo['X-RHN-Proxy-Auth'] = rhnFlags.get(
                'outputTransportOptions')['X-RHN-Proxy-Auth']
        if rhnFlags.get('outputTransportOptions').has_key('Host'):
            self.cachedClientInfo['Host'] = rhnFlags.get(
                'outputTransportOptions')['Host']

        if req_type == 'tinyurl':
            try:
                rep = rhnRepository.TinyUrlRepository(
                    identifier,
                    self.cachedClientInfo,
                    rhnParent=self.rhnParent,
                    rhnParentXMLRPC=self.rhnParentXMLRPC,
                    httpProxy=self.httpProxy,
                    httpProxyUsername=self.httpProxyUsername,
                    httpProxyPassword=self.httpProxyPassword,
                    caChain=self.caChain,
                    systemId=self.proxyAuth.get_system_id())
            except rhnRepository.NotLocalError:
                return None
        elif req_type == 'ks-dist':
            try:
                rep = rhnRepository.KickstartRepository(
                    identifier,
                    self.cachedClientInfo,
                    rhnParent=self.rhnParent,
                    rhnParentXMLRPC=self.rhnParentXMLRPC,
                    httpProxy=self.httpProxy,
                    httpProxyUsername=self.httpProxyUsername,
                    httpProxyPassword=self.httpProxyPassword,
                    caChain=self.caChain,
                    orgId=params['orgId'],
                    child=params['child'],
                    session=params['session'],
                    systemId=self.proxyAuth.get_system_id())
            except rhnRepository.NotLocalError:
                return None
            params = [params['file']]
        else:
            # Find the channel version
            version = None
            for c in self.authChannels:
                ch, ver = c[:2]
                if ch == identifier:
                    version = ver
                    break

            # We already know he's subscribed to this channel
            # channel, so the version is non-null
            rep = rhnRepository.Repository(
                identifier,
                version,
                self.cachedClientInfo,
                rhnParent=self.rhnParent,
                rhnParentXMLRPC=self.rhnParentXMLRPC,
                httpProxy=self.httpProxy,
                httpProxyUsername=self.httpProxyUsername,
                httpProxyPassword=self.httpProxyPassword,
                caChain=self.caChain)

        f = rep.get_function(funct)
        if not f:
            raise rhnFault(
                1000,
                _("Spacewalk Proxy configuration error: invalid function %s") %
                funct)

        log_debug(3, "Calling %s(%s)" % (funct, params))
        if params is None:
            params = ()
        try:
            ret = f(*params)
        except rhnRepository.NotLocalError:
            # The package is not local
            return None

        return ret