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
 
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
 
FinalizeMigration(self, instance, info, success)
Finalize an instance migration.
source code
 
MigrateInstance(self, instance, target, live)
Migrate an instance to a target node.
source code

Inherited from hv_base.BaseHypervisor: CleanupInstance, __init__

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

Class Methods [hide private]
 
_WriteConfigFile(cls, instance, 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]
 
_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

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 = ["/etc/xen/xend-config.sxp", "/etc/xen/scrip...

Inherited from hv_base.BaseHypervisor: PARAMETERS

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

_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

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
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.

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

FinalizeMigration(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.FinalizeMigration

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

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:
["/etc/xen/xend-config.sxp", "/etc/xen/scripts/vif-bridge",]