class documentation

LXC-based virtualization.

Class Method GetInstanceConsole Return a command for connecting to the console of an instance.
Class Method PowercycleNode LXC powercycle, just a wrapper over Linux powercycle.
Method __init__ Undocumented
Method BalloonInstanceMemory Balloon an instance memory to a certain value.
Method CleanupInstance Cleanup after a stopped instance.
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.
Method RebootInstance Reboot an instance.
Method StartInstance Start an instance.
Method StopInstance Stop an instance.
Method Verify Verify the hypervisor.
Constant PARAMETERS Undocumented
Class Method _EnsureCgroupMounts Ensures all cgroup subsystems required to run LXC container are mounted.
Class Method _GetCgroupCpuList Return the list of CPU ids for an instance.
Class Method _GetCgroupCpuUsage Return the CPU usage of an instance.
Class Method _GetCgroupEnabledKernelSubsystems Return cgroup subsystems list that are enabled in current kernel.
Class Method _GetCgroupInstanceValue Return the value of the specified cgroup parameter.
Class Method _GetCgroupMemoryLimit Return the memory limit for an instance
Class Method _GetCgroupMountPoint Return the directory that should be the base of cgroup fs.
Class Method _GetCgroupParamPath Return the path of the specified cgroup parameter file.
Class Method _GetCgroupSubsysDir Return the directory of the cgroup subsystem we use.
Class Method _GetCurrentCgroupSubsysGroups Return the dict of cgroup subsystem hierarchies this process belongs to.
Class Method _GetInstanceDropCapabilities Get and parse the drop capabilities list from the instance hvparams.
Class Method _GetLXCVersionFromCmd Return the LXC version currently used in the system.
Class Method _GetOrPrepareCgroupSubsysMountPoint Prepare cgroup subsystem mount point.
Class Method _InstanceConfFilePath Return the configuration file for an instance.
Class Method _InstanceConsoleLogFilePath Return the console log file path for an instance.
Class Method _InstanceDir Return the root directory for an instance.
Class Method _InstanceLogFilePath Return the log file for an instance.
Class Method _InstanceStashFilePath Return the stash file path for an instance.
Class Method _IsCgroupParameterPresent Return whether a cgroup parameter can be used.
Class Method _IsInstanceAlive Return True if instance is alive.
Class Method _ListAliveInstances Return list of alive instances.
Class Method _MountCgroupSubsystem Mount the cgroup subsystem fs under the cgroup root dir.
Class Method _PrepareInstanceRootFsBdev Return mountable path for storage_path.
Class Method _SetCgroupInstanceValue Set the value to the specified instance cgroup parameter.
Class Method _VerifyDiskRequirements Insures that the disks provided work with the current implementation.
Class Method _VerifyLXCCommands Verify the validity of lxc command line tools.
Class Method _WaitForInstanceState Wait for an instance state transition within timeout
Method _CleanupInstance Actual implementation of the instance cleanup procedure.
Method _CreateConfigFile Create an lxc.conf file for an instance.
Method _EnsureDirectoryExistence Ensures all the directories needed for LXC use exist.
Method _GetInstanceInfoInner Get instance properties.
Method _LoadInstanceStash Load information stashed in file which was created by _SaveInstanceStash.
Method _SaveInstanceStash Save data to the instance stash file in serialized format.
Method _SpawnLXC Execute lxc-start and wait until container health is confirmed.
Constant _CGROUP_ROOT_DIR Undocumented
Constant _DIR_MODE Undocumented
Constant _INSTANCE_DIR Undocumented
Constant _LOG_DIR Undocumented
Constant _LXC_COMMANDS_REQUIRED Undocumented
Constant _LXC_MIN_VERSION_REQUIRED Undocumented
Constant _MEMORY_PARAMETER Undocumented
Constant _MEMORY_SWAP_PARAMETER Undocumented
Constant _PROC_CGROUPS_FILE Undocumented
Constant _PROC_SELF_CGROUP_FILE Undocumented
Constant _REBOOT_TIMEOUT Undocumented
Constant _REQUIRED_CGROUP_SUBSYSTEMS Undocumented
Constant _ROOT_DIR Undocumented
Constant _STASH_KEY_ALLOCATED_LOOP_DEV 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.
Static Method VersionsSafeForMigration Decide if migration between those version is likely to suceed.
Method AcceptInstance Prepare to accept an instance.
Method FinalizeMigrationDst Finalize the instance migration on the target node.
Method FinalizeMigrationSource Finalize the instance migration on the source node.
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 MigrationInfo Get instance information to perform a migration.
Method RestoreInstance Fixup running instance's (config) state.
Method VerifyHotplugSupport Verifies that hotplug is supported.
Method VerifyInstance Verify if running instance (config) is in correct state.
Constant ANCILLARY_FILES Undocumented
Constant ANCILLARY_FILES_OPT Undocumented
Constant CAN_MIGRATE whether this hypervisor can do migration (either live or non-live)
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.

