-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkicker.py
More file actions
74 lines (58 loc) · 1.72 KB
/
kicker.py
File metadata and controls
74 lines (58 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import sys
from mako.template import Template
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
HandlerClass = SimpleHTTPRequestHandler
ServerClass = BaseHTTPServer.HTTPServer
Protocol = "HTTP/1.0"
Port = 38149
MenuActions = {
'c': [], # Configure
'o': [], # Select OS
}
def do_menu():
print chr(27) + "[2J"
print "\nKicker - produce and serve kickstart files:\n\n"
menu = Template(filename='menu/menu.tmpl', module_directory='/tmp')
print(menu.render())
do_status()
try:
choice = raw_input("\n\n\tPlease enter your choice\t\t:\t")
except KeyError:
print "\n\n\tInvalid choice\n"
choice = False
return choice
def do_status():
print "\n\n\tServer status: Not implemented\n"
return
def process_command(cmd):
# TODO: Initialization of kickstart "engine"
# TODO: Print command template
# TODO: Execute necessary commands
# TODO: Any exception handling
return
def start_server():
# TODO: Fork
# TODO: Customise!
server_address = ('0.0.0.0', Port)
HandlerClass.protocol_version = Protocol
httpd = ServerClass(server_address, HandlerClass)
sa = httpd.socket.getsockname()
print "Serving HTTPD on ", sa[0], " port ", sa[1], "..."
httpd.serve_forever()
return
def start_command_server():
# Hosts a RESTful Command WS
# TODO: Map base URI to key command processor
return
def main():
choice = do_menu()
start_server()
start_command_server()
while choice.lower() != 'q':
choice = do_menu()
if hasattr(MenuActions, choice):
process_command(MenuActions[choice])
return
if __name__ == "__main__":
main()