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, 2560, '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', 2, 4096, '60'],
21 'real-mccoy' : ['jay-leno', 2, 4096, '70'],
22 'not-forward' : ['jay-leno', 1, 512, '80'],
23 'old-faithful' : ['johnny-carson', 2, 4096, '90'],
24 'better-mousetrap' : ['johnny-carson', 2, 4096, 'a0'],
25 'shining-armor' : ['david-letterman', 2, 6144, 'b0'],
27 vm = machines[machine_name]
31 def maybe_download_isolinux(install):
33 Download the release image if it isn't already in /root.
38 install_dir = "/root/%s-install" % install
39 if os.path.exists(install_dir): return
40 print "Downloading %s..." % install_dir
41 fedora_release = install[1:],
42 download_dir = "ftp://mirrors.mit.edu/fedora/linux/releases/%s/Fedora/x86_64/os/isolinux" % fedora_release
44 subprocess.check_call(["wget", "-r", "-nd", download_dir], cwd=install_dir)
46 def serve_kickstart(machine_name, install):
48 Serve a parametrized /root/kickstart.ks to localhost once.
58 hostname = machine_name + ".mit.edu"
59 ip = socket.gethostbyname(hostname)
61 source_server = "shining-armor.mit.edu" # hard-coded
62 source_ip = re.sub('^18.181.0.', '172.21.0.', socket.gethostbyname(source_server))
64 # generate the kickstart file
65 ks_orig = open("/etc/xen/scripts.ks").read()
66 ks = string.Template(ks_orig).substitute(
67 local_mirror = "ftp://mirrors.mit.edu",
68 official_mirror = "http://download3.fedora.redhat.com/pub",
70 fedora_release = re.sub('^f', '', install),
73 backend_ip = re.sub('^18.181.0.', '172.21.0.', ip),
74 branch = "branches/fc13-dev",
75 source_server = source_server,
76 source_ip = source_ip,
79 class SingleFileHandler(BaseHTTPServer.BaseHTTPRequestHandler):
81 self.send_response(200)
87 # brief race condition
89 BaseHTTPServer.HTTPServer(('', 55555), SingleFileHandler).handle_request()
91 print "Serving kickstart failed."
94 print "Kickstart served"
98 if 'install' in locals():
99 maybe_download_isolinux(install)
101 kernel = "/root/%s-install/vmlinuz" % install
102 ramdisk = "/root/%s-install/initrd.img" % install
104 ip = socket.gethostbyname(machine_name + ".mit.edu")
106 serve_kickstart(machine_name, install)
108 ks_url = "http://%s.mit.edu:55555/" % vm[vm_host]
113 "netmask=255.255.0.0",
114 "gateway=18.181.0.1",
115 "dns=18.70.0.160,18.71.0.151,18.72.0.3",
117 # "syslog=18.181.0.51:514 debug=1 loglevel=debug telnet",
119 on_reboot = 'destroy' # don't rerun the installer
121 elif 'type' in locals() and type == 'hvm':
122 kernel = "/usr/lib/xen/boot/hvmloader"
125 vncpassword = "foobar"
127 # Fedora installs GRUB.
128 bootloader = "/usr/bin/pygrub"
131 if 'memory' not in locals(): memory = vm[vm_mem]
135 disk = [i % (vg, name) for i in ['phy:/dev/%s/%s-root,xvda,w',
136 'phy:/dev/%s/%s-swap,xvde,w']]
137 vif = [i % mac5 for i in ['bridge=eth0, mac=ac:de:48:00:%s:01',
138 'bridge=eth1, mac=ac:de:48:00:%s:02']]
140 if 'builder' not in locals() or builder != "hvm":
141 # https://bugzilla.redhat.com/show_bug.cgi?id=466681
142 # pygrub uses cached and eventually outdated grub.conf, kernel and initrd
143 file('/proc/sys/vm/drop_caches', 'w').write('1')
145 #if 'install' in locals():
146 # disk.append('file:/root/%s-install/cdimg.ext3.img,hdc1,r' % install)