File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/vsphere.cpython-310.pyc
o
�N�g�� � @ s� d Z ddlZddlZddlZddlmZ ddlZddlm m
Z
ddlZddlZddl
ZddlZddlZddlmZmZ ddlmZmZmZ ddlmZmZ ddlmZ ddlmZmZmZm Z m!Z!m"Z"m#Z#m$Z$ dd l%m&Z&m'Z' dd
l(m)Z) ddl*m+Z+ e�,e-�Z.zddl/Z/dZ0W n e1y� d
Z0Y nw z'ddl2m3Z3m4Z4m5Z5m6Z6 de3j7v r�ej8dkr�ej8dk r�e.�9d� e1� �dZ:W n e1y� d
Z:Y nw z3ddl;m<Z<m=Z=m>Z>m?Z?m@Z@ ddlAmBZBmCZCmDZDmEZEmFZF ddlGmHZH ddlImJZJ eBeCeDeEeFfZKdZLW n e1�y d
ZLY nw ej jM�Nd�ZOeO�rdZPnd
ZPdZQg d�ZRdd� ZSdd� ZTeTdd� �ZUd d!� ZVd"d#� ZWd$d%� ZXe&e:�eWd&d'd(d)d*�eT�d�d+d,����ZYe&e:�eWd&d'd(d)d*�eTd-d.� ���ZZe&eP�eT �d�d/d0���Z[e&eP�eT �d�d1d2���Z\e&eP�eT �d�d3d4���Z]e&eP�eT 5 6 �d�d7d8���Z^e&eP�eT �d�d9d:���Z_e&eP�eT �d�d;d<���Z`e&eP�eT �d�d=d>���Zae&eP�eT �d�d?d@���Zbe&eP�eT �d�dAdB���Zce&eP�eT �d�dCdD���Zde'dE�eT �d�dFdG���Zee'dE�eT �d�dHdI���Zfe&e:�e'dE�eT �d�dJdK����Zge&e:�e'dE�eT �d�dLdM����Zhe&e:�e'dE�eT �d�dNdO����Zie&e:�e'dE�eT �d�dPdQ����Zje&e:�e'dE�eT �d�dRdS����Zke&e:�e'dE�eT �d�dTdU����Zle&e:�e'dE�eT �d�dVdW����Zme&e:�eWd&d'd(d)d*�eXeT�d�dXdY�����Zne&e:�e'dE�eT �d�dZd[����Zoe&e:�e'dE�eT �d�d\d]����Zpe&e:�e'dE�eT�d�d^d_����Zqe&e:�e'dE�eT �d�d`da����Zre&e:�e'dE�eT �d�dbdc����Zse&e:�e'dE�eT�d�ddde����Zte&e:�e'dE�eT �d�dfdg����Zue&e:�e'dE�eT�d�dhdi����Zve&e:�e'dE�eT�d�djdk����Zwe&e:�e'dE�eT�d�dldm����Zxe&e:�e'dE�eT�d�dndo����Zye&e:�e'dE�eT�d�dpdq����Zze&e:�e'dE�eT �d�drds����Z{e&e:�e'dE�eT �d�dtdu����Z|e&e:�e'dE�eT �d�dvdw����Z}e&e:�e'dE�eT �d�dxdy����Z~e&e:�e'dE�eT �d�dzd{����Ze&e:�e'dE�eT �d�d|d}����Z�e&e:�e'dE�eT �d�d~d����Z�e&e:�e'dE�eT �d�d�d�����Z�e&e:�e'dE�eT �d�d�d�����Z�e&e:�e'dE�eT �d�d�d�����Z�e&e:�e'dE�eT 5 �d�d�d�����Z�e&e:�e'dE�eT �d�d�d�����Z�e&e:�e'dE�eT �d�d�d�����Z�e&e:�e'dE�eT �d�d�d�����Z�d�d�� Z�d�d�� Z�d�d�� Z�d�d�� Z�d�d�� Z�e&e:�eWd(d'�eXeT�d�d�d������Z�d�d�� Z�d�d�� Z�d�d�� Z�d�d�� Z�d�d�� Z�d�d�� Z�e&e:�eWd(d'�eXeT�d�d�d������Z�e&e:�eWd(d'�eXeT�d�d�d������Z�d�d�� Z�d�d�� Z�d�d�� Z�d�d�� Z�e&e:�eWd(d'�eXeT�d�d�d������Z�e&e:�eWd(d'�eXeT�d�d�d������Z�d�d�� Z�d�d�� Z�d�d�� Z�d�d�� Z�e&e:�eWd(d'�eXeT�d�d�d������Z�e&e:�eWd(d'�eXeT�d�d�d������Z�e&e:�eWd(d'�eXeT�d�d�dÄ����Z�d�dń Z�e&e:�eWd(d)�eXeT�d�d�dDŽ����Z�e&e:�eWd(d)�eXeT�d�d�dɄ����Z�d�d˄ Z�e&e:�eWd(d)�eXeT�d�d�d̈́����Z�d�dτ Z�e&e:�eWd(d)�eXeT�d�d�dф����Z�e&e:�eWd(d)�eXeT�d�d�dӄ����Z�e&e:�eWd'd(d)�eXeT�d�d�dՄ����Z�e&e:�eWd'd(d)�eXeT �d�d�dׄ����Z�e&e:�eWd(d'd)d*�eXeT�d�d�dل����Z�e&e:�eWd(d)�eXeT�d�d�dۄ����Z�d�d݄ Z�e&e:�eWd'd(�eXeT�d�d�d߄����Z��d�d�d�Z�e&e:�e&e0�eWd'd(�eXeT�d�d�d������Z�e&e:�e&e0�eWd'd(�eXeT�d�d�d������Z�e&e:�eWd&d'd(�eXeT �d�d�d�����Z�e&e:�e&e0�eWd&�eXeT �d�d�d������Z�e&e:�eWd&d'd(�eXeT�d�d�d�����Z�e&e:�eWd&d'd(�eXeT�d�d�d�����Z�e&e:�eWd'd(�eXeT�d�d�d�����Z�e&e:�eWd'd(�eXeT�d�d�d�����Z�d�d� Z�d�d�� Z�e&e:�e&e0�eWd'd(�eXeT �d�d�d�������Z�e&e:�e&e0�eWd'd(�eXeT �d�d�d�������Z�e&e:�eWd&d'd(d)�eXeT �d�d�d������Z�e&e:�eWd&�eXeT�d�d�d������Z�e&e:�eWd&�eXeT�d�d�d������Z�e&e:�eWd&�eXeT�d��d �d�����Z�e&e:�eWd&�eXeT�d��d�d�����Z�e&e:�e&e0�eWd&�eXeT �d��d�d������Z�e&e:�e&e0�eWd&�eXeT �d��d�d������Z�e&e:�e&e0�eWd&�eXeT �d��d�d ������Z�e&e:�e&e0�eWd&�eXeT�d��d
�d������Z�e&e:�eWd&�eXeT�d��d�d
�����Z�e&e:�e&e0�eWd&�eXeT �d��d�d������Zɐd�d� Zʐd�d� Zːd�d� Z̐d�d� Z͐d�d� Zΐd��d�d�Zϐd�d� ZАd�d� Zѐd �d!� ZҐd"�d#� ZӐd$�d%� Z� �d��d&�d'�Z� �d��d(�d)�Z�e&e:�e'dE�eT �d��d*�d+����Z�e&e:�eWd&d'd(d)��d,�d-� ��Zؐd.�d/� Zِd0�d1� Zڐd2�d3� Z�e&e:�eXeT �d��d4�d5����Z�e&e:�eXeT�d��d6�d7����Zݐd��d9�d:�Zސd;�d<� Zߐd=�d>� Z�e&e:�eWd*d'd(�eXeT�d��d?�d@�����Z�d��dA�dB�Z�e&e:�eWd*d'd(�eXeT�d��dC�dD�����Z�dE�dF� Z�e&e:�eWd*d'd(�eXeT �d��dG�dH�����Z�dI�dJ� Z� � K �d��dL�dM�Z�d��dO�dP�Z�dQ�dR� Z� � 8 �d��dS�dT�Z�dU�dV� Z�dW�dX� Z�d��dY�dZ�Z�d[�d\� Z�d��d]�d^�Z� � _ �d��d`�da�Z�db�dc� Z�d��dd�de�Z�d��df�dg�Z�dh�di� Z�d��dj�dk�Z��dl�dm� Z��d��dn�do�Z��dp�dq� Z��dr�ds� Z��dt�du� Z�eT�dv�dw� �Z�eXeT�d��dx�dy���Z��dz�d{� Z��d|�d}� Z��d~�d� Z��d��d�� �Z �d��d��d���Z�d��d�� �Z�d��d��d���Ze&e:eL�eWd)�eXeT �d��d��d�������Ze&e:eL�eWd)�eXeT �d��d��d�������Ze&e:eL�eWd)�eXeT� � �d��d��d�������Ze&e:eL�eWd)�eXeT� � �d��d��d�������Ze&e:eL�eWd)�eXeT �d��d��d�������Ze&e:eL�eWd)�eXeT �d��d��d�������Z e&e:eL�eWd)�eXeT �d��d��d�������Z
e&e:eL�eWd)�eXeT �d��d��d�������Ze&e:�eWd*d'd(�eXeT �d��d��d�������Ze&e:�eWd*d'd(�eXeT �d��d��d�������Z
e&e:�eWd*d'd(�eXeT�d��d��d�������Ze&e:�eWd*d'd(�eXeT�d��d��d�������Ze&e:�eWd*d'd(�eXeT�d��d��d�������Z�d��d��d���Ze&e:�eWd*d'd(�eXeT�dd��d�������Ze&e:�eWd*d'd(�eXeT �dd��d�������ZdS (� aN
Manage VMware vCenter servers and ESXi hosts.
.. versionadded:: 2015.8.4
:codeauthor: Alexandru Bleotu <alexandru.bleotu@morganstaley.com>
Dependencies
============
- pyVmomi Python Module
- ESXCLI
pyVmomi
-------
PyVmomi can be installed via pip:
.. code-block:: bash
pip install pyVmomi
.. note::
Version 6.0 of pyVmomi has some problems with SSL error handling on certain
versions of Python. If using version 6.0 of pyVmomi, Python 2.7.9,
or newer must be present. This is due to an upstream dependency
in pyVmomi 6.0 that is not supported in Python versions 2.7 to 2.7.8. If the
version of Python is not in the supported range, you will need to install an
earlier version of pyVmomi. See `Issue #29537`_ for more information.
.. _Issue #29537: https://github.com/saltstack/salt/issues/29537
Based on the note above, to install an earlier version of pyVmomi than the
version currently listed in PyPi, run the following:
.. code-block:: bash
pip install pyVmomi==5.5.0.2014.1.1
The 5.5.0.2014.1.1 is a known stable version that this original vSphere Execution
Module was developed against.
vSphere Automation SDK
----------------------
vSphere Automation SDK can be installed via pip:
.. code-block:: bash
pip install --upgrade pip setuptools
pip install --upgrade git+https://github.com/vmware/vsphere-automation-sdk-python.git
.. note::
The SDK also requires OpenSSL 1.0.1+ if you want to connect to vSphere 6.5+ in order to support
TLS1.1 & 1.2.
In order to use the tagging functions in this module, vSphere Automation SDK is necessary to
install.
The module is currently in version 1.0.3
(as of 8/26/2019)
ESXCLI
------
Currently, about a third of the functions used in the vSphere Execution Module require
the ESXCLI package be installed on the machine running the Proxy Minion process.
The ESXCLI package is also referred to as the VMware vSphere CLI, or vCLI. VMware
provides vCLI package installation instructions for `vSphere 5.5`_ and
`vSphere 6.0`_.
.. _vSphere 5.5: http://pubs.vmware.com/vsphere-55/index.jsp#com.vmware.vcli.getstart.doc/cli_install.4.2.html
.. _vSphere 6.0: http://pubs.vmware.com/vsphere-60/index.jsp#com.vmware.vcli.getstart.doc/cli_install.4.2.html
Once all of the required dependencies are in place and the vCLI package is
installed, you can check to see if you can connect to your ESXi host or vCenter
server by running the following command:
.. code-block:: bash
esxcli -s <host-location> -u <username> -p <password> system syslog config get
If the connection was successful, ESXCLI was successfully installed on your system.
You should see output related to the ESXi host's syslog configuration.
.. note::
Be aware that some functionality in this execution module may depend on the
type of license attached to a vCenter Server or ESXi host(s).
For example, certain services are only available to manipulate service state
or policies with a VMware vSphere Enterprise or Enterprise Plus license, while
others are available with a Standard license. The ``ntpd`` service is restricted
to an Enterprise Plus license, while ``ssh`` is available via the Standard
license.
Please see the `vSphere Comparison`_ page for more information.
.. _vSphere Comparison: https://www.vmware.com/products/vsphere/compare
About
=====
This execution module was designed to be able to handle connections both to a
vCenter Server, as well as to an ESXi host. It utilizes the pyVmomi Python
library and the ESXCLI package to run remote execution functions against either
the defined vCenter server or the ESXi host.
Whether or not the function runs against a vCenter Server or an ESXi host depends
entirely upon the arguments passed into the function. Each function requires a
``host`` location, ``username``, and ``password``. If the credentials provided
apply to a vCenter Server, then the function will be run against the vCenter
Server. For example, when listing hosts using vCenter credentials, you'll get a
list of hosts associated with that vCenter Server:
.. code-block:: bash
# salt my-minion vsphere.list_hosts <vcenter-ip> <vcenter-user> <vcenter-password>
my-minion:
- esxi-1.example.com
- esxi-2.example.com
However, some functions should be used against ESXi hosts, not vCenter Servers.
Functionality such as getting a host's coredump network configuration should be
performed against a host and not a vCenter server. If the authentication
information you're using is against a vCenter server and not an ESXi host, you
can provide the host name that is associated with the vCenter server in the
command, as a list, using the ``host_names`` or ``esxi_host`` kwarg. For
example:
.. code-block:: bash
# salt my-minion vsphere.get_coredump_network_config <vcenter-ip> <vcenter-user> <vcenter-password> esxi_hosts='[esxi-1.example.com, esxi-2.example.com]'
my-minion:
----------
esxi-1.example.com:
----------
Coredump Config:
----------
enabled:
False
esxi-2.example.com:
----------
Coredump Config:
----------
enabled:
True
host_vnic:
vmk0
ip:
coredump-location.example.com
port:
6500
You can also use these functions against an ESXi host directly by establishing a
connection to an ESXi host using the host's location, username, and password. If ESXi
connection credentials are used instead of vCenter credentials, the ``host_names`` and
``esxi_hosts`` arguments are not needed.
.. code-block:: bash
# salt my-minion vsphere.get_coredump_network_config esxi-1.example.com root <host-password>
local:
----------
10.4.28.150:
----------
Coredump Config:
----------
enabled:
True
host_vnic:
vmk0
ip:
coredump-location.example.com
port:
6500
� N��wraps)�ESXClusterConfigSchema�ESXClusterEntitySchema)�DiskGroupsDiskIdSchema�SimpleHostCacheSchema�VmfsDatastoreSchema)�ESXVirtualMachineDeleteSchema�!ESXVirtualMachineUnregisterSchema)�VCenterEntitySchema)�ArgumentValueError�CommandExecutionError�InvalidConfigError�InvalidEntityError�VMwareApiError�VMwareObjectExistsError�VMwareObjectRetrievalError�VMwareSaltError)�depends�ignores_kwargs)�recursive_diff)� list_diffTF)�VmomiSupport�pbm�vim�vmodlz vim25/6.0)� � )r r � zFpyVmomi not loaded: Incompatible versions of Python. See Issue #29537.)�Category�
CategoryModel�Tag�TagAssociation�TagModel)�
AlreadyExists�InvalidArgument�NotFound�Unauthenticated�Unauthorized)� DynamicID)�Cluster�esxcliZvsphere)�esxi�
esxcluster�
esxdatacenter�vcenter�esxvmc C s t S �N)�__virtualname__� r3 r3 �H/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/vsphere.py�__virtual__* s r5 c s t � �� fdd��}|S )z>
Decorator wrapper to warn about azurearm deprecation
c s6 t jjjddtd� � | i t jjjdi |����}|S )NZArgonz�The 'vsphere' functionality in Salt has been deprecated and its functionality will be removed in version 3008 in favor of the saltext.vmware Salt Extension. (https://github.com/saltstack/salt-ext-modules-vmware))�categoryr3 )�salt�utilsZversionsZ
warn_until�
FutureWarning�args�clean_kwargs)r: �kwargs�ret��functionr3 r4 �wrapped3 s �z%_deprecation_message.<locals>.wrappedr )r? r@ r3 r>