session

Hypervisor session manager.

class compute.session.Capabilities(arch: str, virt_type: str, emulator: str, machine: str, max_vcpus: int, cpu_vendor: str, cpu_model: str, cpu_features: dict, usable_cpus: list[dict])

Store domain capabilities info.

arch: str

Alias for field number 0

cpu_features: dict

Alias for field number 7

cpu_model: str

Alias for field number 6

cpu_vendor: str

Alias for field number 5

emulator: str

Alias for field number 2

machine: str

Alias for field number 3

max_vcpus: int

Alias for field number 4

usable_cpus: list[dict]

Alias for field number 8

virt_type: str

Alias for field number 1

class compute.session.NodeInfo(arch: str, memory: int, cpus: int, mhz: int, nodes: int, sockets: int, cores: int, threads: int)

Store compute node info.

See https://libvirt.org/html/libvirt-libvirt-host.html#virNodeInfo NOTE: memory unit in libvirt docs is wrong! Actual unit is MiB.

arch: str

Alias for field number 0

cores: int

Alias for field number 6

cpus: int

Alias for field number 2

memory: int

Alias for field number 1

mhz: int

Alias for field number 3

nodes: int

Alias for field number 4

sockets: int

Alias for field number 5

threads: int

Alias for field number 7

class compute.session.Session(uri: str | None = None)

Hypervisor session context manager.

Variables:
  • IMAGES_POOL – images storage pool name taken from env

  • VOLUMES_POOL – volumes storage pool name taken from env

__init__(uri: str | None = None)

Initialise session with hypervisor.

Variables:
  • uri (str) – libvirt connection URI.

  • connection (libvirt.virConnect) – libvirt connection object.

Parameters:

uri – libvirt connection URI.

close() None

Close connection to libvirt daemon.

create_instance(**kwargs: Any) Instance

Create and return new compute instance.

Parameters:
  • name (str) – Instance name.

  • title (str) – Instance title for humans.

  • description (str) – Some information about instance.

  • memory (int) – Memory in MiB.

  • max_memory (int) – Maximum memory in MiB.

  • vcpus (int) – Number of vCPUs.

  • max_vcpus (int) – Maximum vCPUs.

  • cpu (dict) – CPU configuration. See CPUSchema for info.

  • machine (str) – QEMU emulated machine.

  • emulator (str) – Path to emulator.

  • arch (str) – CPU architecture to virtualization.

  • boot (dict) – Boot settings. See BootOptionsSchema.

  • image (str) – Source disk image name for system disk.

  • volumes (list[dict]) – List of storage volume configs. For more info see VolumeSchema.

  • network_interfaces (list[dict]) – List of virtual network interfaces configs. See NetworkInterfaceSchema for more info.

get_capabilities() Capabilities

Return capabilities e.g. arch, virt, emulator, etc.

get_instance(name: str) Instance

Get compute instance by name.

get_node_info() NodeInfo

Return information about compute node.

get_storage_pool(name: str) StoragePool

Get storage pool by name.

list_instances() list[compute.instance.instance.Instance]

List all instances.

list_storage_pools() list[compute.storage.pool.StoragePool]

List all strage pools.