ganeti :: hypervisor :: hv_xen :: XenHypervisor :: Class XenHypervisor
[hide private]
[frames] | no frames]

Class XenHypervisor

source code


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.

Instance Methods [hide private]
 
ListInstances(self)
Get the list of running instances.
source code
 
GetInstanceInfo(self, instance_name)
Get instance properties.
source code
 
GetAllInstancesInfo(self)
Get properties of all instances.
source code
 
StartInstance(self, instance, block_devices, startup_paused)
Start an instance.
source code
 
StopInstance(self, instance, force=False, retry=False, name=None)
Stop an instance.
source code
 
RebootInstance(self, instance)
Reboot an instance.
source code
 
BalloonInstanceMemory(self, instance, mem)
Balloon an instance memory to a certain value.
source code
 
GetNodeInfo(self)
Return information about the node.
source code
 
Verify(self)
Verify the hypervisor.
source code
string
MigrationInfo(self, instance)
Get instance information to perform a migration.
source code
 
AcceptInstance(self, instance, info, target)
Prepare to accept an instance.
source code
 
FinalizeMigrationDst(self, instance, info, success)
Finalize an instance migration.
source code
 
MigrateInstance(self, instance, target, live)
Migrate an instance to a target node.
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

Inherited from hv_base.BaseHypervisor: CleanupInstance

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

Class Methods [hide private]
 
_WriteConfigFile(cls, instance, startup_memory, block_devices)
Write the Xen config file for the instance.
source code
 
_GetXMList(cls, include_node)
Return the list of running instances.
source code
 
GetInstanceConsole(cls, instance, hvparams, beparams)
Return a command for connecting to the console of an instance.
source code
 
PowercycleNode(cls)
Xen-specific powercycle.
source code

Inherited from hv_base.BaseHypervisor: CheckParameterSyntax, GetAncillaryFiles, LinuxPowercycle, ValidateParameters

Static Methods [hide private]
str
_ConfigFileName(instance_name)
Get the config file name for an instance.
source code
 
_WriteConfigFileStatic(instance_name, data)
Write the Xen config file for the instance.
source code
 
_ReadConfigFile(instance_name)
Returns the contents of the instance config file.
source code
 
_RemoveConfigFile(instance_name)
Remove the xen configuration file.
source code
 
_RunXmList(xmlist_errors)
Helper function for _GetXMList to run "xm list".
source code
 
_GetConfigFileDiskData(block_devices, blockdev_prefix)
Get disk directive for xen config file.
source code

Inherited from hv_base.BaseHypervisor: GetLinuxNodeInfo

Inherited from hv_base.BaseHypervisor (private): _FormatVerifyResults

