Re: 2 mirrorlist changes for this week

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

 



On Mon, Nov 05, 2007 at 08:15:07AM -0800, Toshio Kuratomi wrote:
> Matt Domsch wrote:
> 
> >2) If a user isn't resolved by GeoIP, they will be given the global
> >   list, but without excluding mirrors who have an Exclusive Country
> >   set (e.g. Vasile's server really only wants traffic from .md users,
> >   but he sees global users).  This requires a change to
> >   mirrorlist_server.py trim_by_client_country() which I haven't made
> >   yet, but will look into doing so.  We should make this change to
> >   provide better accurate clients to our mirrors to keep their
> >   expenses down.  I'll post the patch here for review before implementing.
> 
> I'm not sure how invasive this will be but it does sound like something 
> we want to keep our mirrors happy.  Maybe seeing the patch first will
> be better for deciding if it's too big a change during the freeze.

Here's the resulting function.  I think this is very clear code now,
and it works for me tested against live data on pt1.

def trim_by_client_country(hostresults, clientCountry):
    results = []
    for hostid, hcurl in hostresults:
        if hostid not in host_country_allowed_cache or \
                clientCountry in host_country_allowed_cache[hostid]:
            results.append((hostid, hcurl))
    return results

Patch follows.

-- 
Matt Domsch
Linux Technology Strategist, Dell Office of the CTO
linux.dell.com & www.dell.com/linux

diff --git a/mirrors/server-scripts/mirrorlist_server.py b/mirrors/server-scripts/mirrorlist_server.py
index cf703ff..c7e17e0 100755
--- a/mirrors/server-scripts/mirrorlist_server.py
+++ b/mirrors/server-scripts/mirrorlist_server.py
@@ -82,18 +82,11 @@ def client_in_host_allowed(clientCountry, hostID):
 
 
 def trim_by_client_country(hostresults, clientCountry):
-    if clientCountry is None:
-        return hostresults
-
     results = []
-
     for hostid, hcurl in hostresults:
-        if not host_country_allowed_cache.has_key(hostid):
+        if hostid not in host_country_allowed_cache or \
+                clientCountry in host_country_allowed_cache[hostid]:
             results.append((hostid, hcurl))
-        else:
-            if clientCountry in host_country_allowed_cache[hostid]:
-                results.append((hostid, hcurl))
-
     return results
 
 

_______________________________________________
Fedora-infrastructure-list mailing list
Fedora-infrastructure-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/fedora-infrastructure-list

[Index of Archives]     [Fedora Development]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]

  Powered by Linux