Package ganeti :: Package hypervisor :: Module hv_base :: Class BaseHypervisor
[hide private]
[frames] | no frames]

Class BaseHypervisor

source code


Abstract virtualisation technology interface

The goal is that all aspects of the virtualisation technology are abstracted away from the rest of code.

Instance Methods [hide private]
 
StartInstance(self, instance, block_devices, startup_paused)
Start an instance.
source code
 
StopInstance(self, instance, force=False, retry=False, name=None, timeout=None)
Stop an instance
source code
 
CleanupInstance(self, instance_name)
Cleanup after a stopped instance
source code
 
RebootInstance(self, instance)
Reboot an instance.
source code
 
ListInstances(self, hvparams=None)
Get the list of running instances.
source code
 
GetInstanceInfo(self, instance_name, hvparams=None)
Get instance properties.
source code
 
GetAllInstancesInfo(self, hvparams=None)
Get properties of all instances.
source code
 
GetNodeInfo(self, hvparams=None)
Return information about the node.
source code
 
Verify(self, hvparams=None)
Verify the hypervisor.
source code
string/data (opaque)
MigrationInfo(self, instance)
Get instance information to perform a migration.
source code
 
AcceptInstance(self, instance, info, target)
Prepare to accept an instance.
source code
 
BalloonInstanceMemory(self, instance, mem)
Balloon an instance memory to a certain value.
source code
 
FinalizeMigrationDst(self, instance, info, success)
Finalize the instance migration on the target node.
source code
 
MigrateInstance(self, cluster_name, instance, target, live)
Migrate an instance.
source code
 
FinalizeMigrationSource(self, instance, success, live)
Finalize the instance migration on the source node.
source code
objects.MigrationStatus
GetMigrationStatus(self, instance)
Get the migration status
source code
integer
_InstanceStartupMemory(self, instance)
Get the correct startup memory for an instance
source code
 
HotAddDevice(self, instance, dev_type, device, extra, seq)
Hot-add a device.
source code
 
HotDelDevice(self, instance, dev_type, device, extra, seq)
Hot-del a device.
source code
 
HotModDevice(self, instance, dev_type, device, extra, seq)
Hot-mod a device.
source code
 
VerifyHotplugSupport(self, instance, action, dev_type)
Verifies that hotplug is supported.
source code
 
HotplugSupported(self, instance)
Checks if hotplug is supported.
source code

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

Class Methods [hide private]
 
GetInstanceConsole(cls, instance, primary_node, hvparams, beparams)
Return information for connecting to the console of an instance.
source code
(list of absolute paths, list of absolute paths)
GetAncillaryFiles(cls)
Return a list of ancillary files to be copied to all nodes as ancillary configuration files.
source code
 
CheckParameterSyntax(cls, hvparams)
Check the given parameters for validity.
source code
 
ValidateParameters(cls, hvparams)
Check the given parameters for validity.
source code
 
PowercycleNode(cls, hvparams=None)
Hard powercycle a node using hypervisor specific methods.
source code
 
LinuxPowercycle(cls)
Linux-specific powercycle method.
source code
Static Methods [hide private]
 
GetLinuxNodeInfo(meminfo="/proc/meminfo", cpuinfo="/proc/cpuinfo")
For linux systems, return actual OS information.
source code
 
_FormatVerifyResults(msgs)
Formats the verification results, given a list of errors.
source code
Class Variables [hide private]
  PARAMETERS = {}
a dict of parameter name: check type; the check type is a five-tuple containing:
  ANCILLARY_FILES = []
  ANCILLARY_FILES_OPT = []
boolean CAN_MIGRATE = False
whether this hypervisor can do migration (either live or non-live)
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

StopInstance(self, instance, force=False, retry=False, name=None, timeout=None)

source code 

Stop an instance

Parameters:
  • instance (objects.Instance) - instance to stop
  • force (boolean) - whether to do a "hard" stop (destroy)
  • retry (boolean) - whether this is just a retry call
  • name (string or None) - if this parameter is passed, the the instance object should not be used (will be passed as None), and the shutdown must be done by name only
  • timeout (int or None) - if the parameter is not None, a soft shutdown operation will be killed after the specified number of seconds. A hard (forced) shutdown cannot have a timeout

CleanupInstance(self, instance_name)

source code 

Cleanup after a stopped instance

This is an optional method, used by hypervisors that need to cleanup after an instance has been stopped.

Parameters:
  • instance_name (string) - instance name to cleanup after

GetInstanceInfo(self, instance_name, hvparams=None)

source code 

Get instance properties.

Parameters:
  • instance_name (string) - the instance name
  • hvparams (dict of strings) - hvparams to be used with this instance
Returns:
tuple (name, id, memory, vcpus, state, times)

GetAllInstancesInfo(self, hvparams=None)

source code 

Get properties of all instances.

Parameters:
  • hvparams (dict of strings) - hypervisor parameter
Returns:
list of tuples (name, id, memory, vcpus, stat, times)

GetNodeInfo(self, hvparams=None)

source code 

Return information about the node.

Parameters:
  • hvparams (dict of strings) - hypervisor parameters
Returns:
a dict with at least the following keys (memory values in MiB):
  • memory_total: the total memory size on the node
  • memory_free: the available memory on the node for instances
  • memory_dom0: the memory used by the node itself, if available
  • cpu_total: total number of CPUs
  • cpu_dom0: number of CPUs used by the node OS
  • cpu_nodes: number of NUMA domains
  • cpu_sockets: number of physical CPU sockets