@classmethod
def PowercycleNode(cls, hvparams=None):

LXC powercycle, just a wrapper over Linux powercycle.

Parameters
hvparams:dict of stringshypervisor params to be used on this node
def __init__(self):

Undocumented

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 CleanupInstance(self, instance_name):

Cleanup after a stopped instance.

def GetAllInstancesInfo(self, hvparams=None):

Get properties of all instances.

Parameters
hvparams:dict of stringshypervisor parameter
Returns
[(name, id, memory, vcpus, stat, times),...]
def GetInstanceInfo(self, instance_name, hvparams=None):

Get instance properties.

Parameters
instance_name:stringthe instance name
hvparams:dict of stringshvparams to be used with this instance
Returns
tuple of strings(name, id, memory, vcpus, stat, times)
def GetMigrationStatus(self, instance):

Get the migration status

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):
def ListInstances(self, hvparams=None):

Get the list of running instances.

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

Migrate an instance.

Parameters
cluster_name:stringname of the cluster
instance:objects.Instancethe instance to be migrated
target:stringhostname (usually ip) of the target node
live:booleanwhether to do a live or non-live migration
def RebootInstance(self, instance):
def StartInstance(self, instance, block_devices, startup_paused):

Start an instance.

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

def StopInstance(self, instance, force=False, retry=False, name=None, timeout=None):
def Verify(self, hvparams=None):

Verify the hypervisor.

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

Parameters
hvparams:dict of stringshypervisor parameters to be verified against; not used here
Returns
Problem description if something is wrong, None otherwise
@classmethod
def _EnsureCgroupMounts(cls, hvparams=None):

Ensures all cgroup subsystems required to run LXC container are mounted.

@classmethod
def _GetCgroupCpuList(cls, instance_name):

Return the list of CPU ids for an instance.

@classmethod
def _GetCgroupCpuUsage(cls, instance_name):

Return the CPU usage of an instance.

@classmethod
def _GetCgroupEnabledKernelSubsystems(cls):

Return cgroup subsystems list that are enabled in current kernel.

@classmethod
def _GetCgroupInstanceValue(cls, instance_name, param_name):

Return the value of the specified cgroup parameter.

Parameters
instance_name:stringinstance name
param_name:stringcgroup subsystem parameter name @rtype string @return value read from cgroup subsystem fs
@classmethod
def _GetCgroupMemoryLimit(cls, instance_name):

Return the memory limit for an instance

@classmethod
def _GetCgroupMountPoint(cls):

Return the directory that should be the base of cgroup fs.

@classmethod
def _GetCgroupParamPath(cls, param_name, instance_name=None):

Return the path of the specified cgroup parameter file.

Parameters
param_name:stringcgroup subsystem parameter name
instance_nameUndocumented
Returns
stringpath of the cgroup subsystem parameter file
@classmethod
def _GetCgroupSubsysDir(cls, subsystem):

Return the directory of the cgroup subsystem we use.

Parameters
subsystem:stringcgroup subsystem name
Returns
stringpath of the hierarchy directory for the subsystem
@classmethod
def _GetCurrentCgroupSubsysGroups(cls):

Return the dict of cgroup subsystem hierarchies this process belongs to.

The dictionary has the cgroup subsystem as a key and its hierarchy as a value. Information is read from /proc/self/cgroup.

@classmethod
def _GetInstanceDropCapabilities(cls, hvparams):

Get and parse the drop capabilities list from the instance hvparams.

Parameters
hvparams:dict of stringsinstance hvparams @rtype list(string) @return list of drop capabilities
@classmethod
def _GetLXCVersionFromCmd(cls, from_cmd):

Return the LXC version currently used in the system.

Version information will be retrieved by command specified by from_cmd.

Parameters
from_cmd:stringthe lxc command used to retrieve version information
Returns
LXCVersiona version object which represents the version retrieved from the command
@classmethod
def _GetOrPrepareCgroupSubsysMountPoint(cls, subsystem):

Prepare cgroup subsystem mount point.

Parameters
subsystem:stringcgroup subsystem name to mount @rtype string @return path of subsystem mount point
@classmethod
def _InstanceConfFilePath(cls, instance_name):

Return the configuration file for an instance.

@classmethod
def _InstanceConsoleLogFilePath(cls, instance_name):

Return the console log file path for an instance.

@classmethod
def _InstanceDir(cls, instance_name):

