virt.nic is considered as the old version of virt:nic in the code, but
there is no warning of this. The documentation is also still mentioning
virt.nic. Updating it all to move to virt:nic
list_domain() should not be used internally to get domains as it usually
involves duplicate opened connections. Remove some more useless libvirt
connections by using _get_domain() instead.
list_domain opens two libvirt connections: one for active VMs and one
for inactive ones. Move all the logic in _get_domain() by adding two
possible kwargs ('active' and 'inactive'). With this only one connection
is required by this call and _get_domain should now be the function to
use internally to get domains.
Extract the code of get_nics, get_disks and get_graphics into private
functions providing the same feature with a libvirt domain as parameter.
The rationale behind this change is to allow reducing the number of
libvirt connections opened during some calls.
ESXi connections are using libvirt.openAuth with all the authentication
setup delegated in the libvirt config files. Make the whole thing more
generic to be generally usable to users for all kind of hypervisors (issue #47156).
Connecting to an ESX server requires libvirt:connection property, while
connecting to another libvirt driver requires virt.connect property.
In order to harmonize them, deprecate them all in favor of
virt:connectioni:uri (issue #47156).
The rationale behind not keeping any of them is to harmonize the
libvirt:* and virt* configuration properties in this module and move
them all into a virt tree.
libvirt open() function handles None connection URI. In such a case it
tries all the hypervisors and connects to the first possible one.
Forcing 'qemu:///system' URI in the virt module was wrong since it
forced using the QEMU system session even on minions that don't have it.
With None as default, the user has nothing to do to connect to
hypervisors like Xen.
While at it, remove the use of __opts__ to access the 'virt.connect'
property, use config.get instead.
libvirt.open() has the good idea to automatically connect to the first
available local hypervisor it finds if the uri parameter is None. Don't
force a default value to benefit from that feature. Thus a configuration
like the following will listen to all events on the local hypervisor:
engines:
- libvirt_events
This option was added in PR #46895 where the default in the `run_file` function
was set to `True`, but in the `run` function it was set to `False`. This is an
error and the default should be `True`.
With the default set to False, it causes a test failure and would also be a change
in behavior from previous releases. In addition, the docs also say that default
is True. Therefore, this looks to be a typo. This PR sets the default to `True`.
Fixes the following test failure:
- unit.states.test_mysql_query.MysqlQueryTestCase.test_run