Skip to content

Commit

Permalink
Let mirrors specify multiple countries
Browse files Browse the repository at this point in the history
fedora-infra#267
requests the ability for a mirror (really, a globally load balanced
set of mirrors behind a single DNS name) to be able to specify the
countries of their actual mirrors.

This patch lets Host.country be a comma-separated list of countries.
  • Loading branch information
mdomsch committed May 10, 2019
1 parent 4e786a0 commit 6e00f98
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions mirrormanager2/lib/mirrorlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,24 +171,27 @@ def setup_category_topdir_cache(session):
category_topdir_cache[category_id]:]
del repos

countries = []
if country is not None:
country = country.upper()
countries = country.split(u',')

if not siteprivate and not hostprivate:
add_host_to_set(cache[directoryname]['global'], hostid)

if country is not None:
for country in countries:
if country not in cache[directoryname]['byCountry']:
cache[directoryname]['byCountry'][country] = set()
add_host_to_set(
cache[directoryname]['byCountry'][country], hostid)

if country is not None and i2 and \
for country in countries:
if i2 and \
((not siteprivate and not hostprivate) or i2_clients):
if country not in cache[directoryname]['byCountryInternet2']:
cache[directoryname]['byCountryInternet2'][country] = set()
add_host_to_set(
cache[directoryname]['byCountryInternet2'][country], hostid)
if country not in cache[directoryname]['byCountryInternet2']:
cache[directoryname]['byCountryInternet2'][country] = set()
add_host_to_set(
cache[directoryname]['byCountryInternet2'][country], hostid)

append_value_to_cache(cache[directoryname]['byHostId'], hostid, hcurl)

Expand Down Expand Up @@ -254,7 +257,11 @@ def populate_host_bandwidth_cache(cache, host):


def populate_host_country_cache(cache, host):
cache[host.id] = host.country
if u',' in host.country:
country = host.country.split(u',')[0]
else:
country = host.country
cache[host.id] = country.strip()
return cache


Expand Down

0 comments on commit 6e00f98

Please sign in to comment.