class documentation

Xen generic hypervisor interface

This is the Xen base class used for both Xen PVM and HVM. It contains all the functionality that is identical for both.

Class Method GetInstanceConsole Return a command for connecting to the console of an instance.
Static Method VersionsSafeForMigration Decide if migration is likely to suceed for hypervisor versions.
Method __init__ Undocumented
Method AcceptInstance Prepare to accept an instance.
Method BalloonInstanceMemory Balloon an instance memory to a certain value.
Method FinalizeMigrationDst Finalize an instance migration.
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 ListInstances Get the list of running instances.
Method MigrateInstance Migrate an instance to a target node.
Method MigrationInfo Get instance information to perform a migration.
Method PowercycleNode Xen-specific powercycle.
Method RebootInstance Reboot an instance.
Method RestoreInstance Fixup running instance's state.
Method StartInstance Start an instance.
Method StopInstance Stop an instance.
Method Verify Verify the hypervisor.
Method VerifyInstance Verify if running instance (configuration) is in correct state.
Constant ANCILLARY_FILES Undocumented
Constant ANCILLARY_FILES_OPT Undocumented
Constant CAN_MIGRATE Undocumented
Constant REBOOT_RETRY_COUNT Undocumented
Constant REBOOT_RETRY_INTERVAL Undocumented
Class Method _EnsureDirs Makes sure that the directories needed by the hypervisor exist.
Class Method _GetConfig Build Xen configuration for an instance.
Class Method _InstanceMigrationPidfile Returns the name of the pid file for a socat process used to migrate.
Class Method _InstanceNICDir Returns the directory holding the tap device files for a given instance.
Class Method _InstanceNICFile Returns the name of the file containing the tap device for a given NIC
Class Method _KillMigrationDaemon Kills the migration daemon if present.
Class Method _WriteNICInfoFile Write the Xen config file for the instance.
Method _CheckToolstackXlConfigured Checks whether xl is enabled on an xl-capable node.
Method _ConfigFileName Get the config file name for an instance.
Method _DestroyInstance Destroy an instance if the instance exists.
Method _DestroyInstanceIfAlive Undocumented
Method _GetInstanceList Wrapper around module level _GetAllInstanceList.
Method _MakeConfigFile Gather configuration details and write to disk.
Method _MigrateInstance Migrate an instance to a target node.
Method _ReadConfigFile Returns the contents of the instance config file.
Method _RemoveConfigFile Remove the xen configuration file.
Method _RenameInstance Rename an instance (domain).
Method _RunXen Wrapper around utils.process.RunCmd to run Xen command.
Method _ShutdownInstance Shutdown an instance if the instance is running.
Method _StashConfigFile Move the Xen config file to the log directory and return its new path.
Method _StopInstance Stop an instance.
Method _WriteConfigFile Write the Xen config file for the instance.
Method _WriteNicConfig Undocumented
Constant _DIRS Undocumented
Constant _INSTANCE_LIST_DELAYS Undocumented
Constant _INSTANCE_LIST_TIMEOUT Undocumented
Constant _MIGRATION_DIR Undocumented
Constant _NICS_DIR Undocumented
Constant _ROOT_DIR Undocumented
Instance Variable _cfgdir Undocumented
Instance Variable _cmd Undocumented
Instance Variable _run_cmd_fn Undocumented

Inherited from BaseHypervisor:

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 LinuxPowercycle Linux-specific powercycle method.
Class Method ValidateParameters Check the given parameters for validity.
Static Method GetLinuxNodeInfo For linux systems, return actual OS information.
Method CleanupInstance Cleanup after a stopped instance
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 VerifyHotplugSupport Verifies that hotplug is supported.
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 GetInstanceConsole(cls, instance, primary_node, node_group, hvparams, beparams):

Return a command for connecting to the console of an instance.

@staticmethod
def VersionsSafeForMigration(src, target):

Decide if migration is likely to suceed for hypervisor versions.

