ganeti :: hypervisor :: hv_lxc :: LXCHypervisor :: Class LXCHypervisor
[hide private]
[frames] | no frames]

Class LXCHypervisor

source code


LXC-based virtualization.

TODO:

Problems/issues:

Instance Methods [hide private]
 
__init__(self)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
ListInstances(self, hvparams=None)
Get the list of running instances.
source code
tuple of strings
GetInstanceInfo(self, instance_name, hvparams=None)
Get instance properties.
source code
 
GetAllInstancesInfo(self, hvparams=None)
Get properties of all instances.
source code
 
_CreateConfigFile(self, instance, root_dir)
Create an lxc.conf file for an instance.
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
 
RebootInstance(self, instance)
Reboot an instance.
source code
 
BalloonInstanceMemory(self, instance, mem)
Balloon an instance memory to a certain value.
source code
 
GetNodeInfo(self, hvparams=None)
Return information about the node.
source code
 
Verify(self, hvparams=None)
Verify the hypervisor.
source code
 
MigrateInstance(self, cluster_name, instance, target, live)
Migrate an instance.
source code
objects.MigrationStatus
GetMigrationStatus(self, instance)
Get the migration status
source code

Inherited from hv_base.BaseHypervisor: AcceptInstance, CleanupInstance, FinalizeMigrationDst, FinalizeMigrationSource, HotAddDevice, HotDelDevice, HotModDevice, HotplugSupported, MigrationInfo, VerifyHotplugSupport

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

Class Methods [hide private]
 
_InstanceDir(cls, instance_name)
Return the root directory for an instance.
source code
 
_InstanceConfFile(cls, instance_name)
Return the configuration file for an instance.
source code
 
_InstanceLogFile(cls, instance_name)
Return the log file for an instance.
source code
 
_GetCgroupMountPoint(cls) source code
 
_GetCgroupCpuList(cls, instance_name)
Return the list of CPU ids for an instance.
source code
 
_GetCgroupMemoryLimit(cls, instance_name)
Return the memory limit for an instance
source code
 
GetInstanceConsole(cls, instance, primary_node, hvparams, beparams)
Return a command for connecting to the console of an instance.
source code
 
PowercycleNode(cls, hvparams=None)
LXC powercycle, just a wrapper over Linux powercycle.
source code

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

Static Methods [hide private]
 
_GetMountSubdirs(path)
Return the list of mountpoints under a given path.
source code

Inherited from hv_base.BaseHypervisor: GetLinuxNodeInfo

Inherited from hv_base.BaseHypervisor (private): _FormatVerifyResults

Class Variables [hide private]
  _ROOT_DIR = pathutils.RUN_DIR+ "/lxc"
  _DEVS = ["c 1:3", "c 1:5", "c 1:7", "c 1:8", "c 1:9", "c 1:10"...
  _DENIED_CAPABILITIES = ["mac_override", "sys_boot", "sys_modul...
  _DIR_MODE = 0755
  PARAMETERS = {constants.HV_CPU_MASK: hv_base.OPT_CPU_MASK_CHECK,}
a dict of parameter name: check type; the check type is a five-tuple containing:

Inherited from hv_base.BaseHypervisor: ANCILLARY_FILES, ANCILLARY_FILES_OPT, CAN_MIGRATE

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

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

Overrides: object.__init__
(inherited documentation)

ListInstances(self, hvparams=None)

source code 

Get the list of running instances.

Overrides: hv_base.BaseHypervisor.ListInstances

GetInstanceInfo(self, instance_name, hvparams=None)

source code 

Get instance properties.

Parameters:
  • instance_name (string) - the instance name
  • hvparams (dict of strings) - hvparams to be used with this instance
Returns: tuple of strings
(name, id, memory, vcpus, stat, times)
Overrides: hv_base.BaseHypervisor.GetInstanceInfo

GetAllInstancesInfo(self, hvparams=None)

source code 

Get properties of all instances.

Parameters:
  • hvparams (dict of strings) - hypervisor parameter
Returns:
[(name, id, memory, vcpus, stat, times),...]
Overrides: hv_base.BaseHypervisor.GetAllInstancesInfo

StartInstance(self, instance, block_devices, startup_paused)

source code 

Start an instance.

For LXC, we try to mount the block device and execute 'lxc-start'. We use volatile containers.

Overrides: hv_base.BaseHypervisor.StartInstance

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

source code 

Stop an instance.

This method has complicated cleanup tests, as we must:

  • try to kill all leftover processes
  • try to unmount any additional sub-mountpoints
  • finally unmount the instance dir
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

RebootInstance(self, instance)

source code 

Reboot an instance.

This is not (yet) implemented (in Ganeti) for the LXC hypervisor.

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

source code 

Return information about the node.

See BaseHypervisor.GetLinuxNodeInfo.

Parameters:
  • hvparams - hypervisor 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
Overrides: hv_base.BaseHypervisor.GetNodeInfo

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

source code 

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

Overrides: hv_base.BaseHypervisor.GetInstanceConsole

Verify(self, hvparams=None)

source code 

Verify the hypervisor.

For the LXC manager, it just checks the existence of the base dir.

Parameters:
  • hvparams (dict of strings) - hypervisor parameters to be verified against; not used here
Returns:
Problem description if something is wrong, None otherwise
Overrides: hv_base.BaseHypervisor.Verify

PowercycleNode(cls, hvparams=None)
Class Method

source code 

LXC powercycle, just a wrapper over Linux powercycle.

Parameters:
  • hvparams (dict of strings) - hypervisor params to be used on this node
Overrides: hv_base.BaseHypervisor.PowercycleNode

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

source code 

Migrate an instance.

Parameters:
  • cluster_name (string) - name of the cluster
  • instance (objects.Instance) - the instance to be migrated
  • target (string) - hostname (usually ip) of the target node
  • live (boolean) - whether to do a live or non-live migration
Overrides: hv_base.BaseHypervisor.MigrateInstance

GetMigrationStatus(self, instance)

source code 

Get the migration status

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

Class Variable Details [hide private]

_DEVS

Value:
["c 1:3", "c 1:5", "c 1:7", "c 1:8", "c 1:9", "c 1:10", "c 5:0", "c 5:\
1", "c 5:2", "c 136:*",]

_DENIED_CAPABILITIES

Value:
["mac_override", "sys_boot", "sys_module", "sys_time",]