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]
 
__init__(self, _cfgdir=None, _run_cmd_fn=None, _cmd=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
_GetCommand(self)
Returns Xen command to use.
source code
 
_RunXen(self, args, timeout=None)
Wrapper around utils.process.RunCmd to run Xen command.
source code
str
_ConfigFileName(self, instance_name)
Get the config file name for an instance.
source code
 
_WriteConfigFile(self, instance_name, data)
Write the Xen config file for the instance.
source code
 
_ReadConfigFile(self, instance_name)
Returns the contents of the instance config file.
source code
 
_RemoveConfigFile(self, instance_name)
Remove the xen configuration file.
source code
 
_StashConfigFile(self, instance_name)
Move the Xen config file to the log directory and return its new path.
source code
 
_GetXmList(self, include_node)
Wrapper around module level _GetXmList.
source code
 
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
 
_MakeConfigFile(self, instance, startup_memory, block_devices)
Gather configuration details and write to disk.
source code
 
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
 
_ShutdownInstance(self, name, timeout)
Shutdown an instance if the instance is running.
source code
 
_DestroyInstance(self, name)
Destroy an instance if the instance if the instance exists.
source code
 
_StopInstance(self, name, force, timeout)
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
 
_MigrateInstance(self, cluster_name, instance_name, target, port, live, _ping_fn=netutils.TcpPing)
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__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods [hide private]
 
_GetConfig(cls, instance, startup_memory, block_devices)
Build Xen configuration for an instance.
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]

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]

__init__(self, _cfgdir=None, _run_cmd_fn=None, _cmd=None)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

_RunXen(self, args, timeout=None)

source code 

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

If a timeout (in seconds) is specified, the command will be terminated after that number of seconds.

_ConfigFileName(self, instance_name)

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

_WriteConfigFile(self, instance_name, data)

source code 

Write the Xen config file for the instance.

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

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

_MakeConfigFile(self, instance, startup_memory, block_devices)

source code 

Gather configuration details and write to disk.

See _GetConfig for arguments.

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, timeout=None)

source code 

Stop an instance.

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

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
  • timeout - 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
Overrides: hv_base.BaseHypervisor.StopInstance

_ShutdownInstance(self, name, timeout)

source code 

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 (string) - name of the instance to stop
  • timeout (int or None) - a timeout after which the shutdown command should be killed, or None for no timeout

_DestroyInstance(self, name)

source code 

Destroy an instance if the instance if the instance exists.

Parameters:
  • name (string) - name of the instance to destroy

_StopInstance(self, name, force, timeout)

source code 

Stop an instance.

Parameters:
  • name (string) - name of the instance to destroy
  • force (boolean) - whether to do a "hard" stop (destroy)
  • timeout (int or None) - a timeout after which the shutdown command should be killed, or None for no timeout

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

See Also: _GetNodeInfo and _ParseNodeInfo

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

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

_MigrateInstance(self, cluster_name, instance_name, target, port, live, _ping_fn=netutils.TcpPing)

source code 

Migrate an instance to a target node.

See Also: MigrateInstance for details

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,]