Given two versions of a hypervisor, give a guess whether live migration from the one version to the other version is likely to succeed. For Xen, the heuristics is, that an increase by one on the second digit is OK. This fits with the current numbering scheme.

Parameters
src:list or tupleUndocumented
target:list or tupleUndocumented
Returns
boolUndocumented
def __init__(self, _cfgdir=None, _run_cmd_fn=None, _cmd=None):

Undocumented

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

Prepare to accept an instance.

Parameters
instance:objects.Instanceinstance to be accepted
info:stringcontent of the xen config file on 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 FinalizeMigrationDst(self, instance, config, success):

Finalize an instance migration.

Write a config file if the instance is running on the destination node regardles if we think the migration succeeded or not. This will cover cases, when the migration succeeded but due to a timeout on the source node we think it failed. If we think the migration failed and there is an unstarted domain, clean it up.

Parameters
instance:objects.Instanceinstance whose migration is being finalized
config:stringcontent of the xen config file from the source node
success:booleanwhether the master node thinks the migration succeeded
def FinalizeMigrationSource(self, instance, success, _):

Finalize the instance migration on the source node.

Parameters
instance:objects.Instancethe instance that was migrated
success:boolwhether the master thinks the migration succeeded
_Undocumented
def GetAllInstancesInfo(self, hvparams=None):

Get properties of all instances.