Class Variables [hide private]
boolean CAN_MIGRATE = True
whether this hypervisor can do migration (either live or non-live)
  REBOOT_RETRY_COUNT = 60
  REBOOT_RETRY_INTERVAL = 10
  ANCILLARY_FILES = [XEND_CONFIG_FILE, XL_CONFIG_FILE, VIF_BRIDG...
  ANCILLARY_FILES_OPT = [XL_CONFIG_FILE,]

Inherited from hv_base.BaseHypervisor: PARAMETERS

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

_ConfigFileName(instance_name)
Static Method

source code 

Get the config file name for an instance.

Parameters:
  • instance_name (str) - instance name
Returns: str
fully qualified path to instance config file

_WriteConfigFileStatic(instance_name, data)
Static Method

source code 

Write the Xen config file for the instance.

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

_GetXMList(cls, include_node)
Class Method

source code 

Return the list of running instances.

If the include_node argument is True, then we return information for dom0 also, otherwise we filter that from the return value.

Returns:
list of (name, id, memory, vcpus, state, time spent)

ListInstances(self)

source code 

Get the list of running instances.

Overrides: hv_base.BaseHypervisor.ListInstances

GetInstanceInfo(self, instance_name)

source code 

Get instance properties.

Parameters:
  • instance_name - the instance name
Returns:
tuple (name, id, memory, vcpus, stat, times)
Overrides: hv_base.BaseHypervisor.GetInstanceInfo

GetAllInstancesInfo(self)

source code 

Get properties of all instances.

Returns:
list of tuples (name, id, memory, vcpus, stat, times)
Overrides: hv_base.BaseHypervisor.GetAllInstancesInfo

StartInstance(self, instance, block_devices, startup_paused)

source code 

Start an instance.

Overrides: hv_base.BaseHypervisor.StartInstance

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

source code 

Stop an instance.

Parameters:
  • instance - instance to stop
  • force - whether to do a "hard" stop (destroy)
  • retry - whether this is just a retry call
  • name - 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
Overrides: hv_base.BaseHypervisor.StopInstance

RebootInstance(self, instance)

source code 

Reboot an instance.

Overrides: hv_base.BaseHypervisor.RebootInstance

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
Overrides: hv_base.BaseHypervisor.BalloonInstanceMemory

GetNodeInfo(self)

source code 

Return information about the node.

Returns:
a dict with 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
  • nr_cpus: total number of CPUs
  • nr_nodes: in a NUMA system, the number of domains
  • nr_sockets: the number of physical CPU sockets in the node
  • hv_version: the hypervisor version in the form (major, minor)
Overrides: hv_base.BaseHypervisor.GetNodeInfo

GetInstanceConsole(cls, instance, hvparams, beparams)
Class Method

source code 

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

Overrides: hv_base.BaseHypervisor.GetInstanceConsole

Verify(self)

source code 

Verify the hypervisor.

For Xen, this verifies that the xend process is running.

Returns:
Problem description if something is wrong, None otherwise
Overrides: hv_base.BaseHypervisor.Verify

_GetConfigFileDiskData(block_devices, blockdev_prefix)
Static Method

source code 

Get disk directive for xen config file.

This method builds the xen config disk directive according to the given disk_template and block_devices.

Parameters:
  • block_devices - list of tuples (cfdev, rldev):
    • cfdev: dict containing ganeti config disk part
    • rldev: ganeti.bdev.BlockDev object
  • blockdev_prefix - a string containing blockdevice prefix, e.g. "sd" for /dev/sda
Returns:
string containing disk directive for xen instance config file

MigrationInfo(self, instance)

source code 

Get instance information to perform a migration.

Parameters:
Returns: string
content of the xen config file
Overrides: hv_base.BaseHypervisor.MigrationInfo

AcceptInstance(self, instance, info, target)

source code 

Prepare to accept an instance.

Parameters:
  • instance (objects.Instance) - instance to be accepted
  • info (string) - content of the xen config file on the source node
  • target (string) - target host (usually ip), on this node
Overrides: hv_base.BaseHypervisor.AcceptInstance

FinalizeMigrationDst(self, instance, info, success)

source code 

Finalize an instance migration.

After a successful migration we write the xen config file. We do nothing on a failure, as we did not change anything at accept time.

Parameters:
  • instance (objects.Instance) - instance whose migration is being finalized
  • info (string) - content of the xen config file on the source node
  • success (boolean) - whether the migration was a success or a failure
Overrides: hv_base.BaseHypervisor.FinalizeMigrationDst

MigrateInstance(self, instance, target, live)

source code 

Migrate an instance to a target node.

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

Parameters:
  • instance (objects.Instance) - the instance to be migrated
  • target (string) - ip address of the target node
  • live (boolean) - perform a live migration
Overrides: hv_base.BaseHypervisor.MigrateInstance

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
Overrides: hv_base.BaseHypervisor.FinalizeMigrationSource

GetMigrationStatus(self, instance)

source code 

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:
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
Overrides: hv_base.BaseHypervisor.GetMigrationStatus

PowercycleNode(cls)
Class Method

source code 

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.

Overrides: hv_base.BaseHypervisor.PowercycleNode

Class Variable Details [hide private]

ANCILLARY_FILES

Value:
[XEND_CONFIG_FILE, XL_CONFIG_FILE, VIF_BRIDGE_SCRIPT,]