Return the root directory for an instance.

@classmethod
def _InstanceLogFilePath(cls, instance):

Return the log file for an instance.

Parameters
instance:objects.InstanceUndocumented
@classmethod
def _InstanceStashFilePath(cls, instance_name):

Return the stash file path for an instance.

The stash file is used to keep information needed to clean up after the destruction of the instance.

@classmethod
def _IsCgroupParameterPresent(cls, parameter, hvparams=None):

Return whether a cgroup parameter can be used.

This is checked by seeing whether there is a file representation of the parameter in the location where the cgroup is mounted.

Parameters
parameter:stringThe name of the parameter.
hvparamsThe hypervisor parameters, optional.
Returns
booleanUndocumented
@classmethod
def _IsInstanceAlive(cls, instance_name):

Return True if instance is alive.

@classmethod
def _ListAliveInstances(cls):

Return list of alive instances.

@classmethod
def _MountCgroupSubsystem(cls, subsystem):

Mount the cgroup subsystem fs under the cgroup root dir.

Parameters
subsystem:stringcgroup subsystem name to mount @rtype string @return path of subsystem mount point
@classmethod
def _PrepareInstanceRootFsBdev(cls, storage_path, stash):

Return mountable path for storage_path.

This function creates a partition mapping for storage_path and returns the first partition device path as a rootfs partition, and stashes the loopback device path. If storage_path is not a multi-partition block device, just return storage_path.

@classmethod
def _SetCgroupInstanceValue(cls, instance_name, param_name, param_value):

Set the value to the specified instance cgroup parameter.

Parameters
instance_name:stringinstance name
param_name:stringcgroup subsystem parameter name
param_value:stringcgroup subsystem parameter value to be set
@classmethod
def _VerifyDiskRequirements(cls, block_devices):

Insures that the disks provided work with the current implementation.

@classmethod
def _VerifyLXCCommands(cls):

Verify the validity of lxc command line tools.

Returns
list(str)list of problem descriptions. the blank list will be returned if there is no problem.
@classmethod
def _WaitForInstanceState(cls, instance_name, state, timeout):

Wait for an instance state transition within timeout

Return True if an instance state changed to the desired state within timeout secs.

def _CleanupInstance(self, instance_name, stash):

Actual implementation of the instance cleanup procedure.

Parameters
instance_name:stringinstance name
stash:dict(string:any)dict that contains desired information for instance cleanup
def _CreateConfigFile(self, instance, sda_dev_path):

Create an lxc.conf file for an instance.

def _EnsureDirectoryExistence(self):

Ensures all the directories needed for LXC use exist.

def _GetInstanceInfoInner(self, instance_name):

Get instance properties.

Parameters
instance_name:stringthe instance name
Returns
tuple of strings(name, id, memory, vcpus, stat, times)
def _LoadInstanceStash(self, instance_name):

Load information stashed in file which was created by _SaveInstanceStash.

def _SaveInstanceStash(self, instance_name, data):

Save data to the instance stash file in serialized format.

def _SpawnLXC(self, instance, log_file, conf_file):

Execute lxc-start and wait until container health is confirmed.

_CGROUP_ROOT_DIR =

Undocumented

Value
_ROOT_DIR+'/cgroup'
_DIR_MODE: int =

Undocumented

Value
493
_INSTANCE_DIR =

Undocumented

Value
_ROOT_DIR+'/instance'
_LOG_DIR =

Undocumented

Value
pathutils.LOG_DIR+'/lxc'
_LXC_COMMANDS_REQUIRED: list[str] =

Undocumented

Value
['lxc-console', 'lxc-ls', 'lxc-start', 'lxc-stop', 'lxc-wait']
_LXC_MIN_VERSION_REQUIRED =

Undocumented

Value
LXCVersion('1.0.0')
_MEMORY_PARAMETER: str =

Undocumented

Value
'memory.limit_in_bytes'
_MEMORY_SWAP_PARAMETER: str =

Undocumented

Value
'memory.memsw.limit_in_bytes'
_PROC_CGROUPS_FILE: str =

Undocumented

Value
'/proc/cgroups'
_PROC_SELF_CGROUP_FILE: str =

Undocumented

Value
'/proc/self/cgroup'
_REBOOT_TIMEOUT: int =

Undocumented

Value
120
_REQUIRED_CGROUP_SUBSYSTEMS: list[str] =

Undocumented

Value
['cpuset', 'memory', 'devices', 'cpuacct']
_ROOT_DIR =

Undocumented

Value
pathutils.RUN_DIR+'/lxc'
_STASH_KEY_ALLOCATED_LOOP_DEV: str =

Undocumented

Value
'allocated_loopdev'