aboutsummaryrefslogtreecommitdiff
path: root/master
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek.chauhan@gmail.com>2008-08-16 18:30:33 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2008-08-16 18:30:33 +0530
commitc2d11859491622380703ea21954f07fb484e04ba (patch)
tree8232b2b3f76dd884711407ae2f8ec95199ecc3e7 /master
parent- Add ~username/jobs/ page (diff)
downloadautotua-c2d11859491622380703ea21954f07fb484e04ba.tar.gz
autotua-c2d11859491622380703ea21954f07fb484e04ba.tar.bz2
autotua-c2d11859491622380703ea21954f07fb484e04ba.zip
Link the master and the slave in a simplistic (for now) way:
* stage url processing is shifted to the master now * Communication is via protocol 2 (binary) pickles * slave API can be accessed via /slave_api/jobs /slave_api/jobs/<username> /slave_api/jobs/<username>/<job_name>
Diffstat (limited to 'master')
-rw-r--r--master/autotua/slave_api.py37
-rw-r--r--master/autotua/templates/data.html8
-rw-r--r--master/autotua/urls.py13
3 files changed, 46 insertions, 12 deletions
diff --git a/master/autotua/slave_api.py b/master/autotua/slave_api.py
new file mode 100644
index 0000000..686009d
--- /dev/null
+++ b/master/autotua/slave_api.py
@@ -0,0 +1,37 @@
+# vim: set sw=4 sts=4 et :
+# Copyright: 2008 Gentoo Foundation
+# Author(s): Nirbheek Chauhan <nirbheek.chauhan@gmail.com>
+# License: GPL-2
+#
+# Immortal lh!
+#
+
+import cPickle as pickle
+
+from django.conf import settings
+from django.http import HttpResponse
+from django.shortcuts import *
+
+from master.models import Job, User
+import process
+
+def job_list(request, **kwargs):
+ filters = {}
+ if kwargs.has_key('username'):
+ filters['maintainer'] = get_object_or_404(User, username=kwargs['username'])
+ if kwargs.has_key('job_name'):
+ filters['name'] = kwargs['job_name']
+ jobs = []
+ for job in get_list_or_404(Job, **filters):
+ jobs.append(job_data(job))
+ return HttpResponse(pickle.dumps(jobs, 2), mimetype='application/octet-stream')
+
+def job_data(job):
+ data = {'maintainer': {'username': job.maintainer.username,
+ 'name': job.maintainer.get_full_name(),
+ 'email': job.maintainer.email,},
+ 'name': job.name,
+ 'jobtagerev': job.jobtagerev,
+ 'stage': process.generate_stage_url(job),
+ 'atoms': job.atoms,}
+ return data
diff --git a/master/autotua/templates/data.html b/master/autotua/templates/data.html
deleted file mode 100644
index bc448fb..0000000
--- a/master/autotua/templates/data.html
+++ /dev/null
@@ -1,8 +0,0 @@
-{# vim: set sw=4 sts=4 et filetype=htmldjango : #}
-{# Copyright: 2008 Gentoo Foundation #}
-{# Author(s): Nirbheek Chauhan <nirbheek.chauhan@gmail.com> #}
-{# License: GPL-2 #}
-{# #}
-{# Immortal lh! #}
-{# #}
-{{ data }}
diff --git a/master/autotua/urls.py b/master/autotua/urls.py
index e3df801..58c62f1 100644
--- a/master/autotua/urls.py
+++ b/master/autotua/urls.py
@@ -8,11 +8,16 @@
from django.conf.urls.defaults import *
from django.conf import settings
-from views import *
-urlpatterns = patterns('',
- (r'^~([a-zA-Z0-9_]+)/$', user_page),
- (r'^~([a-zA-Z0-9_]+)/jobs/$', jobs_page),
+urlpatterns = patterns('master.views',
+ (r'^~([a-zA-Z0-9_]+)/$', 'user_page'),
+ (r'^~([a-zA-Z0-9_]+)/jobs/$', 'jobs_page'),
+)
+
+urlpatterns += patterns('master.slave_api',
+ (r'^slave_api/jobs/$', 'job_list'),
+ (r'^slave_api/jobs/(?P<username>[a-zA-Z0-9_]+)/$', 'job_list'),
+ (r'^slave_api/jobs/(?P<username>[a-zA-Z0-9_]+)/(?P<job_name>[^/]+)/$', 'job_list'),
)
# Static media serving for development purposes