GetAncillaryFiles(cls)
Class Method

source code 

Return a list of ancillary files to be copied to all nodes as ancillary configuration files.

Returns: (list of absolute paths, list of absolute paths)
(all files, optional files)

Verify(self, hvparams=None)

source code 

Verify the hypervisor.

Parameters:
  • hvparams (dict of strings) - hypervisor parameters to be verified against
Returns:
Problem description if something is wrong, None otherwise

MigrationInfo(self, instance)

source code 

Get instance information to perform a migration.

By default assume no information is needed.

Parameters:
Returns: string/data (opaque)
instance migration information - serialized form

AcceptInstance(self, instance, info, target)

source code 

Prepare to accept an instance.

By default assume no preparation is needed.

Parameters:
  • instance (objects.Instance) - instance to be accepted
  • info (string/data (opaque)) - migration information, from the source node
  • target (string) - target host (usually ip), on this node

BalloonInstanceMemory(self, instance, mem)

source code 

Balloon an instance memory to a certain value.

Parameters:
  • instance (objects.Instance) - instance to be accepted
  • mem (int) - actual memory size to use for instance runtime

FinalizeMigrationDst(self, instance, info, success)

source code 

Finalize the instance migration on the target node.

Should finalize or revert any preparation done to accept the instance. Since by default we do no preparation, we also don't have anything to do

Parameters:
  • instance (objects.Instance) - instance whose migration is being finalized
  • info (string/data (opaque)) - migration information, from the source node
  • success (boolean) - whether the migration was a success or a failure

MigrateInstance(self, cluster_name, instance, target, live)

source code 

Migrate an instance.

Parameters:
  • cluster_name (string) - name of the cluster
  • instance (objects.Instance) - the instance to be migrated
  • target (string) - hostname (usually ip) of the target node
  • live (boolean) - whether to do a live or non-live migration

FinalizeMigrationSource(self, instance, success, live)

source code 

Finalize the instance migration on the source node.

Parameters:
  • instance (objects.Instance) - the instance that was migrated
  • success (bool) - whether the migration succeeded or not
  • live (bool) - whether the user requested a live migration or not

GetMigrationStatus(self, instance)

source code 

Get the migration status

Parameters:
Returns: objects.MigrationStatus
the status of the current migration (one of constants.HV_MIGRATION_VALID_STATUSES), plus any additional progress info that can be retrieved from the hypervisor

_InstanceStartupMemory(self, instance)

source code 

Get the correct startup memory for an instance

This function calculates how much memory an instance should be started with, making sure it's a value between the minimum and the maximum memory, but also trying to use no more than the current free memory on the node.

Parameters:
Returns: integer
memory the instance should be started with

CheckParameterSyntax(cls, hvparams)
Class Method

source code 

Check the given parameters for validity.

This should check the passed set of parameters for validity. Classes should extend, not replace, this function.

Parameters:
  • hvparams (dict) - dictionary with parameter names/value
Raises:

ValidateParameters(cls, hvparams)
Class Method

source code 

Check the given parameters for validity.

This should check the passed set of parameters for validity. Classes should extend, not replace, this function.

Parameters:
  • hvparams (dict) - dictionary with parameter names/value
Raises:

PowercycleNode(cls, hvparams=None)
Class Method

source code 

Hard powercycle a node using hypervisor specific methods.

This method should hard powercycle the node, using whatever methods the hypervisor provides. Note that this means that all instances running on the node must be stopped too.

Parameters:
  • hvparams (dict of strings) - hypervisor params to be used on this node

GetLinuxNodeInfo(meminfo="/proc/meminfo", cpuinfo="/proc/cpuinfo")
Static Method

source code 

For linux systems, return actual OS information.

This is an abstraction for all non-hypervisor-based classes, where the node actually sees all the memory and CPUs via the /proc interface and standard commands. The other case if for example xen, where you only see the hardware resources via xen-specific tools.

Parameters:
  • meminfo (string) - name of the file containing meminfo
  • cpuinfo (string) - name of the file containing cpuinfo
Returns:
a dict with the following keys (values in MiB):
  • memory_total: the total memory size on the node
  • memory_free: the available memory on the node for instances
  • memory_dom0: the memory used by the node itself, if available
  • cpu_total: total number of CPUs
  • cpu_dom0: number of CPUs used by the node OS
  • cpu_nodes: number of NUMA domains
  • cpu_sockets: number of physical CPU sockets

_FormatVerifyResults(msgs)
Static Method

source code 

Formats the verification results, given a list of errors.

Parameters:
  • msgs - list of errors, possibly empty
Returns:
overall problem description if something is wrong, None otherwise

VerifyHotplugSupport(self, instance, action, dev_type)

source code 

Verifies that hotplug is supported.

Given the target device and hotplug action checks if hotplug is actually supported.

Parameters:
  • instance (objects.Instance) - the instance object
  • action (string) - one of the supported hotplug commands
  • dev_type (string) - one of the supported device types to hotplug
Raises:

HotplugSupported(self, instance)

source code 

Checks if hotplug is supported.

By default is not. Currently only KVM hypervisor supports it.


Class Variable Details [hide private]

PARAMETERS

a dict of parameter name: check type; the check type is a five-tuple containing:
  • the required flag (boolean)
  • a function to check for syntax, that will be used in CheckParameterSyntax, in the master daemon process
  • an error message for the above function
  • a function to check for parameter validity on the remote node, in the ValidateParameters function
  • an error message for the above function
Value:
{}