5eadd326ba5e15eb37f0346001cfe8c0847bc8ff
[invirt/packages/invirt-autoinstaller.git] / partial / sipb-xen-make-iso.py
1 #!/usr/bin/env python
2
3 import sys
4 import os
5 from subprocess import call
6
7 def 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
21 if __name__ == '__main__':
22   make_debian_cd(*sys.argv[1:])