source: old/trunk/vtest/buildmaster.py @ 2598

Revision 2598, 2.3 KB checked in by kcr@…, 20 months ago (diff)

add license

Line 
1#!/usr/bin/python
2# -*- coding: utf-8 -*-
3# Copyright © 2009 by Karl Ramm
4#
5# All rights reserved.
6#
7# Permission to use, copy, modify, and distribute this software and
8# its documentation for any purpose and without fee is hereby granted,
9# provided that the above copyright notice appear in all copies and
10# that both that copyright notice and this permission notice appear in
11# supporting documentation, and that the name of Karl Ramm not be used
12# in advertising or publicity pertaining to distribution of the
13# software without specific, written prior permission.
14#
15# KARL RAMM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
16# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
17# NO EVENT SHALL KARL RAMM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
18# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22
23from sys import exit
24from os import rename
25from os.path import exists
26from time import sleep
27from vm import sshtestmachine
28
29mvover = False
30
31def main():
32    ouch = False
33    t = None
34    try:
35        open('./known-hosts', 'w').close() # open for writing and thus truncate
36        image = 'install.img'
37        t = sshtestmachine(0,
38                           sshmaster=None,
39                           mkimage='qemu-img create -f qcow2 %s 2G' % image,
40                           image=image,
41                           qemuopts='-kernel tftpboot/debian-installer/i386/linux -initrd initrd.gz --append "quiet locale=en_US priority=critical DEBIAN_FRONTEND=text fb=false"') # -nographic #console=ttyS0,115200
42        t.wait()
43        t=sshtestmachine(0, mkimage='true', image=image, qemuopts='')
44
45        while not t.ready():
46            sleep(5)
47
48        t.putfile('files/dhcp.hostname', '/etc/dhcp/dhclient-exit-hooks.d/hostname')
49        t.script("sed -ie '/^127\.0\.1\.1/d' /etc/hosts") # HATE
50    except:
51        ouch = True
52        raise
53    finally:
54        try:
55            if t is not None:
56                t.shutdown()
57        except:
58            pass
59        if t is not None:
60            t.wait()
61
62    if not ouch and mvover:
63        rename('install.img', 'master.img')
64    else:
65        exit(1)
66
67if __name__ == '__main__':
68    main()
69    exit(0)
Note: See TracBrowser for help on using the repository browser.