Basic dispatching.
parent
6c1db01775
commit
a3bba233cd
38
run.py
38
run.py
|
@ -2,9 +2,45 @@
|
|||
|
||||
import sys, logging
|
||||
import tftpy
|
||||
import re
|
||||
import cStringIO
|
||||
import time
|
||||
|
||||
file_hooks = {}
|
||||
def hook_dispatcher(path):
|
||||
for pattern, hook in file_hooks.iteritems():
|
||||
match = re.match(pattern, path)
|
||||
if match:
|
||||
return hook(path, match)
|
||||
return None
|
||||
|
||||
def hook(pattern):
|
||||
def decorator(f):
|
||||
file_hooks[pattern] = f
|
||||
return f
|
||||
return decorator
|
||||
|
||||
@hook(r"^pxelinux.cfg/default$")
|
||||
def pxelinux_default(path, match):
|
||||
s = """default menu.c32
|
||||
prompt 0
|
||||
|
||||
menu title "Khepri Boot Menu generated at %s"
|
||||
menu INCLUDE pxelinux.cfg/graphics.conf
|
||||
MENU AUTOBOOT Starting Xen Node in # seconds
|
||||
|
||||
label xen
|
||||
menu label ^Xen Node
|
||||
menu default
|
||||
timeout 80
|
||||
kernel xen/vmlinuz
|
||||
append rootfstype=nfs root=/dev/nfs nfsroot=10.8.1.1:/var/khepri/nfs/xen,v4,rsize=16384,wsize=16384 ip=:::::eth0:dhcp
|
||||
""" % time.strftime("%d/%m/%Y at %H:%M:%S")
|
||||
return cStringIO.StringIO(s)
|
||||
|
||||
|
||||
def main():
|
||||
server = tftpy.TftpServer("/var/khepri/tftp-root/")
|
||||
server = tftpy.TftpServer("/var/khepri/tftp-root/", dyn_file_func=hook_dispatcher)
|
||||
try:
|
||||
server.listen("10.8.1.1", 5000)
|
||||
except tftpy.TftpException, err:
|
||||
|
|
Reference in New Issue