Package VMBuilder :: Module disk :: Class Disk
[frames] | no frames]

Class Disk

source code

object --+
         |
        Disk

Nested Classes
  Partition
Instance Methods
 
__init__(self, vm, size='5G', preallocated=False, filename=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
string
devletters(self)
Returns: the series of letters that ought to correspond to the device inside the VM.
source code
 
create(self, directory)
Creates the disk image (unless preallocated), partitions it, creates the partition mapping devices and mkfs's the partitions
source code
string
get_grub_id(self)
Returns: name of the disk as known by grub
source code
number
get_index(self)
Returns: index of the disk (starting from 0)
source code
 
unmap(self, ignore_fail=False)
Destroy all mapping devices
source code
 
add_part(self, begin, length, type, mntpnt)
Add a partition to the disk
source code
string
convert(self, destdir, format)
Convert the disk image
source code

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

Properties

Inherited from object: __class__

Method Details

__init__(self, vm, size='5G', preallocated=False, filename=None)
(Constructor)

source code 

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

Parameters:
  • size (string or number) - The size of the disk image (passed to parse_size)
  • preallocated (boolean) - if True, the disk image already exists and will not be created (useful for raw devices)
  • filename (string) - force a certain filename or to give the name of the preallocated disk image
Overrides: object.__init__

devletters(self)

source code 
Returns: string
the series of letters that ought to correspond to the device inside the VM. E.g. the first disk of a VM would return 'a', while the 702nd would return 'zz'

create(self, directory)

source code 

Creates the disk image (unless preallocated), partitions it, creates the partition mapping devices and mkfs's the partitions

Parameters:
  • directory (string) - If set, the disk image is created in this directory

get_grub_id(self)

source code 
Returns: string
name of the disk as known by grub

get_index(self)

source code 
Returns: number
index of the disk (starting from 0)

add_part(self, begin, length, type, mntpnt)

source code 

Add a partition to the disk

Parameters:
  • begin (number) - Start offset of the new partition (in megabytes)
  • length () - Size of the new partition (in megabytes)
  • type (string) - Type of the new partition. Valid options are: ext2 ext3 xfs swap linux-swap
  • mntpnt (string) - Intended mountpoint inside the guest of the new partition

convert(self, destdir, format)

source code 

Convert the disk image

Parameters:
  • destdir (string) - Target location of converted disk image
  • format (string) - The target format (as understood by qemu-img or vdi)
Returns: string
the name of the converted image