]> git.ipfire.org Git - ipfire.org.git/blob - build/rpc.py
Added pxe site.
[ipfire.org.git] / build / rpc.py
1 #!/usr/bin/python
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2008,2009 Michael Tremer & Christian Schmidt #
6 # #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 # #
20 ###############################################################################
21
22 import os
23 import sys
24 import cgi
25
26 sys.path.append(".")
27
28 from builder import Builder, getAllBuilders
29 from constants import config
30
31 ALLOWED_ACTIONS_SET = ( "distcc", "duration", "hostname", "jobs", "log", "state",
32 "package", "target", "toolchain", "cpu", "machine", "system",)
33 ALLOWED_ACTIONS_GET = ( "distcc",)
34
35 def run(uuid, action):
36 myself = Builder(config, uuid)
37
38 if action == "get":
39 for key in ALLOWED_ACTIONS_GET:
40 if key == "distcc":
41 for value in data.getlist(key):
42 if value == "raw":
43 builders = getAllBuilders()
44 print "--randomize"
45 for builder in builders:
46 # Print "localhost" for ourself
47 if myself.uuid == builder.uuid:
48 print "localhost"
49 else:
50 if ((myself.toolchain() == builder.toolchain()) and \
51 (myself.machine() == builder.machine()) and \
52 (myself.target() == builder.target())):
53 print "%s" % (builder.distcc,)
54
55 elif action == "set":
56 for key in ALLOWED_ACTIONS_SET:
57 for value in data.getlist(key):
58 print myself.set(key, value)
59
60 data = cgi.FieldStorage()
61
62 print "Status: 200 - OK" # We always send okay.
63 print
64
65 try:
66 uuid = data.getfirst("uuid")
67 action = data.getfirst("action")
68 if uuid and action:
69 run(uuid, action)
70 except SystemExit:
71 pass