| Server IP : 198.38.94.13 / Your IP : 216.73.217.33 Web Server : Apache System : Linux d4744.dxb1.stableserver.net 5.14.0-611.49.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Apr 21 16:39:08 EDT 2026 x86_64 User : revivere ( 1140) PHP Version : 8.2.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /opt/saltstack/salt/lib/python3.10/site-packages/salt/states/__pycache__/ |
Upload File : |
o
;j�X � @ s d Z ddlZddlZddlmZ ddlZddlmZm Z ddl
mZ ddlm
Z
ddlmZ zddlZdZW n eyA d ZY nw z
dd
lmZ dZW n eyW d ZY nw e�e�Zdd� Zd
d� Zedd� �Zdd� Zedd� �Zedd� �Zeddd��ZdS )a�
Manage VMware ESXi Clusters.
.. Warning::
This module will be deprecated in a future release of Salt. VMware strongly
recommends using the
`VMware Salt extensions <https://docs.saltproject.io/salt/extensions/salt-ext-modules-vmware/en/latest/all.html>`_
instead of the ESX cluster module. Because the Salt extensions are newer and
actively supported by VMware, they are more compatible with current versions
of ESXi and they work well with the latest features in the VMware product
line.
Dependencies
============
- pyVmomi Python Module
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 ESXi State
Module was developed against.
� N��wraps)�ESXClusterConfigSchema�
LicenseSchema)�
dictupdate)�recursive_diff)� list_diffTF)�VmomiSupportc C s6 t sdS tsdS dtjv rtjdkrtjdk rdS dS )N)Fz/State module did not load: jsonschema not found)Fz,State module did not load: pyVmomi not foundz vim25/6.0)� � )r
r � )FzaState module did not load: Incompatible versions of Python and pyVmomi present. See Issue #29537.T)�HAS_JSONSCHEMA�HAS_PYVMOMIr Z
versionMap�sys�version_info� r r �J/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/esxcluster.py�__virtual__P s
r c s t � �� fdd��}|S )z>
Decorator wrapper to warn about azurearm deprecation
c s6 t jjjddtd� � | i t jjjdi |����}|S )NZArgonz�The 'esxcluster' 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))�categoryr )�salt�utilsZversionsZ
warn_until�
FutureWarning�argsZclean_kwargs)r �kwargs�ret��functionr r �wrappedj s �z%_deprecation_message.<locals>.wrappedr )r r r r r �_deprecation_messagee s r c C s dS )zT
Retrieves and adapt the login credentials from the proxy connection module
Tr )�lowr r r �mod_initz s r c C sB t �d� dd� td | d�D �}|stj�d|� d���|d S ) zRetrieves the vsan_datastorezRetrieving vsan datastorec S s g | ]
}|d dkr|�qS )�typeZvsanr )�.0Zdsr r r �
<listcomp>� s
�z'_get_vsan_datastore.<locals>.<listcomp>z!vsphere.list_datastores_via_proxy��service_instancez0No vSAN datastores where retrieved for cluster '�'r )�log�trace�__salt__r �
exceptions�VMwareObjectRetrievalError)�si�cluster_nameZvsan_datastoresr r r �_get_vsan_datastore� s
�
�r. c
C sv t d � }|dkr| t d � d }}n|dkr(t d � d t d � d }}n tj�d|� ���t�d | ||� |}t�d
|� d}| i dd
d�}g }i } d}�z�t�d� t�� }
t�d|
� zt �
||
� W n t jjy} } ztj�|��d}~ww d}t d � }
zt d |||
d�}W n` tjj
y� d}td r�|�d�| ||�� t�|d � t d |
� |�dd�|�d�� | Y W S t�d||� t d ||||
d� |�d�||�� t�|d � | �d|i� Y nw |�r�d}d|v �r5d |d v �r5t|�di ��d g �|�di ��d g �d!�}t�d"|j� |d d = d|v �r5d |d v �r5|d d = t||�}t�d#|j� |j�s]|�rL|j�s]|�d$�||�� t�|d � n�d}d%}|j�rl|� |j� �}|�r�|j�r�d&�|d�d'd(� |j�d�D ���}td �r�|�d)�| |||�� nR|j}|j}|�r�|j�r�t�|dd |jii� |�r�|j�r�t�|dd |jii� t�d*|� t d+ ||||
d� |�d,�||�� t�|d � | �||d-�� t d |
� d}td �r�|�r�d}|�|d�|�| d.�� |W S tjj�y: } z#tjd/|dd0� |
�r$t d |
� |�dt|�d�� |W Y d}~S d}~ww )1a�
Configures a cluster. Creates a new cluster, if it doesn't exist on the
vCenter or reconfigures it if configured differently
Supported proxies: esxdatacenter, esxcluster
name
Name of the state. If the state is run in by an ``esxdatacenter``
proxy, it will be the name of the cluster.
cluster_config
Configuration applied to the cluster.
Complex datastructure following the ESXClusterConfigSchema.
Valid example is:
.. code-block:: yaml
drs:
default_vm_behavior: fullyAutomated
enabled: true
vmotion_rate: 3
ha:
admission_control
_enabled: false
default_vm_settings:
isolation_response: powerOff
restart_priority: medium
enabled: true
hb_ds_candidate_policy: userSelectedDs
host_monitoring: enabled
options:
- key: das.ignoreinsufficienthbdatastore
value: 'true'
vm_monitoring: vmMonitoringDisabled
vm_swap_placement: vmDirectory
vsan:
auto_claim_storage: false
compression_enabled: true
dedup_enabled: true
enabled: true
zvsphere.get_proxy_typeZ
esxdatacenterzesxdatacenter.get_details�
datacenterZ
esxcluster�esxcluster.get_details�clusterzUnsupported proxy z.Running %s for cluster '%s' in datacenter '%s'zcluster_dict = %sFN�Default��name�changes�result�commentz)Validating cluster_configured state inputzschema = %s�&vsphere.get_service_instance_via_proxyzvsphere.list_clusterr$ T�testz5State {} will create cluster '{}' in datacenter '{}'.����vsphere.disconnect�
�r6 r7 z)Creating cluster '%s' in datacenter '%s'.zvsphere.create_clusterz'Created cluster '{}' in datacenter '{}'�newZha�options�keyzoptions diffs = %sz
diffs = %szBCluster '{}' in datacenter '{}' is up to date. Nothing to be done.� z{}
ha:
options:
{}c S s g | ]}d |� ��qS )z r �r"