[mirrormanager] master: /mirroradmins: add text & JSON listing all admin usernames (ecdc478)
by Matt Domsch
Repository : http://git.fedorahosted.org/cgit/
On branch : master
>---------------------------------------------------------------
commit ecdc478c90354b0db899dd245ef0a7b1ac5c215b
Author: Matt Domsch <matt(a)domsch.com>
Date: Thu Aug 15 13:55:14 2013 -0500
/mirroradmins: add text & JSON listing all admin usernames
For Fedora Badges, enhance the /mirroradmins REST call to return all
admin usernames. If &public_only=0, return all mirroradmins. If
&host=, no change (so as to not break zodbot).
>---------------------------------------------------------------
server/mirrormanager/controllers.py | 11 +++++++----
server/mirrormanager/model.py | 12 ++++++++++++
2 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/server/mirrormanager/controllers.py b/server/mirrormanager/controllers.py
index f7e1e8c..c05a0f2 100644
--- a/server/mirrormanager/controllers.py
+++ b/server/mirrormanager/controllers.py
@@ -875,10 +875,13 @@ class Root(controllers.RootController):
@expose(template="kid:mirrormanager.templates.rsync_acl", format="plain", content_type="text/plain", allow_json=True)
def mirroradmins(self, **kwargs):
- if 'host' not in kwargs:
- return dict(values=[])
- host = kwargs['host']
- return dict(values=host_siteadmins(host))
+ if 'host' in kwargs:
+ host = kwargs['host']
+ return dict(values=host_siteadmins(host))
+ else:
+ public_only = bool(int(kwargs.get('public_only', 1)))
+ values = mirror_admins(public_only=public_only)
+ return dict(values=values)
@expose(template="kid:mirrormanager.templates.rsyncFilter", format="plain", content_type="text/plain")
def rsyncFilter(self, **kwargs):
diff --git a/server/mirrormanager/model.py b/server/mirrormanager/model.py
index 69d8cb6..ae14378 100644
--- a/server/mirrormanager/model.py
+++ b/server/mirrormanager/model.py
@@ -881,6 +881,18 @@ class DirectoryExclusiveHost(SQLObject):
host = ForeignKey('Host')
idx = DatabaseIndex('directory', 'host', unique=True)
+def mirror_admins(public_only=True):
+ sql = 'SELECT DISTINCT site_admin.username '
+ sql += 'FROM site, host, site_admin '
+ sql += 'WHERE host.site_id = site.id '
+ sql += 'AND site_admin.site_id = site.id '
+ if public:
+ sql += 'AND site.public AND host.public '
+ sql += 'ORDER BY site_admin.username '
+ qresult = Directory._connection.queryAll(sql)
+ result = [x[0] for x in qresult]
+ return result
+
def _host_siteadmins(url):
sql = 'SELECT DISTINCT site_admin.username FROM '
sql += 'host_category_url, host_category, host, site, site_admin WHERE '
10 years, 8 months
[mirrormanager] master: welcome.kid: use list() around the site.hosts list (eca3a58)
by Matt Domsch
Repository : http://git.fedorahosted.org/cgit/
On branch : master
>---------------------------------------------------------------
commit eca3a58edc31a7cfd5481f8ede8aae47797163d1
Author: Matt Domsch <matt(a)domsch.com>
Date: Thu Aug 15 13:38:38 2013 -0500
welcome.kid: use list() around the site.hosts list
to speed it up a little bit.
>---------------------------------------------------------------
server/mirrormanager/templates/welcome.kid | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/server/mirrormanager/templates/welcome.kid b/server/mirrormanager/templates/welcome.kid
index a9c0473..f7d5c66 100644
--- a/server/mirrormanager/templates/welcome.kid
+++ b/server/mirrormanager/templates/welcome.kid
@@ -23,7 +23,7 @@ if admin_group in tg.identity.groups:
<a href="${tg.url('/site/'+str(site.id))}"><span py:replace="site.name">Site Name</span></a>
<ul>
- <li py:for="h in site.hosts">
+ <li py:for="h in list(site.hosts)">
<a href="${tg.url('/host/'+str(h.id))}"><span
py:replace="h.name">Host Name</span></a>
</li>
10 years, 8 months
[mirrormanager] master: welcome page: display sites that have no hosts (58afd2a)
by Matt Domsch
Repository : http://git.fedorahosted.org/cgit/
On branch : master
>---------------------------------------------------------------
commit 58afd2a870f6e43e2a4fbee6dc5cb52c1c689075
Author: Matt Domsch <matt(a)domsch.com>
Date: Thu Aug 15 13:36:57 2013 -0500
welcome page: display sites that have no hosts
The previous (faster) query was only returning sites that had defined
child hosts. That's not right. So revert to the slower method, using
list() to speed up selectresults.
>---------------------------------------------------------------
server/mirrormanager/controllers.py | 2 +-
server/mirrormanager/model.py | 49 +---------------------------------
2 files changed, 3 insertions(+), 48 deletions(-)
diff --git a/server/mirrormanager/controllers.py b/server/mirrormanager/controllers.py
index a1d2696..f7e1e8c 100644
--- a/server/mirrormanager/controllers.py
+++ b/server/mirrormanager/controllers.py
@@ -847,7 +847,7 @@ class Root(controllers.RootController):
@identity.require(identity.not_anonymous())
def index(self):
if admin_group in identity.current.groups:
- sites = all_sites_and_hosts()
+ sites = Site.select().orderBy('name')
else:
sites = user_sites(identity)
return {"sites":sites}
diff --git a/server/mirrormanager/model.py b/server/mirrormanager/model.py
index 2fcda5e..69d8cb6 100644
--- a/server/mirrormanager/model.py
+++ b/server/mirrormanager/model.py
@@ -121,56 +121,11 @@ class SiteAdmin(SQLObject):
def my_site(self):
return self.site
-
-class MiniSite(object):
- def __init__(self, id, name):
- self.id = id
- self.name = name
- self.hosts = []
-
-class MiniHost(object):
- def __init__(self, id, name):
- self.id = id
- self.name = name
-
-def _min_sites_and_hosts(results):
- sites = []
- site = None
- current_site = None
- for (site_id, site_name, host_id, host_name) in results:
- if current_site != site_id:
- site = MiniSite(site_id, site_name)
- sites.append(site)
- current_site = site_id
- host = MiniHost(host_id, host_name)
- site.hosts.append(host)
- return sites
-
def user_sites(identity):
result = []
- query_result = Site.select(join=INNERJOINOn(Site, SiteAdmin, AND(SiteAdmin.q.siteID == Site.q.id,
+ sites = Site.select(join=INNERJOINOn(Site, SiteAdmin, AND(SiteAdmin.q.siteID == Site.q.id,
SiteAdmin.q.username == identity.current.user_name)))
- for site in query_result:
- for h in site.hosts:
- result.append((site.id, site.name, h.id, h.name))
-
- sites = _min_sites_and_hosts(result)
- return sites
-
-def all_sites_and_hosts():
- def _all_sites_and_hosts():
- sql = 'SELECT site.id AS site_id, site.name AS site_name, host.id AS host_id, host.name AS host_name '
- sql += 'FROM site, host '
- sql += 'WHERE '
- sql += 'host.site_id = site.id '
- sql += 'GROUP BY site.id, site.name, host.id, host.name '
- sql += 'ORDER BY site.name, host.name '
- result = Site._connection.queryAll(sql)
- return result
-
- sites = _min_sites_and_hosts(_all_sites_and_hosts())
- return sites
-
+ return list(sites)
class HostCategory(SQLObject):
class sqlmeta:
10 years, 8 months
[mirrormanager] master: umdl: ignore invalid duplicate Repository pointers (29bd052)
by Matt Domsch
Repository : http://git.fedorahosted.org/cgit/
On branch : master
>---------------------------------------------------------------
commit 29bd052962a63d1ffe8c9522e1dfa31b3238f7ed
Author: Matt Domsch <matt(a)domsch.com>
Date: Fri Aug 9 15:56:35 2013 -0500
umdl: ignore invalid duplicate Repository pointers
If a directory has >1 Repository pointer, there can be only one valid
one (per database uniqueness constraints). Therefore the others must
have version=None or arch=None. Ignore those.
>---------------------------------------------------------------
server/mirrormanager/mirrorlist.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/server/mirrormanager/mirrorlist.py b/server/mirrormanager/mirrorlist.py
index b869ce0..ca45a1e 100644
--- a/server/mirrormanager/mirrorlist.py
+++ b/server/mirrormanager/mirrorlist.py
@@ -98,7 +98,7 @@ def populate_directory_cache():
def setup_directory_repo_cache():
cache = {}
for r in list(Repository.select()):
- if r.directory:
+ if r.directory and r.version and r.arch:
cache[r.directory.id] = r
return cache
def setup_version_ordered_mirrorlist_cache():
10 years, 8 months
[mirrormanager] master: crawler: fix crawler --stopid now that the host list is sorted (c790e33)
by Matt Domsch
Repository : http://git.fedorahosted.org/cgit/
On branch : master
>---------------------------------------------------------------
commit c790e33968e6d489a6b9bf16525448067441fa33
Author: Adrian Reber <adrian(a)lisas.de>
Date: Wed Aug 7 07:08:03 2013 -0500
crawler: fix crawler --stopid now that the host list is sorted
We can't break out of the host loop early if we've passed stopid,
because the list isn't sorted by ID anymore, but by
last_crawl_duration.
Fix from Adrian.
>---------------------------------------------------------------
server/crawler | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/server/crawler b/server/crawler
index efd32a0..3b2aacf 100755
--- a/server/crawler
+++ b/server/crawler
@@ -130,7 +130,7 @@ def doit():
i += 1
try:
if h.id < options.startid: continue
- if h.id >= options.stopid: break
+ if h.id >= options.stopid: continue
master.wait_for_available_slot()
if not (h.admin_active and h.user_active and h.site.user_active and h.site.admin_active):
10 years, 8 months