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,100],
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 extra = "selinux=0 ks=file:/root/scripts.ks"
98 maybe_download_isolinux(install)
99 ramdisk = make_ramdisk("/root/%s-install/initrd.img" % install, machine_name, install)
100 elif 'type' in locals() and type == 'hvm':
101 kernel = "/usr/lib/xen/boot/hvmloader"
104 vncpassword = "foobar"
106 # Fedora installs GRUB.
107 bootloader = "/usr/bin/pygrub"
110 if 'memory' not in locals(): memory = vm[vm_mem]
114 disk = [i % (vg, name) for i in ['phy:/dev/%s/%s-root,xvda,w',
115 'phy:/dev/%s/%s-swap,xvde,w']]
116 vif = [i % mac5 for i in ['bridge=eth0, mac=ac:de:48:00:%s:01',
117 'bridge=eth1, mac=ac:de:48:00:%s:02']]
119 if 'builder' not in locals() or builder != "hvm":
120 # https://bugzilla.redhat.com/show_bug.cgi?id=466681
121 # pygrub uses cached and eventually outdated grub.conf, kernel and initrd
122 file('/proc/sys/vm/drop_caches', 'w').write('1')
124 #if 'install' in locals():
125 # disk.append('file:/root/%s-install/cdimg.ext3.img,hdc1,r' % install)