Home | Trees | Indices | Help |
---|
|
1 # 2 # Uncomplicated VM Builder 3 # Copyright (C) 2007-2009 Canonical Ltd. 4 # 5 # See AUTHORS for list of contributors 6 # 7 # This program is free software: you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License version 3, as 9 # published by the Free Software Foundation. 10 # 11 # This program is distributed in the hope that it will be useful, 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 # GNU General Public License for more details. 15 # 16 # You should have received a copy of the GNU General Public License 17 # along with this program. If not, see <http://www.gnu.org/licenses/>. 18 # 19 # Hypervisor super class 20 21 import logging 22 import VMBuilder.distro 23 import VMBuilder.disk 24 from VMBuilder.util import run_cmd, tmpdir 25 26 STORAGE_DISK_IMAGE = 0 27 STORAGE_FS_IMAGE = 1 2830 preferred_storage = STORAGE_DISK_IMAGE 3111833 self.plugin_classes = VMBuilder._hypervisor_plugins 34 super(Hypervisor, self).__init__() 35 self.plugins += [distro] 36 self.distro = distro 37 self.filesystems = [] 38 self.disks = [] 39 self.nics = []4042 """Adds a filesystem to the virtual machine""" 43 from VMBuilder.disk import Filesystem 44 45 fs = Filesystem(self, *args, **kwargs) 46 self.filesystems.append(fs) 47 return fs4850 """Adds a disk image to the virtual machine""" 51 from VMBuilder.disk import Disk 52 53 disk = Disk(self, *args, **kwargs) 54 self.disks.append(disk) 55 return disk5658 self.nics = [self.NIC()] 59 self.call_hooks('preflight_check') 60 self.call_hooks('configure_networking', self.nics) 61 self.call_hooks('configure_mounting', self.disks, self.filesystems) 62 63 self.chroot_dir = tmpdir() 64 self.call_hooks('mount_partitions', self.chroot_dir) 65 run_cmd('rsync', '-aHA', '%s/' % self.distro.chroot_dir, self.chroot_dir) 66 self.distro.set_chroot_dir(self.chroot_dir) 67 if self.needs_bootloader: 68 self.call_hooks('install_bootloader', self.chroot_dir, self.disks) 69 self.call_hooks('install_kernel', self.chroot_dir) 70 self.call_hooks('unmount_partitions')7173 self.call_hooks('convert', 74 self.preferred_storage == STORAGE_DISK_IMAGE and self.disks or self.filesystems, 75 destdir) 76 self.call_hooks('deploy', destdir)7779 """Mounts all the vm's partitions and filesystems below .rootmnt""" 80 logging.info('Mounting target filesystems') 81 for fs in self.filesystems: 82 fs.create() 83 fs.mkfs() 84 for disk in self.disks: 85 disk.create() 86 disk.partition() 87 disk.map_partitions() 88 disk.mkfs() 89 fss = VMBuilder.disk.get_ordered_filesystems(self) 90 for fs in fss: 91 fs.mount(mntdir) 92 self.distro.post_mount(fs)9395 """Unmounts all the vm's partitions and filesystems""" 96 logging.info('Unmounting target filesystem') 97 fss = VMBuilder.disk.get_ordered_filesystems(self) 98 fss.reverse() 99 for fs in fss: 100 fs.umount() 101 for disk in self.disks: 102 disk.unmap()103 107
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Tue Mar 30 04:55:12 2010 | http://epydoc.sourceforge.net |