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 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 2931 preferred_storage = STORAGE_DISK_IMAGE 3212034 self.plugin_classes = VMBuilder._hypervisor_plugins 35 super(Hypervisor, self).__init__() 36 self.plugins += [distro] 37 self.distro = distro 38 self.filesystems = [] 39 self.disks = [] 40 self.nics = []4143 """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 fs4951 """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 disk5759 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.call_hooks('unmount_partitions') 72 os.rmdir(self.chroot_dir)7375 self.call_hooks('convert', 76 self.preferred_storage == STORAGE_DISK_IMAGE and self.disks or self.filesystems, 77 destdir) 78 self.call_hooks('deploy', destdir)7981 """Mounts all the vm's partitions and filesystems below .rootmnt""" 82 logging.info('Mounting target filesystems') 83 for fs in self.filesystems: 84 fs.create() 85 fs.mkfs() 86 for disk in self.disks: 87 disk.create() 88 disk.partition() 89 disk.map_partitions() 90 disk.mkfs() 91 fss = VMBuilder.disk.get_ordered_filesystems(self) 92 for fs in fss: 93 fs.mount(mntdir) 94 self.distro.post_mount(fs)9597 """Unmounts all the vm's partitions and filesystems""" 98 logging.info('Unmounting target filesystem') 99 fss = VMBuilder.disk.get_ordered_filesystems(self) 100 fss.reverse() 101 for fs in fss: 102 fs.umount() 103 for disk in self.disks: 104 disk.unmap()105 109
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Tue Apr 19 16:33:01 2011 | http://epydoc.sourceforge.net |