Package ganeti :: Package cmdlib :: Module instance_storage :: Class TemporaryDisk
[hide private]
[frames] | no frames]

Class TemporaryDisk

source code

Creates a new temporary bootable disk, and makes sure it is destroyed.

Is a context manager, and should be used with the ``with`` statement as such.

The disk is guaranteed to be created at index 0, shifting any other disks of the instance by one place, and allowing the instance to be booted with the content of the disk.

Instance Methods [hide private]
 
__init__(self, lu, instance, disks, feedback_fn, shutdown_timeout=constants.DEFAULT_SHUTDOWN_TIMEOUT)
Constructor storing arguments until used later.
source code
 
_EnsureInstanceDiskState(self)
Ensures that the instance is down, and its disks inactive.
source code
ganeti.objects.Disk
__enter__(self)
Context manager entry function, creating the disk.
source code
 
__exit__(self, exc_type, _value, _traceback)
Context manager exit function, destroying the disk.
source code
Method Details [hide private]

__init__(self, lu, instance, disks, feedback_fn, shutdown_timeout=constants.DEFAULT_SHUTDOWN_TIMEOUT)
(Constructor)

source code 

Constructor storing arguments until used later.

Parameters:
  • lu (ganeti.cmdlib.base.LogicalUnit) - The LU within which this disk is created.
  • instance (ganeti.objects.Instance) - The instance to which the disk should be added
  • disks (list of triples (disk template, disk access mode, int)) - disk specification, which is a list of triples containing the disk template (e.g., constants.DT_PLAIN), the disk access mode (i.e., constants.DISK_RDONLY or constants.DISK_RDWR), and size in MiB.
  • feedback_fn (function) - Function used to log progress

_EnsureInstanceDiskState(self)

source code 

Ensures that the instance is down, and its disks inactive.

All the operations related to the creation and destruction of disks require that the instance is down and that the disks are inactive. This function is invoked to make it so.

__enter__(self)

source code 

Context manager entry function, creating the disk.

Returns: ganeti.objects.Disk
The disk object created.