class documentation

Abstract virtualisation technology interface

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

Class Method CheckParameterSyntax Check the given parameters for validity.
Class Method GetAncillaryFiles Return a list of ancillary files to be copied to all nodes as ancillary configuration files.
Class Method GetInstanceConsole Return information for connecting to the console of an instance.
Class Method LinuxPowercycle Linux-specific powercycle method.
Class Method PowercycleNode Hard powercycle a node using hypervisor specific methods.
Class Method ValidateParameters Check the given parameters for validity.
Static Method GetLinuxNodeInfo For linux systems, return actual OS information.
Static Method VersionsSafeForMigration Decide if migration between those version is likely to suceed.
Method AcceptInstance Prepare to accept an instance.
Method BalloonInstanceMemory Balloon an instance memory to a certain value.
Method CleanupInstance Cleanup after a stopped instance
Method FinalizeMigrationDst Finalize the instance migration on the target node.
Method FinalizeMigrationSource Finalize the instance migration on the source node.
Method GetAllInstancesInfo Get properties of all instances.
Method GetInstanceInfo Get instance properties.
Method GetMigrationStatus Get the migration status
Method GetNodeInfo Return information about the node.
Method HotAddDevice Hot-add a device.
Method HotDelDevice Hot-del a device.
Method HotModDevice Hot-mod a device.
Method HotplugSupported Checks if hotplug is supported.
Method ListInstances Get the list of running instances.
Method MigrateInstance Migrate an instance.
Method MigrationInfo Get instance information to perform a migration.
Method RebootInstance Reboot an instance.
Method RestoreInstance Fixup running instance's (config) state.
Method StartInstance Start an instance.
Method StopInstance Stop an instance
Method Verify Verify the hypervisor.
Method VerifyHotplugSupport Verifies that hotplug is supported.
Method VerifyInstance Verify if running instance (config) is in correct state.
Constant ANCILLARY_FILES Undocumented
Constant ANCILLARY_FILES_OPT Undocumented
Constant CAN_MIGRATE whether this hypervisor can do migration (either live or non-live)
Constant PARAMETERS a dict of parameter name: check type; the check type is a five-tuple containing:
Class Method _IsParamValueUnspecified Check if the parameter value is a kind of value meaning unspecified.
Static Method _FormatVerifyResults Formats the verification results, given a list of errors.
Method _InstanceStartupMemory Get the correct startup memory for an instance
@classmethod
def CheckParameterSyntax(cls, hvparams):

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:dictdictionary with parameter names/value
Raises
errors.HypervisorErrorwhen a parameter is not valid
@classmethod
def GetAncillaryFiles(cls):

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)
@classmethod
def GetInstanceConsole(cls, instance, primary_node, node_group, hvparams, beparams):
@classmethod
def LinuxPowercycle(cls):

Linux-specific powercycle method.

@classmethod
def PowercycleNode(cls, hvparams=None):

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 stringshypervisor params to be used on this node
@classmethod
def ValidateParameters(cls, hvparams):

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:dictdictionary with parameter names/value
Raises
errors.HypervisorErrorwhen a parameter is not valid
@staticmethod
def GetLinuxNodeInfo(meminfo='/proc/meminfo', cpuinfo='/proc/cpuinfo'):

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:stringname of the file containing meminfo
cpuinfo:stringname 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
@staticmethod
def VersionsSafeForMigration(src, target):

Decide if migration between those version is likely to suceed.

Given two versions of a hypervisor, give a guess whether live migration from the one version to the other version is likely to succeed. The current

def AcceptInstance(self, instance, info, target):

Prepare to accept an instance.

By default assume no preparation is needed.

Parameters
instance:objects.Instanceinstance to be accepted
info:string/data (opaque)migration information, from the source node
target:stringtarget host (usually ip), on this node
def BalloonInstanceMemory(self, instance, mem):

Balloon an instance memory to a certain value.

Parameters
instance:objects.Instanceinstance to be accepted
mem:intactual memory size to use for instance runtime
def CleanupInstance(self, instance_name):

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:stringinstance name to cleanup after
def FinalizeMigrationDst(self, instance, info, success):

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.Instanceinstance whose migration is being finalized
info:string/data (opaque)migration information, from the source node
success:booleanwhether the migration was a success or a failure
def FinalizeMigrationSource(self, instance, success, live):

Finalize the instance migration on the source node.

