1 # Xen domain configuration file for scripts.mit.edu virtualized web servers
4 # xm create scripts-server machine_name=bees-knees
5 # xm create scripts-server machine_name=cats-whiskers
6 # name is the name of the server (as used in the LV volumes)
7 # mac5 is the fifth octet of the MAC address: ac:de:48:00:xx:01
8 # set install=fcX if you want to run a Fedora install, where X
9 # is the version of Fedora to install
15 machines = { 'bees-knees' : ['david-letterman', 2, 6144, '10'],
16 'cats-whiskers' : ['david-letterman', 2, 6144, '20'],
17 'not-backward' : ['david-letterman', 2, 2560, '30'],
18 'busy-beaver' : ['conan-obrien', 2, 4096, '40'],
19 'pancake-bunny' : ['conan-obrien', 2, 4096, '50'],
20 'whole-enchilada': ['jay-leno', 1, 2048, '60'],
21 'real-mccoy' : ['jay-leno', 2, 4096, '70'],
22 'not-forward' : ['jay-leno', 2, 512, '80'],
23 'old-faithful' : ['johnny-carson', 2, 4096, '90'],
24 'better-mousetrap' : ['johnny-carson', 2, 4096, 'a0'],
26 vm = machines[machine_name]
30 def maybe_download_isolinux(install):
32 Download the release image if it isn't already in /root.
37 install_dir = "/root/%s-install" % install
38 if os.path.exists(install_dir): return
39 print "Downloading %s..." % install_dir
40 fedora_release = install[1:],
41 download_dir = "ftp://mirrors.mit.edu/fedora/linux/releases/%s/Fedora/x86_64/os" % fedora_release
43 subprocess.check_call(["wget", "-r", "-nd", download_dir], cwd=install_dir)
45 def serve_kickstart(machine_name, install):
47 Serve a parametrized /root/kickstart.ks to localhost once.
57 hostname = machine_name + ".mit.edu"
58 ip = socket.gethostbyname(hostname)
60 source_server = "cats-whiskers.mit.edu" # hard-coded
61 source_ip = re.sub('^18.181.0.', '172.21.0.', socket.gethostbyname(source_server))
63 # generate the kickstart file
64 ks_orig = open("/etc/xen/scripts.ks").read()
65 ks = string.Template(ks_orig).substitute(
66 local_mirror = "ftp://mirrors.mit.edu",
67 official_mirror = "http://download3.fedora.redhat.com/pub",
69 fedora_release = re.sub('^f', '', install),
72 backend_ip = re.sub('^18.181.0.', '172.21.0.', ip),
73 branch = "branches/fc13-dev",
74 source_server = source_server,
75 source_ip = source_ip,
78 class SingleFileHandler(BaseHTTPServer.BaseHTTPRequestHandler):
80 self.send_response(200)
86 # brief race condition
88 BaseHTTPServer.HTTPServer(('', 55555), SingleFileHandler).handle_request()
90 print "Serving kickstart failed."
93 print "Kickstart served"
97 if 'install' in locals():
98 maybe_download_isolinux(install)
100 kernel = "/root/%s-install/vmlinuz" % install
101 ramdisk = "/root/%s-install/initrd.img" % install
103 ip = socket.gethostbyname(machine_name + ".mit.edu")
105 serve_kickstart(machine_name, install)
107 ks_url = "http://%s.mit.edu:55555/" % vm[vm_host]
112 "netmask=255.255.0.0",
113 "gateway=18.181.0.1",
114 "dns=18.70.0.160,18.71.0.151,18.72.0.3",
116 # "syslog=18.181.0.51:514 debug=1 loglevel=debug telnet",
118 on_reboot = 'destroy' # don't rerun the installer
120 elif 'type' in locals() and type == 'hvm':
121 kernel = "/usr/lib/xen/boot/hvmloader"
124 vncpassword = "foobar"
126 # Fedora installs GRUB.
127 bootloader = "/usr/bin/pygrub"
130 if 'memory' not in locals(): memory = vm[vm_mem]
134 disk = [i % (vg, name) for i in ['phy:/dev/%s/%s-root,xvda,w',
135 'phy:/dev/%s/%s-swap,xvde,w']]
136 vif = [i % mac5 for i in ['bridge=eth0, mac=ac:de:48:00:%s:01',
137 'bridge=eth1, mac=ac:de:48:00:%s:02']]
139 if 'builder' not in locals() or builder != "hvm":
140 # https://bugzilla.redhat.com/show_bug.cgi?id=466681
141 # pygrub uses cached and eventually outdated grub.conf, kernel and initrd
142 file('/proc/sys/vm/drop_caches', 'w').write('1')
144 #if 'install' in locals():
145 # disk.append('file:/root/%s-install/cdimg.ext3.img,hdc1,r' % install)