Parameters
hvparams:dict of stringshypervisor parameters
Returns
(string, string, int, int, HypervisorInstanceState, 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 stringsthe instance's hypervisor params
Returns
tuple (name, id, memory, vcpus, stat, times)
def GetMigrationStatus(self, instance):

Get the migration status

As MigrateInstance for Xen is still blocking, if this method is called it means that MigrateInstance has completed successfully. So we can safely assume that the migration was successful and notify this fact to the client.

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.

See Also
_GetNodeInfo and _ParseNodeInfo
def ListInstances(self, hvparams=None):

Get the list of running instances.

Parameters
hvparams:dict of stringsthe instance's hypervisor params
Returns
list of stringsnames of running instances
def MigrateInstance(self, _cluster_name, instance, target, live):

Migrate an instance to a target node.

The migration will not be attempted if the instance is not currently running.

Parameters
_cluster_nameUndocumented
instance:objects.Instancethe instance to be migrated
target:stringip address of the target node
live:booleanperform a live migration
def MigrationInfo(self, instance):

Get instance information to perform a migration.

Parameters
instance:objects.Instanceinstance to be migrated
Returns
stringcontent of the xen config file
def PowercycleNode(self, hvparams=None):

Xen-specific powercycle.

This first does a Linux reboot (which triggers automatically a Xen reboot), and if that fails it tries to do a Xen reboot. The reason we don't try a Xen reboot first is that the xen reboot launches an external command which connects to the Xen hypervisor, and that won't work in case the root filesystem is broken and/or the xend daemon is not working.

Parameters
hvparams:dict of stringshypervisor params to be used on this node
def RebootInstance(self, instance):
def RestoreInstance(self, instance, block_devices):

Fixup running instance's 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 (cfdev, rldev)

  • cfdev: dict containing ganeti config disk part
  • rldev: ganeti.block.bdev.BlockDev object
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.

A soft shutdown can be interrupted. A hard shutdown tries forever.

def Verify(self, hvparams=None):

Verify the hypervisor.

For Xen, this verifies that the XL toolstack is present and functional

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

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

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

Undocumented

Value
True
REBOOT_RETRY_COUNT: int =

Undocumented

Value
60
REBOOT_RETRY_INTERVAL: int =

Undocumented

Value
10
@classmethod
def _EnsureDirs(cls, extra_dirs=None):

Makes sure that the directories needed by the hypervisor exist.

Parameters
extra_dirs:list of string or NoneAdditional directories which ought to exist.
@classmethod
def _GetConfig(cls, instance, startup_memory, block_devices):

Build Xen configuration for an instance.

@classmethod
def _InstanceMigrationPidfile(cls, _instance_name):

Returns the name of the pid file for a socat process used to migrate.

@classmethod
def _InstanceNICDir(cls, instance_name):

Returns the directory holding the tap device files for a given instance.

@classmethod
def _InstanceNICFile(cls, instance_name, seq):

Returns the name of the file containing the tap device for a given NIC

@classmethod
def _KillMigrationDaemon(cls, instance):

Kills the migration daemon if present.

@classmethod
def _WriteNICInfoFile(cls, instance, idx, nic):

Write the Xen config file for the instance.

This version of the function just writes the config file from static data.

def _CheckToolstackXlConfigured(self):

Checks whether xl is enabled on an xl-capable node.

Returns
boolTrue if 'xl' is enabled, False otherwise
def _ConfigFileName(self, instance_name):

Get the config file name for an instance.

Parameters
instance_name:strinstance name
Returns
strfully qualified path to instance config file
def _DestroyInstance(self, name, hvparams):

Destroy an instance if the instance exists.

Parameters
name:stringname of the instance to destroy
hvparams:dict of stringhypervisor parameters of the instance
def _DestroyInstanceIfAlive(self, name, hvparams):

Undocumented

def _GetInstanceList(self, include_node):

Wrapper around module level _GetAllInstanceList.

def _MakeConfigFile(self, instance, startup_memory, block_devices):

Gather configuration details and write to disk.

See _GetConfig for arguments.

def _MigrateInstance(self, instance_name, target, port, hvparams, _ping_fn=netutils.TcpPing):

Migrate an instance to a target node.

See Also
MigrateInstance for details
def _ReadConfigFile(self, instance_name):

Returns the contents of the instance config file.

def _RemoveConfigFile(self, instance_name):

Remove the xen configuration file.

def _RenameInstance(self, old_name, new_name):

Rename an instance (domain).

Parameters
old_name:stringcurrent name of the instance
new_name:stringfuture (requested) name of the instace
def _RunXen(self, args, timeout=None):

Wrapper around utils.process.RunCmd to run Xen command.

Parameters
argsUndocumented
timeout:int or Noneif a timeout (in seconds) is specified, the command will be terminated after that number of seconds.
See Also
utils.process.RunCmd
def _ShutdownInstance(self, name, hvparams, timeout):

Shutdown an instance if the instance is running.

The '-w' flag waits for shutdown to complete which avoids the need to poll in the case where we want to destroy the domain immediately after shutdown.

Parameters
name:stringname of the instance to stop
hvparams:dict of stringhypervisor parameters of the instance
timeout:int or Nonea timeout after which the shutdown command should be killed, or None for no timeout
def _StashConfigFile(self, instance_name):

Move the Xen config file to the log directory and return its new path.

def _StopInstance(self, name, force, hvparams, timeout):

Stop an instance.

Parameters
name:stringname of the instance to destroy
force:booleanwhether to do a "hard" stop (destroy)
hvparams:dict of stringhypervisor parameters of the instance
timeout:int or Nonea timeout after which the shutdown command should be killed, or None for no timeout
def _WriteConfigFile(self, instance_name, data):

Write the Xen config file for the instance.

This version of the function just writes the config file from static data.

def _WriteNicConfig(self, config, instance, hvp):

Undocumented

_DIRS =

Undocumented

Value
[_ROOT_DIR, _NICS_DIR, _MIGRATION_DIR]
_INSTANCE_LIST_DELAYS: tuple[float, ...] =

Undocumented

Value
(0.3, 1.5, 1.0)
_INSTANCE_LIST_TIMEOUT: int =

Undocumented

Value
5
_MIGRATION_DIR =

Undocumented

Value
_ROOT_DIR+'/migration'
_NICS_DIR =

Undocumented

Value
_ROOT_DIR+'/nic'
_ROOT_DIR =

Undocumented

Value
pathutils.RUN_DIR+'/xen-hypervisor'
_cfgdir =

Undocumented

_cmd =

Undocumented

_run_cmd_fn =

Undocumented