Exemple #1
0
 def _authenticate(self, url):
     if url.startswith("uln:///"):
         self.uln_url = "https://" + DEFAULT_UP2DATE_URL
         label = url[7:]
     elif url.startswith("uln://"):
         parts = url[6:].split("/")
         self.uln_url = "https://" + parts[0]
         label = parts[1]
     else:
         raise RhnSyncException("url format error, url must start with uln://")
     self.uln_user = self.yumbase.conf.username
     self.uln_pass = self.yumbase.conf.password
     self.url = self.uln_url + "/XMLRPC/GET-REQ/" + label
     print("The download URL is: " + self.url)
     if self.proxy_addr:
         print("Trying proxy " + self.proxy_addr)
     slist = ServerList([self.uln_url+"/rpc/api",])
     s = RetryServer(slist.server(),
                     refreshCallback=None,
                     proxy=self.proxy_addr,
                     username=self.proxy_user,
                     password=self.proxy_pass,
                     timeout=5)
     s.addServerList(slist)
     self.key = s.auth.login(self.uln_user, self.uln_pass)
Exemple #2
0
 def _authenticate(self, url):
     if url.startswith("uln:///"):
         self.uln_url = "https://" + DEFAULT_UP2DATE_URL
         label = url[7:]
     elif url.startswith("uln://"):
         parts = url[6:].split("/")
         self.uln_url = "https://" + parts[0]
         label = parts[1]
     else:
         raise RhnSyncException(
             "url format error, url must start with uln://")
     self.uln_user = self.yumbase.conf.username
     self.uln_pass = self.yumbase.conf.password
     self.url = self.uln_url + "/XMLRPC/GET-REQ/" + label
     print("The download URL is: " + self.url)
     if self.proxy_addr:
         print("Trying proxy " + self.proxy_addr)
     slist = ServerList([
         self.uln_url + "/rpc/api",
     ])
     s = RetryServer(slist.server(),
                     refreshCallback=None,
                     proxy=self.proxy_addr,
                     username=self.proxy_user,
                     password=self.proxy_pass,
                     timeout=5)
     s.addServerList(slist)
     self.key = s.auth.login(self.uln_user, self.uln_pass)
Exemple #3
0
    def authenticate(self, url):
        """
        Get ULN token.

        :raises RhnSyncException: if configuration does not contain required sections.
        :returns: ULN token
        """
        err_msg = ''
        if self._uln_token is None:
            try:
                usr, pwd = self.get_credentials()
                self._uln_url, label = self.get_hostname(url)
                px_url, px_usr, px_pwd = get_proxy(self._uln_url)
                server_list = ServerList([self._uln_url + "/rpc/api"])
                retry_server = RetryServer(server_list.server(),
                                           refreshCallback=None,
                                           proxy=px_url,
                                           username=px_usr,
                                           password=px_pwd,
                                           timeout=5)
                retry_server.addServerList(server_list)
                self._uln_token = retry_server.auth.login(usr, pwd)
            except Exception as exc:
                err_msg = exc

        if not self.token or err_msg:
            raise ULNTokenException(
                "Authentication failure: token was not obtained. {}".format(
                    err_msg))

        return self.token