# is the version of Fedora to install
vm_host = 0
-vm_mem = 1
-vm_mac5 = 2
-machines = { 'bees-knees' : ['not-forward', 6144, 10],
- 'cats-whiskers' : ['not-forward', 6144, 20],
- 'not-backward' : ['not-forward', 2048, 30],
- 'busy-beaver' : ['conan-obrien', 3072, 40],
- 'pancake-bunny' : ['conan-obrien', 3072, 50],
- 'whole-enchilada': ['conan-obrien', 3072, 60],
+vm_cpus = 1
+vm_mem = 2
+vm_mac5 = 3
+machines = { 'bees-knees' : ['david-letterman', 2, 6144, '10'],
+ 'cats-whiskers' : ['david-letterman', 2, 6144, '20'],
+ 'not-backward' : ['david-letterman', 2, 2560, '30'],
+ 'busy-beaver' : ['conan-obrien', 2, 4096, '40'],
+ 'pancake-bunny' : ['conan-obrien', 2, 4096, '50'],
+ 'whole-enchilada': ['jay-leno', 1, 2048, '60'],
+ 'real-mccoy' : ['jay-leno', 2, 4096, '70'],
+ 'not-forward' : ['jay-leno', 2, 512, '80'],
+ 'old-faithful' : ['johnny-carson', 2, 4096, '90'],
+ 'better-mousetrap' : ['johnny-carson', 2, 4096, 'a0'],
}
vm = machines[machine_name]
mac5 = vm[vm_mac5]
+def maybe_download_isolinux(install):
+ """
+ Download the release image if it isn't already in /root.
+ """
+ import subprocess
+ import os.path
+
+ install_dir = "/root/%s-install" % install
+ if os.path.exists(install_dir): return
+ print "Downloading %s..." % install_dir
+ fedora_release = install[1:],
+ download_dir = "ftp://mirrors.mit.edu/fedora/linux/releases/%s/Fedora/x86_64/os" % fedora_release
+ os.mkdir(install_dir)
+ subprocess.check_call(["wget", "-r", "-nd", download_dir], cwd=install_dir)
+
+def make_ramdisk(base_image, machine_name, install):
+ """
+ Create a ramdisk containing our kickstart file in /root/kickstart.ks
+ """
+ import socket
+ import tempfile
+ import subprocess
+ import os
+ import os.path
+ import gzip
+ import StringIO
+ import string
+ import shutil
+
+ # some calculations
+ hostname = machine_name + ".mit.edu"
+ ip = socket.gethostbyname(hostname)
+
+ # create the playground
+ tmpdir = tempfile.mkdtemp()
+ rootdir = os.path.join(tmpdir, "root")
+
+ # add the kickstart file
+ os.mkdir(rootdir)
+ ks_orig = open("/etc/xen/scripts.ks").read()
+ ks = string.Template(ks_orig).substitute(
+ local_mirror = "ftp://mirrors.mit.edu",
+ official_mirror = "http://download3.fedora.redhat.com/pub",
+ arch = "x86_64",
+ fedora_release = install[1:],
+ hostname = hostname,
+ ip = ip,
+ )
+ open(os.path.join(rootdir, "scripts.ks"), 'w').write(ks)
+
+ # generate the final image
+ (tmpfd, tmpname) = tempfile.mkstemp(suffix=".img")
+ tmp = os.fdopen(tmpfd, 'w')
+ tmp.write(gzip.open(base_image).read())
+ tmp.close()
+ find = subprocess.Popen(["find", ".", "-depth", "-print"],
+ stdout=subprocess.PIPE, cwd=tmpdir)
+ cpio = subprocess.Popen(["cpio", "-v", "--append", "-o", "--file", tmpname, "-H", "newc"],
+ stdin=find.stdout, cwd=tmpdir)
+ cpio.communicate()
+ find.wait()
+
+ print "Using initramfs at %s" % tmpname
+ return tmpname
+
if 'install' in locals():
- # Get these files from a Fedora mirror, from a path like
- # pub/fedora/linux/releases/test/11-Preview/Fedora/x86_64/os/isolinux/
kernel = "/root/%s-install/vmlinuz" % install
ramdisk = "/root/%s-install/initrd.img" % install
- extra = "selinux=0"
+
+ # some calculations
+ hostname = machine_name + ".mit.edu"
+ ip = socket.gethostbyname(hostname)
+
+ 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"
+ maybe_download_isolinux(install)
+ #ramdisk = make_ramdisk("/root/%s-install/initrd.img" % install, machine_name, install)
+ on_reboot = 'destroy' # don't rerun the installer
+
elif 'type' in locals() and type == 'hvm':
kernel = "/usr/lib/xen/boot/hvmloader"
builder = "hvm"
# Fedora installs GRUB.
bootloader = "/usr/bin/pygrub"
-vcpus = 2
+vcpus = vm[vm_cpus]
if 'memory' not in locals(): memory = vm[vm_mem]
maxmem = 16384
name = machine_name
vg = vm[vm_host]
-disk = [i % (vg, name) for i in ['phy:/dev/%s/%s-root,hda,w',
- 'phy:/dev/%s/%s-swap,hdb,w']]
+disk = [i % (vg, name) for i in ['phy:/dev/%s/%s-root,xvda,w',
+ 'phy:/dev/%s/%s-swap,xvde,w']]
vif = [i % mac5 for i in ['bridge=eth0, mac=ac:de:48:00:%s:01',
'bridge=eth1, mac=ac:de:48:00:%s:02']]
+if 'install' in locals():
+ del vif[1]
+
if 'builder' not in locals() or builder != "hvm":
# https://bugzilla.redhat.com/show_bug.cgi?id=466681
# pygrub uses cached and eventually outdated grub.conf, kernel and initrd
file('/proc/sys/vm/drop_caches', 'w').write('1')
+
+#if 'install' in locals():
+# disk.append('file:/root/%s-install/cdimg.ext3.img,hdc1,r' % install)