File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/virt.cpython-310.pyc
o
�N�g<~ � @ s2 d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl
Z
ddlZddlZddl
ZddlmZ ddlmZ ddlZddlZddlZddlZddlZddlZddlZddlZddlm mZ ddl Zddl!m"Z" ddl#m$Z$m%Z% zddl&Z&ddl&m'Z' dZ(W n e)y� d Z(Y nw e�*e+�Z,ej-e�.ej/�0ejj1j2d
��d�Z3dZ4d
d
d
ddddd�Z5dd� Z6dd� Z7dd� Z8dd� Z9dd� Z:dd� Z;dd� Z<d d!� Z=d"d#� Z>d$d%� Z?d&d'� Z@d(d)� ZAd*d+� ZBd,d-� ZCd.d/� ZDd0d1� ZEd2d3� ZF�ded5d6�ZG�dfd7d8�ZH �dgd9d:�ZI �dhd;d<�ZJ �did=d>�ZK �djd?d@�ZLdAdB� ZMdCdD� ZNdEdF� ZO�dkdHdI�ZPdJdK� ZQ�dldLdM�ZRdNdO� ZSdPdQ� ZTdRdS� ZUdTdU� ZV�dfdVdW�ZWdXdY� ZXdZd[� ZY \ \ G ] �dmd^d_�ZZd`da� Z[dbdc� Z\ddde� Z]dfdg� Z^dhdi� Z_djdk� Z`dldm� Zadndo� Zbdpdq� Zcdrds� Zddtdu� Zedvdw� Zfdxdy� Zgdzd{� Zhd|d}� Zid~d� Zjd�d�� Zkd�d�� Zld�d�� Zmd�d�� Znd�d�� Zo �dnd�d��Zpd�d�� Zqd�d�� Zrd�d�� Zs�dfd�d��Zt�dfd�d��Zud�d�� Zvd�d�� Zwd�d�� Zxd�d�� Zyd�d�� Zzd�d�� Z{d�d�� Z|d�d�� Z}d�d�� Z~�dod�d��Z�dod�d��Z�d�d�� Z�d�d�� Z�d�d�� Z�d�d�� Z�d�d�� Z�d�d�� Z��dfd�d��Z�d�d� Z�d�d�� Z�d�d�� Z�d�d�� Z�d�d Z�d�dĄ Z�d�dƄ Z�d�dȄ Z�d�dʄ Z�d�d̄ Z�d�d΄ Z�d�dЄ Z��dfd�d҄Z� �dfd�dԄZ��dfd�dքZ�d�d Z�d�dڄ Z��dod�d܄Z��dpd�d߄Z�d�d� Z��dqd�d�Z�d�d� Z�d�d� Z�d�d� Z�d�d� Z�d�d� Z�d�d� Z��dfd�d�Z��dfd�d�Z��dfd�d��Z��dod�d��Z��dfd�d��Z��drd�d��Z�d�d�� Z��dsd�d��Z��d �d� Z��d�d� Z��d�d� Z��d�d� Z��d�d � Z��d
�d� Z��d�d
� Z��d�d� Z��d�d� Z��d�d� Z��d�d� Z��d�d� Z��dt�d�d�Z��d�d� Z��du�d�d�Z� �dv�d�d �Z��d!�d"� Z� �dw�d#�d$�Z��d%�d&� Z��df�d'�d(�Z��d)�d*� Z��d+�d,� Z��d-�d.� Z��d/�d0� Zdp�d1�d2�ZÐd3�d4� ZĐd5�d6� ZŐd7�d8� Z� �dx�d9�d:�Z� �dy�d;�d<�Z� �dz�d=�d>�Zɐd?�d@� Zʐdf�dA�dB�ZːdC�dD� Z̐dE�dF� Z͐dG�dH� ZΐdI�dJ� ZϐdK�dL� ZАdM�dN� ZѐdO�dP� ZҐdp�dQ�dR�ZӐdS�dT� ZԐdU�dV� ZՐdW�dX� ZdY�dZ� Zאdr�d[�d\�Zؐd]�d^� Z� �d{�d_�d`�Zڐd|�da�db�Zېd|�dc�dd�Z�dS (} aJ
Work with virtual machines managed by libvirt
:depends:
* libvirt Python module
* libvirt client
* qemu-img
* grep
Connection
==========
The connection to the virtualization host can be either setup in the minion configuration,
pillar data or overridden for each individual call.
By default, the libvirt connection URL will be guessed: the first available libvirt
hypervisor driver will be used. This can be overridden like this:
.. code-block:: yaml
virt:
connection:
uri: lxc:///
If the connection requires an authentication like for ESXi, this can be defined in the
minion pillar data like this:
.. code-block:: yaml
virt:
connection:
uri: esx://10.1.1.101/?no_verify=1&auto_answer=1
auth:
username: user
password: secret
Connecting with SSH protocol
----------------------------
Libvirt can connect to remote hosts using SSH using one of the ``ssh``, ``libssh`` and
``libssh2`` transports. Note that ``libssh2`` is likely to fail as it doesn't read the
``known_hosts`` file. Libvirt may also have been built without ``libssh`` or ``libssh2``
support.
To use the SSH transport, on the minion setup an SSH agent with a key authorized on
the remote libvirt machine.
Per call connection setup
-------------------------
.. versionadded:: 2019.2.0
All the calls requiring the libvirt connection configuration as mentioned above can
override this configuration using ``connection``, ``username`` and ``password`` parameters.
This means that the following will list the domains on the local LXC libvirt driver,
whatever the ``virt:connection`` is.
.. code-block:: bash
salt 'hypervisor' virt.list_domains connection=lxc:///
The calls not using the libvirt connection setup are:
- ``seed_non_shared_migrate``
- ``virt_type``
- ``is_*hyper``
- all migration functions
- `libvirt ESX URI format <http://libvirt.org/drvesx.html#uriformat>`_
- `libvirt URI format <http://libvirt.org/uri.html#URI_config>`_
- `libvirt authentication configuration <http://libvirt.org/auth.html#Auth_client_config>`_
Units
==========
.. _virt-units:
.. rubric:: Units specification
.. versionadded:: 3002
The string should contain a number optionally followed
by a unit. The number may have a decimal fraction. If
the unit is not given then MiB are set by default.
Units can optionally be given in IEC style (such as MiB),
although the standard single letter style (such as M) is
more convenient.
Valid units include:
========== ===== ========== ========== ======
Standard IEC Standard IEC
Unit Unit Name Name Factor
========== ===== ========== ========== ======
B Bytes 1
K KiB Kilobytes Kibibytes 2**10
M MiB Megabytes Mebibytes 2**20
G GiB Gigabytes Gibibytes 2**30
T TiB Terabytes Tebibytes 2**40
P PiB Petabytes Pebibytes 2**50
E EiB Exabytes Exbibytes 2**60
Z ZiB Zettabytes Zebibytes 2**70
Y YiB Yottabytes Yobibytes 2**80
========== ===== ========== ========== ======
Additional decimal based units:
====== =======
Unit Factor
====== =======
KB 10**3
MB 10**6
GB 10**9
TB 10**12
PB 10**15
EB 10**18
ZB 10**21
YB 10**24
====== =======
� N)�ElementTree)�saxutils)� ipaddress)�CommandExecutionError�SaltInvocationError)�libvirtErrorTF�virt)�loaderz/var/lib/libvirt/saltinst�runningZpaused�shutdownZcrashed)r � � � � � � c C s t sdS dS )N)Fz2Unable to locate or import python libvirt library.r )�HAS_LIBVIRT� r r �E/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/virt.py�__virtual__� s r c s � �fdd�}dS )zm
Get libvirt.openAuth callback with username, password values overriding
the configuration ones.
c sz | D ]8}|d t jkr�r�ntd d|d �|d<