lago.providers.libvirt package¶
Submodules¶
lago.providers.libvirt.cpu module¶
-
class
lago.providers.libvirt.cpu.
CPU
(spec, host_cpu)[source]¶ Bases:
object
-
cpu_xml
¶
-
generate_custom
(cpu, vcpu_num, fill_topology)[source]¶ Generate custom CPU model. This method attempts to convert the dict to XML, as defined by
xmltodict.unparse
method.Parameters: Returns: CPU XML node
Return type: lxml.etree.Element
Raises: LagoInitException
– when failed to convert dict to XML
-
generate_exact
(model, vcpu_num, host_cpu)[source]¶ Generate exact CPU model with nested virtualization CPU feature.
Parameters: Returns: CPU XML node
Return type: lxml.etree.Element
-
generate_feature
(name, policy='require')[source]¶ Generate CPU feature element
Parameters: Returns: feature XML element
Return type: lxml.etree.Element
-
generate_host_passthrough
(vcpu_num)[source]¶ Generate host-passthrough XML cpu node
Parameters: vcpu_num (int) – number of virtual CPUs Returns: CPU XML node Return type: lxml.etree.Element
-
generate_topology
(vcpu_num, cores=1, threads=1)[source]¶ Generate CPU <topology> XML child
Parameters: Returns: topology XML element
Return type: lxml.etree.Element
-
generate_vcpu
(vcpu_num)[source]¶ Generate <vcpu> domain XML child
Parameters: vcpu_num (int) – number of virtual cpus Returns: vcpu XML element Return type: lxml.etree.Element
-
generate_vcpu_xml
(vcpu_num)[source]¶ Parameters: vcpu_num (int) – number of virtual cpus Returns: vcpu XML node Return type: lxml.etree.Element
-
model
¶
-
validate
()[source]¶ Validate CPU-related VM spec are compatible
Raises: LagoInitException
– if both ‘cpu_model’ and ‘cpu’ are defined.
-
vcpu_xml
¶
-
vendor
¶
-
-
class
lago.providers.libvirt.cpu.
LibvirtCPU
[source]¶ Bases:
object
Query data from /usr/share/libvirt/cpu_map.xml
-
classmethod
get_cpu_props
(family, arch='x86')[source]¶ Get CPU info XML
Parameters: Returns: CPU xml
Return type: lxml.etree.Element
Raises: LagoException
– If no such CPU family exists
-
classmethod
lago.providers.libvirt.network module¶
-
class
lago.providers.libvirt.network.
Network
(env, spec, compat)[source]¶ Bases:
object
-
spec
¶
-
lago.providers.libvirt.utils module¶
Utilities to help deal with the libvirt python bindings
-
lago.providers.libvirt.utils.
DOMAIN_STATES
= {<class 'sphinx.ext.autodoc.VIR_DOMAIN_SHUTOFF'>: 'shut off', <class 'sphinx.ext.autodoc.VIR_DOMAIN_BLOCKED'>: 'blocked', <class 'sphinx.ext.autodoc.VIR_DOMAIN_PMSUSPENDED'>: 'suspended', <class 'sphinx.ext.autodoc.VIR_DOMAIN_NOSTATE'>: 'no state', <class 'sphinx.ext.autodoc.VIR_DOMAIN_SHUTDOWN'>: 'beign shut down', <class 'sphinx.ext.autodoc.VIR_DOMAIN_RUNNING'>: 'running', <class 'sphinx.ext.autodoc.VIR_DOMAIN_CRASHED'>: 'crashed', <class 'sphinx.ext.autodoc.VIR_DOMAIN_PAUSED'>: 'paused'}¶ Mapping of domain statuses values to human readable strings
-
class
lago.providers.libvirt.utils.
Domain
[source]¶ Bases:
object
Class to namespace libvirt domain related helpers
-
static
resolve_state
(state_number)[source]¶ Get a nice description from a domain state number
Parameters: state_number (list of int) – State number as returned by libvirt.virDomain.state()
Returns: - small human readable description of the domain state, unknown
- if the state is not in the known list
Return type: str
-
static
-
lago.providers.libvirt.utils.
LIBVIRT_CONNECTIONS
= {}¶ Singleton with the cached opened libvirt connections
lago.providers.libvirt.vm module¶
-
class
lago.providers.libvirt.vm.
LocalLibvirtVMProvider
(vm)[source]¶ Bases:
lago.plugins.vm.VMProviderPlugin
-
_shutdown
(libvirt_cmd, ssh_cmd, msg)[source]¶ Choose the invoking method (using libvirt or ssh) to shutdown / poweroff the domain.
If acpi is defined in the domain use libvirt, otherwise use ssh.
Parameters: - libvirt_cmd (function) – Libvirt function the invoke
- ssh_cmd (list of str) – Shell command to invoke on the domain
- msg (str) – Name of the command that should be inserted to the log message.
- Returns
- None
Raises: RuntimeError
– If acpi is not configured an ssh isn’t available
-
export_disks
(standalone, dst_dir, compress, *args, **kwargs)[source]¶ Exports all the disks of self. For each disk type, handler function should be added.
Parameters:
-
extract_paths
(paths, ignore_nopath)[source]¶ Extract the given paths from the domain
Attempt to extract all files defined in
paths
with the method defined inextract_paths()
, if it fails, will try extracting the files with libguestfs.Parameters: - paths (list of str) – paths to extract
- ignore_nopath (boolean) – if True will ignore none existing paths.
Returns: None
Raises: ExtractPathNoPathError
– if a none existing path was found on the VM, and ignore_nopath is True.ExtractPathError
– on all other failures.
-
interactive_console
(*args, **kwargs)[source]¶ Opens an interactive console
Returns: result of the virsh command execution Return type: lago.utils.CommandStatus
-