[yum-cvs] 5 commits - plugins/fastestmirror
Luke Macken
lmacken at linux.duke.edu
Mon Dec 3 16:43:07 UTC 2007
plugins/fastestmirror/ChangeLog | 5 +++++
plugins/fastestmirror/fastestmirror.conf | 1 +
plugins/fastestmirror/fastestmirror.py | 28 ++++++++++++++++++++++++----
3 files changed, 30 insertions(+), 4 deletions(-)
New commits:
commit 7a085f013f8250da6593178dc9fd13fb966604f6
Author: Luke Macken <lmacken at redhat.com>
Date: Mon Dec 3 11:41:34 2007 -0500
update fastestmirrors ChangeLog
diff --git a/plugins/fastestmirror/ChangeLog b/plugins/fastestmirror/ChangeLog
index dc9af60..d33e1fe 100644
--- a/plugins/fastestmirror/ChangeLog
+++ b/plugins/fastestmirror/ChangeLog
@@ -1,3 +1,8 @@
+* Dec 3 2007 Luke Macken <lmacken at redhat.com> - 0.3.0
+- Throttle threads based on 'maxthreads' configuration option (rh#227772)
+- Add an exclude configuration option (rh#407471)
+- Actually display the fastest mirrors
+
* Aug 8 2007 Luke Macken <lmacken at redhat.com> - 0.2.8
- Add patch from Christopher Aillon to fail quietly when fastestmirror does
not have write access to the timed hostfile.
commit 378eabfecc3e4263251f77d89bc0dba18d057ca4
Author: Luke Macken <lmacken at redhat.com>
Date: Mon Dec 3 11:40:56 2007 -0500
Add an 'exclude' configuration option to fastestmirror (Bug #407471)
diff --git a/plugins/fastestmirror/fastestmirror.py b/plugins/fastestmirror/fastestmirror.py
index c64e406..9e782b0 100644
--- a/plugins/fastestmirror/fastestmirror.py
+++ b/plugins/fastestmirror/fastestmirror.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Version: 0.2.8
+# Version: 0.3.0
#
# A plugin for the Yellowdog Updater Modified which sorts each repo's
# mirrorlist by connection speed prior to download.
@@ -17,6 +17,7 @@
# hostfilepath=/var/cache/yum/timedhosts
# maxhostfileage=10
# maxthreads=15
+# #exclude=.gov
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -52,16 +53,18 @@ hostfilepath = ''
maxhostfileage = 10
loadcache = False
maxthreads = 15
+exclude = None
def init_hook(conduit):
global verbose, socket_timeout, hostfilepath, maxhostfileage, loadcache
- global maxthreads
+ global maxthreads, exclude
verbose = conduit.confBool('main', 'verbose', default=False)
socket_timeout = conduit.confInt('main', 'socket_timeout', default=3)
hostfilepath = conduit.confString('main', 'hostfilepath',
default='/var/cache/yum/timedhosts')
maxhostfileage = conduit.confInt('main', 'maxhostfileage', default=10)
maxthreads = conduit.confInt('main', 'maxthreads', default=10)
+ exclude = conduit.confString('main', 'exclude', default=None)
if os.path.exists(hostfilepath) and get_hostfile_age() < maxhostfileage:
loadcache = True
@@ -70,8 +73,10 @@ def clean_hook(conduit):
conduit.info(2, "Cleaning up list of fastest mirrors")
os.unlink(hostfilepath)
+host = lambda mirror: mirror.split('/')[2]
+
def postreposetup_hook(conduit):
- global loadcache
+ global loadcache, exclude
if loadcache:
conduit.info(2, "Loading mirror speeds from cached hostfile")
read_timedhosts()
@@ -82,8 +87,13 @@ def postreposetup_hook(conduit):
for repo in repos.listEnabled():
if not repomirrors.has_key(str(repo)):
repomirrors[str(repo)] = FastestMirror(repo.urls).get_mirrorlist()
+ if exclude:
+ for mirror in repomirrors[str(repo)]:
+ if exclude in host(mirror):
+ conduit.info(2, "Excluding mirrors: %s" % host(mirror))
+ repomirrors[str(repo)].remove(mirror)
repo.urls = repomirrors[str(repo)]
- conduit.info(2, " * %s: %s" % (str(repo), repo.urls[0].split('/')[2]))
+ conduit.info(2, " * %s: %s" % (str(repo), host(repo.urls[0])))
repo.failovermethod = 'priority'
repo.check()
repo.setupGrab()
commit a112f75c93c33b6e8f7b59a1e4694f0aecbf9f5e
Author: Luke Macken <lmacken at redhat.com>
Date: Mon Dec 3 11:38:55 2007 -0500
Add a maxthreads configuration option to fastestmirror (Bug #227772)
diff --git a/plugins/fastestmirror/fastestmirror.conf b/plugins/fastestmirror/fastestmirror.conf
index c7d43d6..76af534 100644
--- a/plugins/fastestmirror/fastestmirror.conf
+++ b/plugins/fastestmirror/fastestmirror.conf
@@ -4,3 +4,4 @@ verbose=0
socket_timeout=3
hostfilepath=/var/cache/yum/timedhosts.txt
maxhostfileage=10
+maxthreads=15
diff --git a/plugins/fastestmirror/fastestmirror.py b/plugins/fastestmirror/fastestmirror.py
index 37505cb..c64e406 100644
--- a/plugins/fastestmirror/fastestmirror.py
+++ b/plugins/fastestmirror/fastestmirror.py
@@ -16,6 +16,7 @@
# socket_timeout=3
# hostfilepath=/var/cache/yum/timedhosts
# maxhostfileage=10
+# maxthreads=15
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -50,14 +51,17 @@ timedhosts = {}
hostfilepath = ''
maxhostfileage = 10
loadcache = False
+maxthreads = 15
def init_hook(conduit):
global verbose, socket_timeout, hostfilepath, maxhostfileage, loadcache
+ global maxthreads
verbose = conduit.confBool('main', 'verbose', default=False)
socket_timeout = conduit.confInt('main', 'socket_timeout', default=3)
hostfilepath = conduit.confString('main', 'hostfilepath',
default='/var/cache/yum/timedhosts')
maxhostfileage = conduit.confInt('main', 'maxhostfileage', default=10)
+ maxthreads = conduit.confInt('main', 'maxthreads', default=10)
if os.path.exists(hostfilepath) and get_hostfile_age() < maxhostfileage:
loadcache = True
@@ -128,14 +132,19 @@ class FastestMirror:
return [x[1] for x in mirrors]
def _poll_mirrors(self):
+ global maxthreads
for mirror in self.mirrorlist:
+ if len(self.threads) > maxthreads:
+ if self.threads[0].isAlive():
+ self.threads[0].join()
+ del self.threads[0]
pollThread = PollThread(self, mirror)
pollThread.start()
self.threads.append(pollThread)
while len(self.threads) > 0:
if self.threads[0].isAlive():
self.threads[0].join()
- del(self.threads[0])
+ del self.threads[0]
def _add_result(self, mirror, host, time):
global timedhosts
commit c9febfc06c0bced6732215a288cec69cb8ded745
Author: Luke Macken <lmacken at redhat.com>
Date: Mon Dec 3 10:39:09 2007 -0500
Actually display the fastest mirrors
diff --git a/plugins/fastestmirror/fastestmirror.py b/plugins/fastestmirror/fastestmirror.py
index 75e669e..37505cb 100644
--- a/plugins/fastestmirror/fastestmirror.py
+++ b/plugins/fastestmirror/fastestmirror.py
@@ -79,6 +79,7 @@ def postreposetup_hook(conduit):
if not repomirrors.has_key(str(repo)):
repomirrors[str(repo)] = FastestMirror(repo.urls).get_mirrorlist()
repo.urls = repomirrors[str(repo)]
+ conduit.info(2, " * %s: %s" % (str(repo), repo.urls[0].split('/')[2]))
repo.failovermethod = 'priority'
repo.check()
repo.setupGrab()
commit caccec8c73ecb2e448a683b100b98f3b400ad1b9
Author: Luke Macken <lmacken at redhat.com>
Date: Mon Dec 3 10:27:55 2007 -0500
Remove unused PluginYumExit import
diff --git a/plugins/fastestmirror/fastestmirror.py b/plugins/fastestmirror/fastestmirror.py
index cfa7467..75e669e 100644
--- a/plugins/fastestmirror/fastestmirror.py
+++ b/plugins/fastestmirror/fastestmirror.py
@@ -39,7 +39,7 @@ import urlparse
import datetime
import threading
-from yum.plugins import TYPE_CORE, PluginYumExit
+from yum.plugins import TYPE_CORE
requires_api_version = '2.5'
plugin_type = (TYPE_CORE,)
More information about the Yum-cvs-commits
mailing list