Package VMBuilder :: Module vm :: Class VM
[frames] | no frames]

Class VM

source code

object --+
         |
        VM

The VM object has the following attributes of relevance to plugins:

distro: A distro object, representing the distro running in the vm

disks: The disk images for the vm.
filesystems: The filesystem images for the vm.

result_files: A list of the files that make up the entire vm.
              The ownership of these files will be fixed up.

optparser: Will be of interest mostly to frontends. Any sort of option
           a plugin accepts will be represented in the optparser.

Instance Methods
 
__init__(self, conf=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
cleanup(self) source code
 
add_clean_cb(self, cb) source code
 
add_clean_cmd(self, *argv, **kwargs) source code
 
cancel_cleanup(self, cb) source code
 
distro_help(self) source code
 
hypervisor_help(self) source code
 
register_setting(self, *args, **kwargs) source code
 
register_setting_group(self, group) source code
 
setting_group(self, *args, **kwargs) source code
 
add_disk(self, *args, **kwargs)
Adds a disk image to the virtual machine
source code
 
add_filesystem(self, *args, **kwargs)
Adds a filesystem to the virtual machine
source code
 
call_hooks(self, func) source code
 
deploy(self)
"Deploy" the VM, by asking the plugins in turn to deploy it.
source code
 
set_distro(self, arg) source code
 
set_hypervisor(self, arg) source code
 
get_conf_value(self, key) source code
 
set_defaults(self)
is called to give all the plugins and the distro and hypervisor plugin a chance to set some reasonable defaults, which the frontend then can inspect and present
source code
 
ip_defaults(self)
is called to validate the ip configuration given and set defaults
source code
 
create_directory_structure(self)
Creates the directory structure where we'll be doing all the work
source code
 
create_workdir(self)
Creates the working directory for this vm and returns its path
source code
 
mount_partitions(self)
Mounts all the vm's partitions and filesystems below .rootmnt
source code
 
umount_partitions(self)
Unmounts all the vm's partitions and filesystems
source code
 
install(self) source code
 
preflight_check(self) source code
 
install_file(self, path, contents=None, source=None, mode=None) source code
 
create(self)
The core vm creation method
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Instance Variables
  hypervisor
hypervisor object, representing the hypervisor the vm is destined for
Properties

Inherited from object: __class__

Method Details

__init__(self, conf=None)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

deploy(self)

source code 

"Deploy" the VM, by asking the plugins in turn to deploy it.

If no non-hypervior and non-distro plugin accepts to deploy the image, thfe hypervisor's default deployment is used.

Returns when the first True is returned.

create_directory_structure(self)

source code 

Creates the directory structure where we'll be doing all the work

When create_directory_structure returns, the following attributes will be set:

  • VM.destdir: The final destination for the disk images
  • VM.workdir: The temporary directory where we'll do all the work
  • VM.rootmnt: The root mount point where all the target filesystems will be mounted
  • VM.tmproot: The directory where we build up the guest filesystem

..and the corresponding directories are created.

Additionally, VM.destdir is created, which is where the files (disk images, filesystem images, run scripts, etc.) will eventually be placed.

create(self)

source code 

The core vm creation method

The VM creation happens in the following steps:

A series of preliminary checks are performed:

  • We check if we're being run as root, since the filesystem handling requires root priv's
  • Each plugin's preflight_check method is called. See VMBuilder.plugins.Plugin documentation for details
  • create_directory_structure is called
  • VMBuilder.disk.create_partitions is called
  • VMBuilder.disk.create_filesystems is called
  • .mount_partitions is called
  • .install is called