Parameters
instance:objects.Instancethe instance that was migrated
success:boolwhether the migration succeeded or not
live:boolwhether the user requested a live migration or not
def GetAllInstancesInfo(self, hvparams=None):

Get properties of all instances.

Parameters
hvparams:dict of stringshypervisor parameter
Returns
(string, string, int, int, HvInstanceState, int)list of tuples (name, id, memory, vcpus, state, times)
def GetInstanceInfo(self, instance_name, hvparams=None):

Get instance properties.

Parameters
instance_name:stringthe instance name
hvparams:dict of stringshvparams to be used with this instance
Returns
(string, string, int, int, HvInstanceState, int)tuple (name, id, memory, vcpus, state, times)
def GetMigrationStatus(self, instance):

Get the migration status

Parameters
instance:objects.Instancethe instance that is being migrated
Returns
objects.MigrationStatusthe status of the current migration (one of constants.HV_MIGRATION_VALID_STATUSES), plus any additional progress info that can be retrieved from the hypervisor
def GetNodeInfo(self, hvparams=None):

Return information about the node.

Parameters
hvparams:dict of stringshypervisor 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
def HotAddDevice(self, instance, dev_type, device, extra, seq):

Hot-add a device.

def HotDelDevice(self, instance, dev_type, device, extra, seq):

Hot-del a device.

def HotModDevice(self, instance, dev_type, device, extra, seq):

Hot-mod a device.

def HotplugSupported(self, instance):

Checks if hotplug is supported.

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

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

Migrate an instance.

Parameters
cluster_name:stringname of the cluster
instance:objects.Instancethe instance to be migrated
target:stringhostname (usually ip) of the target node
live:booleanwhether to do a live or non-live migration
def MigrationInfo(self, instance):

Get instance information to perform a migration.

By default assume no information is needed.

Parameters
instance:objects.Instanceinstance to be migrated
Returns
string/data (opaque)instance migration information - serialized form
def RestoreInstance(self, instance, block_devices):

Fixup running instance's (config) state.

Parameters
instance:objects.Instanceinstance to restore
block_devices:list of tuples (disk_object, link_name, drive_uri)blockdevices assigned to this instance
def StartInstance(self, instance, block_devices, startup_paused):

Start an instance.

Parameters
instance:objects.Instanceinstance to start
block_devices:list of tuples (disk_object, link_name, drive_uri)blockdevices assigned to this instance
startup_paused:boolif instance should be paused at startup
def StopInstance(self, instance, force=False, retry=False, name=None, timeout=None):

Stop an instance

Parameters
instance:objects.Instanceinstance to stop
force:booleanwhether to do a "hard" stop (destroy)
retry:booleanwhether this is just a retry call
name:string or Noneif 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 Noneif 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
Raises
errors.HypervisorErrorwhen a parameter is not valid or the instance failed to be stopped
def Verify(self, hvparams=None):

Verify the hypervisor.

Parameters
hvparams:dict of stringshypervisor parameters to be verified against
Returns
Problem description if something is wrong, None otherwise
def VerifyHotplugSupport(self, instance, action, dev_type):

Verifies that hotplug is supported.

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

Parameters
instance:objects.Instancethe instance object
action:stringone of the supported hotplug commands
dev_type:stringone of the supported device types to hotplug
Raises
errors.HotplugErrorif hotplugging is not supported
def VerifyInstance(self, instance):

Verify if running instance (config) is in correct state.

Parameters
instance:objects.Instanceinstance to verify
Returns
bool, if instance in correct state
ANCILLARY_FILES: list =
ANCILLARY_FILES_OPT: list =
CAN_MIGRATE: boolean =

whether this hypervisor can do migration (either live or non-live)

Value
False
PARAMETERS: dict =

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
{}
@classmethod
def _IsParamValueUnspecified(cls, param_value):

Check if the parameter value is a kind of value meaning unspecified.

This function checks if the parameter value is a kind of value meaning unspecified.

Parameters
param_value:anythe parameter value that needs to be checked
Returns
boolTrue if the parameter value is a kind of value meaning unspecified, False otherwise
@staticmethod
def _FormatVerifyResults(msgs):

Formats the verification results, given a list of errors.

Parameters
msgslist of errors, possibly empty
Returns
overall problem description if something is wrong, None otherwise
def _InstanceStartupMemory(self, instance):

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
instance:objects.Instancethe instance that is being started
Returns
integermemory the instance should be started with