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 make_ramdisk(base_image, machine_name, install):
47 Create a ramdisk containing our kickstart file in /root/kickstart.ks
60 hostname = machine_name + ".mit.edu"
61 ip = socket.gethostbyname(hostname)
63 # create the playground
64 tmpdir = tempfile.mkdtemp()
65 rootdir = os.path.join(tmpdir, "root")
67 # add the kickstart file
69 ks_orig = open("/etc/xen/scripts.ks").read()
70 ks = string.Template(ks_orig).substitute(
71 local_mirror = "ftp://mirrors.mit.edu",
72 official_mirror = "http://download3.fedora.redhat.com/pub",
74 fedora_release = install[1:],
78 open(os.path.join(rootdir, "scripts.ks"), 'w').write(ks)
80 # generate the final image
81 (tmpfd, tmpname) = tempfile.mkstemp(suffix=".img")
82 tmp = os.fdopen(tmpfd, 'w')
83 tmp.write(gzip.open(base_image).read())
85 find = subprocess.Popen(["find", ".", "-depth", "-print"],
86 stdout=subprocess.PIPE, cwd=tmpdir)
87 cpio = subprocess.Popen(["cpio", "-v", "--append", "-o", "--file", tmpname, "-H", "newc"],
88 stdin=find.stdout, cwd=tmpdir)
92 print "Using initramfs at %s" % tmpname
95 if 'install' in locals():
96 kernel = "/root/%s-install/vmlinuz" % install
97 ramdisk = "/root/%s-install/initrd.img" % install
100 hostname = machine_name + ".mit.edu"
101 ip = socket.gethostbyname(hostname)
103 extra = "selinux=0 ks=http://whole-enchilada.mit.edu/old-faithful.txt ip="+ip+" netmask=255.255.0.0 gateway=18.181.0.1 dns=18.70.0.160,18.71.0.151,18.72.0.3 syslog=18.181.0.51:514 debug=1 loglevel=debug telnet"
104 maybe_download_isolinux(install)
105 #ramdisk = make_ramdisk("/root/%s-install/initrd.img" % install, machine_name, install)
106 on_reboot = 'destroy' # don't rerun the installer
108 elif 'type' in locals() and type == 'hvm':
109 kernel = "/usr/lib/xen/boot/hvmloader"
112 vncpassword = "foobar"
114 # Fedora installs GRUB.
115 bootloader = "/usr/bin/pygrub"
118 if 'memory' not in locals(): memory = vm[vm_mem]
122 disk = [i % (vg, name) for i in ['phy:/dev/%s/%s-root,xvda,w',
123 'phy:/dev/%s/%s-swap,xvde,w']]
124 vif = [i % mac5 for i in ['bridge=eth0, mac=ac:de:48:00:%s:01',
125 'bridge=eth1, mac=ac:de:48:00:%s:02']]
127 if 'install' in locals():
130 if 'builder' not in locals() or builder != "hvm":
131 # https://bugzilla.redhat.com/show_bug.cgi?id=466681
132 # pygrub uses cached and eventually outdated grub.conf, kernel and initrd
133 file('/proc/sys/vm/drop_caches', 'w').write('1')
135 #if 'install' in locals():
136 # disk.append('file:/root/%s-install/cdimg.ext3.img,hdc1,r' % install)