1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import logging
22 import os
23 import VMBuilder.distro
24 import VMBuilder.disk
25 from VMBuilder.util import run_cmd, tmpdir
26
27 STORAGE_DISK_IMAGE = 0
28 STORAGE_FS_IMAGE = 1
29
31 preferred_storage = STORAGE_DISK_IMAGE
32
41
43 """Adds a filesystem to the virtual machine"""
44 from VMBuilder.disk import Filesystem
45
46 fs = Filesystem(self, *args, **kwargs)
47 self.filesystems.append(fs)
48 return fs
49
51 """Adds a disk image to the virtual machine"""
52 from VMBuilder.disk import Disk
53
54 disk = Disk(self, *args, **kwargs)
55 self.disks.append(disk)
56 return disk
57
59 self.nics = [self.NIC()]
60 self.call_hooks('preflight_check')
61 self.call_hooks('configure_networking', self.nics)
62 self.call_hooks('configure_mounting', self.disks, self.filesystems)
63
64 self.chroot_dir = tmpdir()
65 self.call_hooks('mount_partitions', self.chroot_dir)
66 run_cmd('rsync', '-aHA', '%s/' % self.distro.chroot_dir, self.chroot_dir)
67 self.distro.set_chroot_dir(self.chroot_dir)
68 if self.needs_bootloader:
69 self.call_hooks('install_bootloader', self.chroot_dir, self.disks)
70 self.call_hooks('install_kernel', self.chroot_dir)
71 self.distro.call_hooks('post_install')
72 self.call_hooks('unmount_partitions')
73 os.rmdir(self.chroot_dir)
74
80
96
106
110
112 - def __init__(self, type='dhcp', ip=None, network=None, netmask=None,
113 broadcast=None, dns=None, gateway=None):
114 self.type = type
115 self.ip = ip
116 self.network = network
117 self.netmask = netmask
118 self.broadcast = broadcast
119 self.dns = dns
120 self.gateway = gateway
121