source: trunk/packages/sipb-xen-guest-installer/sipb-xen-guest-installer/partial/sipb-xen-make-iso.py @ 201

Last change on this file since 201 was 201, checked in by price, 17 years ago

a system for building guest images on demand (partially implemented)

The plan, roughly, is

  1. we download an upstream install CD iso, mount it, copy out the contents;
  2. when a user wants a VM, the script makes a copy, applies a small static patch (mostly a preseed file for the installer), adds a few vm-dependent variables to the preseed, maybe makes some other changes here, then makes an iso from that;
  3. we boot a vm from the new iso, with the empty volume as /dev/hda, and let the installer run.

This checkin implements 2 and 3, when run in an appropriate testing
environment, but I haven't adapted it to the real environment yet.
Step 2 turns out to be surprisingly fast; much less than a second.
Step 3, unfortunately, is looking like 20 minutes, maybe 10 if we
work at tightening it. We'll want to mitigate that somehow.

Code in the 'partial' directory is meant to be moved elsewhere
as it gets integrated.

  • Property svn:executable set to *
File size: 902 bytes
Line 
1#!/usr/bin/env python
2
3import sys
4import os
5from subprocess import call
6
7def make_debian_cd(basetree, guest_ip, guest_hostname, passhash, output_iso):
8  old_preseed = file(os.path.join(basetree, 'preseed.cfg'))
9  cdtree = os.path.join(basetree, 'cdrom')
10  new_preseed = file(os.path.join(cdtree, 'preseed.cfg'), 'w')
11  new_preseed.write(old_preseed.read())
12  new_preseed.write('d-i netcfg/get_ipaddress string '+guest_ip+'\n')
13  new_preseed.write('d-i netcfg/get_hostname string '+guest_hostname+'\n')
14  new_preseed.write('d-i passwd/root-password-crypted password '+passhash+'\n')
15  new_preseed.close()
16  call('''mkisofs -r -V "SIPB-Xen_Custom_Install_CD" -cache-inodes -J -l
17           -b isolinux/isolinux.bin -c isolinux/boot.cat
18           -no-emul-boot -boot-load-size 4 -boot-info-table'''.split()
19       + ['-o', output_iso, cdtree])
20
21if __name__ == '__main__':
22  make_debian_cd(*sys.argv[1:])
Note: See TracBrowser for help on using the repository browser.