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('create_partitions')
63 self.call_hooks('configure_mounting', self.disks, self.filesystems)
64
65 self.chroot_dir = tmpdir()
66 self.call_hooks('mount_partitions', self.chroot_dir)
67 run_cmd('rsync', '-aHA', '%s/' % self.distro.chroot_dir, self.chroot_dir)
68 self.distro.set_chroot_dir(self.chroot_dir)
69 if self.needs_bootloader:
70 self.call_hooks('install_bootloader', self.chroot_dir, self.disks)
71 self.call_hooks('install_kernel', self.chroot_dir)
72 self.distro.call_hooks('post_install')
73 self.call_hooks('unmount_partitions')
74 os.rmdir(self.chroot_dir)
75
81
92
100
110
114
116 - def __init__(self, type='dhcp', ip=None, network=None, netmask=None,
117 broadcast=None, dns=None, gateway=None):
118 self.type = type
119 self.ip = ip
120 self.network = network
121 self.netmask = netmask
122 self.broadcast = broadcast
123 self.dns = dns
124 self.gateway = gateway
125