[PATCH rhel6 2/3] Add proxy handling to .treeinfo (#634655)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a string with the correct method and auth info to the parent object
for use with things like urlgrabber that need a full url

Tested with proxy, proxy+auth, repo+proxy kickstart and no proxy

Resolves: rhbz#634655
---
 yuminstall.py |   32 ++++++++++++++++++++++++--------
 1 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/yuminstall.py b/yuminstall.py
index 9c8c210..c936553 100644
--- a/yuminstall.py
+++ b/yuminstall.py
@@ -260,6 +260,7 @@ class AnacondaYumRepo(YumRepository):
         YumRepository.__init__(self, *args, **kwargs)
         self.enablegroups = True
         self._anacondaBaseURLs = []
+        self.proxy_url = None
 
     def needsNetwork(self):
         def _isURL(s):
@@ -677,7 +678,7 @@ class AnacondaYum(YumSorter):
         c = ConfigParser()
 
         # If there's no .treeinfo for this repo, don't bother looking for addons.
-        treeinfo = self._getTreeinfo(baseurl)
+        treeinfo = self._getTreeinfo(baseurl, repo.proxy_url)
         if not treeinfo:
             return retval
 
@@ -702,7 +703,11 @@ class AnacondaYum(YumSorter):
 
         return retval
 
-    def _getTreeinfo(self, baseurl):
+    def _getTreeinfo(self, baseurl, proxy_url=None):
+        """
+        Try to get .treeinfo file from baseurl, optionally using proxy_url
+        Saves the file into /tmp/.treeinfo
+        """
         if baseurl.startswith("http") or baseurl.startswith("ftp"):
             if not network.hasActiveNetDev():
                 if not self.anaconda.intf.enableNetwork():
@@ -711,25 +716,36 @@ class AnacondaYum(YumSorter):
                 urlgrabber.grabber.reset_curl_obj()
 
         ug = URLGrabber()
+        if proxy_url and proxy_url.startswith("http"):
+            proxies = { 'http'  : proxy_url,
+                        'https' : proxy_url }
+        elif proxy_url and proxy_url.startswith("ftp"):
+            proxies = { 'ftp'   : proxy_url }
+        else:
+            proxies = {}
 
         try:
-            ug.urlgrab("%s/.treeinfo" % baseurl, "/tmp/.treeinfo", copy_local=1)
+            ug.urlgrab("%s/.treeinfo" % baseurl, "/tmp/.treeinfo",
+                       copy_local=1, proxies=proxies)
         except Exception as e:
             try:
-                ug.urlgrab("%s/treeinfo" % baseurl, "/tmp/.treeinfo", copy_local=1)
+                ug.urlgrab("%s/treeinfo" % baseurl, "/tmp/.treeinfo",
+                           copy_local=1, proxies=proxies)
             except Exception as e:
                 log.error("Error downloading treeinfo file: %s" % e)
                 return None
 
         return "/tmp/.treeinfo"
 
-    # We need to make sure $releasever gets set up before .repo files are
-    # read.  Since there's no redhat-release package in /mnt/sysimage (and
-    # won't be for quite a while), we need to do our own substutition.
     def _getReleasever(self):
+        """
+        We need to make sure $releasever gets set up before .repo files are
+        read.  Since there's no redhat-release package in /mnt/sysimage (and
+        won't be for quite a while), we need to do our own substutition.
+        """
         c = ConfigParser()
 
-        treeinfo = self._getTreeinfo(self._baseRepoURL)
+        treeinfo = self._getTreeinfo(self._baseRepoURL, self.proxy_url)
         if not treeinfo:
             return productVersion
 
-- 
1.7.3.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux