Use the max_connection attribute from metalink parser
when building MirrorGroup arguments, so it's available
to the parallel download scheduller.
---
 yum/metalink.py |    8 ++++----
 yum/yumRepo.py  |   15 +++++++++++++--
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/yum/metalink.py b/yum/metalink.py
index aaa4f25..867ae86 100755
--- a/yum/metalink.py
+++ b/yum/metalink.py
@@ -180,6 +180,7 @@ class MetaLinkRepoMD:
         self.repomd = None
         self.old_repomds = []
         self.mirrors = []
+        self.host2con = {}
         if not os.path.exists(filename):
             raise MetaLinkRepoErrorParseFail, "File %s does not exist" 
%filename
         try:
@@ -225,8 +226,6 @@ class MetaLinkRepoMD:
         # Get the hostname from a url, stripping away any usernames/passwords
         # Borrowd from fastestmirror
         url2host = lambda url: url.split('/')[2].split('@')[-1]
-        hosts = set() # Don't want multiple urls for one host in plain mode
-                      # The list of URLs is sorted, so http is before ftp
 
         for mirror in self.mirrors:
             url = mirror.url
@@ -237,9 +236,10 @@ class MetaLinkRepoMD:
             elif (url.startswith("http:") or url.startswith("ftp:") or
                   url.startswith("https:")):
                 host = url2host(url)
-                if host in hosts:
+                # Don't want multiple urls for one host in plain mode
+                if host in self.host2con:
                     continue
-                hosts.add(host)
+                self.host2con[host] = mirror.max_connections
             else:
                 continue
 
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index 91b7dde..30fa939 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -490,8 +490,19 @@ class YumRepository(Repository, config.RepoConf):
                                     copy_local=self.copy_local,
                                     reget='simple',
                                     **ugopts)
-
-        self._grab = mgclass(self._grabfunc, self.urls,
+        urls = self.urls
+        if self.metalink:
+            def add_con(url):
+                host = urlparse.urlsplit(url).netloc
+                con = self.metalink_data.host2con.get(host)
+                if con:
+                    url = {
+                        'mirror': misc.to_utf8(url),
+                        'kwargs': { 'max_connections': con },
+                    }
+                return url
+            urls = map(add_con, urls)
+        self._grab = mgclass(self._grabfunc, urls,
                              failure_callback=self.mirror_failure_obj)
 
     def _default_grabopts(self, cache=True):
-- 
1.7.4.4

_______________________________________________
Yum-devel mailing list
Yum-devel@lists.baseurl.org
http://lists.baseurl.org/mailman/listinfo/yum-devel

Reply via email to