The nova.virt.libvirt.host Module

Manages information about the host OS and hypervisor.

This class encapsulates a connection to the libvirt daemon and provides certain higher level APIs around the raw libvirt API. These APIs are then used by all the other libvirt related classes

class DomainJobInfo(**kwargs)

Bases: object

Information about libvirt background jobs

This class encapsulates information about libvirt background jobs. It provides a mapping from either the old virDomainGetJobInfo API which returned a fixed list of fields, or the modern virDomainGetJobStats which returns an extendable dict of fields.

classmethod for_domain(dom)

Get job info for the domain

Query the libvirt job info for the domain (ie progress of migration, or snapshot operation)

Returns: a DomainJobInfo instance

class Host(uri, read_only=False, conn_event_handler=None, lifecycle_event_handler=None)

Bases: object

compare_cpu(xmlDesc, flags=0)

Compares the given CPU description with the host CPU.

create_secret(usage_type, usage_id, password=None)

Create a secret.

Parameters:
  • usage_type – one of ‘iscsi’, ‘ceph’, ‘rbd’ or ‘volume’ ‘rbd’ will be converted to ‘ceph’.
  • usage_id – name of resource in secret
  • password – optional secret value to set
delete_secret(usage_type, usage_id)

Delete a secret.

usage_type: one of ‘iscsi’, ‘ceph’, ‘rbd’ or ‘volume’ usage_id: name of resource in secret

device_lookup_by_name(name)

Lookup a node device by its name.

Returns:a virNodeDevice instance
find_secret(usage_type, usage_id)

Find a secret.

usage_type: one of ‘iscsi’, ‘ceph’, ‘rbd’ or ‘volume’ usage_id: name of resource in secret

get_capabilities()

Returns the host capabilities information

Returns an instance of config.LibvirtConfigCaps representing the capabilities of the host.

Note: The result is cached in the member attribute _caps.

Returns:a config.LibvirtConfigCaps object
get_connection()

Returns a connection to the hypervisor

This method should be used to create and return a well configured connection to the hypervisor.

Returns:a libvirt.virConnect object
get_cpu_count()

Returns the total numbers of cpu in the host.

get_cpu_stats()

Returns the current CPU state of the host with frequency.

get_domain(instance)

Retrieve libvirt domain object for an instance.

Parameters:instance – an nova.objects.Instance object

Attempt to lookup the libvirt domain objects corresponding to the Nova instance, based on its name. If not found it will raise an exception.InstanceNotFound exception. On other errors, it will raise an exception.NovaException exception.

Returns:a libvirt.Domain object
get_driver_type()

Get hypervisor type.

Returns:hypervisor type (ex. qemu)
get_guest(instance)

Retrieve libvirt domain object for an instance.

Parameters:instance – an nova.objects.Instance object
Returns:a nova.virt.libvirt.Guest object
get_hostname()

Returns the hostname of the hypervisor.

get_memory_mb_total()

Get the total memory size(MB) of physical computer.

Returns:the total amount of memory(MB).
get_memory_mb_used()

Get the used memory size(MB) of physical computer.

Returns:the total usage of memory(MB).
get_online_cpus()

Get the set of CPUs that are online on the host

Method is only used by NUMA code paths which check on libvirt version >= 1.0.4. getCPUMap() was introduced in libvirt 1.0.0.

Returns:set of online CPUs, raises libvirtError on error
get_version()

Get hypervisor version.

Returns:hypervisor version (ex. 12003)
has_min_version(lv_ver=None, hv_ver=None, hv_type=None)
has_version(lv_ver=None, hv_ver=None, hv_type=None)
initialize()
is_cpu_control_policy_capable()

Returns whether kernel configuration CGROUP_SCHED is enabled

CONFIG_CGROUP_SCHED may be disabled in some kernel configs to improve scheduler latency.

list_guests(only_running=True, only_guests=True)

Get a list of Guest objects for nova instances

Parameters:
  • only_running – True to only return running instances
  • only_guests – True to filter out any host domain (eg Dom-0)

See method “list_instance_domains” for more information.

Returns:list of Guest objects
list_instance_domains(only_running=True, only_guests=True)

Get a list of libvirt.Domain objects for nova instances

Parameters:
  • only_running – True to only return running instances
  • only_guests – True to filter out any host domain (eg Dom-0)

Query libvirt to a get a list of all libvirt.Domain objects that correspond to nova instances. If the only_running parameter is true this list will only include active domains, otherwise inactive domains will be included too. If the only_guests parameter is true the list will have any “host” domain (aka Xen Domain-0) filtered out.

Returns:list of libvirt.Domain objects
list_pci_devices(flags=0)

Lookup pci devices.

Returns:a list of virNodeDevice instance
write_instance_config(xml)

Defines a domain, but does not start it.

Parameters:xml – XML domain definition of the guest.
Returns:a virDomain instance

Previous topic

The nova.virt.libvirt.guest Module

Next topic

The nova.virt.libvirt.imagebackend Module

Project Source

This Page