403Webshell
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 :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/saltstack/salt/lib/python3.10/site-packages/salt/states/__pycache__/esxcluster.cpython-310.pyc
o

;j�X�@sdZddlZddlZddlmZddlZddlmZm	Z	ddl
mZddlm
Z
ddlmZzddlZdZWneyAd	ZYnwz
dd
lmZdZWneyWd	ZYnwe�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)�VmomiSupportcCs6tsdStsdSdtjvrtjdkrtjdkrdSdS)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�rr�J/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/esxcluster.py�__virtual__Ps


rcst���fdd��}|S)z>
    Decorator wrapper to warn about azurearm deprecation
    cs6tjjjddtd��|itjjjdi|����}|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�argsZclean_kwargs)r�kwargs�ret��functionrr�wrappedjs�z%_deprecation_message.<locals>.wrappedr)rrrrr�_deprecation_messageesrcCsdS)zT
    Retrieves and adapt the login credentials from the proxy connection module
    Tr)�lowrrr�mod_initzsr cCsBt�d�dd�td|d�D�}|stj�d|�d���|dS)	zRetrieves the vsan_datastorezRetrieving vsan datastorecSsg|]
}|ddkr|�qS)�typeZvsanr)�.0Zdsrrr�
<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_datastoresrrr�_get_vsan_datastore�s
�
�r.c
Csvtd�}|dkr|td�d}}n|dkr(td�dtd�d}}n	tj�d|����t�d	|||�|}t�d
|�d}|idd
d�}g}i}	d}�z�t�d�t��}
t�d|
�zt	�
||
�Wnt	jjy}}ztj�|��d}~wwd}td�}
ztd|||
d�}Wn`tjj
y�d}tdr�|�d�|||��t�|d�td|
�|�dd�|�d��|YWSt�d||�td||||
d�|�d�||��t�|d�|	�d|i�Ynw|�r�d}d|v�r5d |dv�r5t|�di��d g�|�di��d g�d!�}t�d"|j�|dd =d|v�r5d |dv�r5|dd =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*|�td+||||
d�|�d,�||��t�|d�|	�||d-��td|
�d}td�r�|�r�d}|�|d�|�|	d.��|WStjj�y:}z#tjd/|dd0�|
�r$td|
�|�dt|�d��|WYd}~Sd}~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�
�r6r7z)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:
{}cSsg|]}d|���qS)z  r�r"�lrrrr#$sz&cluster_configured.<locals>.<listcomp>z8State {} will update cluster '{}' in datacenter '{}':
{}znew_values = %szvsphere.update_clusterz'Updated cluster '{}' in datacenter '{}'�r>�old�r6r7r5�	Error: %s��exc_info)r)rr*�CommandExecutionErrorr'�infor(r�	serialize�
jsonschema�validate�ValidationErrorZInvalidESXClusterPayloadErrorr+�__opts__�append�format�update�joinr�getZdiffsr�changes_strZchanges_str2�split�
new_values�
old_valuesr�error�str)r4Zcluster_configZ
proxy_typer-�datacenter_nameZcluster_dict�changes_requiredr�commentsr5�schema�exc�currentr,Zldiff�diffrVrXrYZ
ret_statusrrr�cluster_configured�s
,���
��

���
������


���
����������rcc
Cs�td�dtd�d}}|�d|��}t�d|�|iddd�}g}i}d	}z�td
�}	t|	|�}
|
d|krL|�d�|
d��t�|d
�nHd}tdrc|�d�||��t�|d
�n1t�d|
d|�td|
d||	d�|�d|�d��dd|id|
did�i}t�|d
�td|	�|�|s�dntdr�dndd�	|�|d��|WSt
jjy�}z!tj
d|dd�|	r�td|	�|�d	|jd��|WYd}~Sd}~ww)z�
    Configures the cluster's VSAN datastore

    WARNING: The VSAN datastore is created automatically after the first
    ESXi host is added to the cluster; the state assumes that the datastore
    exists and errors if it doesn't.
    r0r1r/�/z*Running vsan_datastore_configured for '%s'Nr2r3Fr8r4z;vSAN datastore is correctly named '{}'. Nothing to be done.r:Tr9z0State {} will rename the vSAN datastore to '{}'.z$Renaming vSAN datastore '%s' to '%s'zvsphere.rename_datastore)�datastore_nameZnew_datastore_namer%zRenamed vSAN datastore to '�'.Zvsan_datastorerDr;r<rFrGrHr=)r)r'rKr.rQrRrPr(rSrTrr*rJrZ�strerror)r4rer-r\�display_namerr^r5r]r,Zvsan_dsr`rrr�vsan_datastore_configuredSs|�

������
�������rics\|iddd�}|stj�d��td�dtd�d}}|�d|��}t�d	|�t�d
|�d||d�}t�d|�g}i}d
}	d
}
�z�t�d�t��}z
t	�
d|i|�Wnt	jjyn}ztj�|��d}~wwtd�}
td|
d�}|�
�D�]O\}��fdd�|D�}|s�d}
tdr�|�d�|||��t�|d�qztd�||
d�}Wn#tjjy�}z|�|j�t�|d�d}	WYd}~qd}~ww|�d|�d��t�|d�n|�d�|��t�|d�|d}t�d�td |||
d!�}|�r|dnd}|�r,|d"�k�r,|�d#�||��t�|d�qd}
|d$|d%k�rJ|�d&�||��t�|d�d}	qtd�ra|�d'�|||��t�|d�nnz
td(�||||
d)�Wn$tjj�y�}z|�|j�t�|d�d}	WYd}~qd}~ww|�d*�||��t�|d�td |||
d!�d}d+|d"<|�r�d+|d"<|�r�|d$tjk�r�d,|d$<||d-�||<qtd.|
�|�|
�s�dn
td�r�dn|	�r�d
ndd/�|�td�s�|nid0��|WStjj�y-}z"tjd1|dd2�|
�rtd.|
�|�d
|jd3��|WYd}~Sd}~ww)4a�
    Configures licenses on the cluster entity

    Checks if each license exists on the server:
        - if it doesn't, it creates it
    Check if license is assigned to the cluster:
        - if it's not assigned to the cluster:
            - assign it to the cluster if there is space
            - error if there's no space
        - if it's assigned to the cluster nothing needs to be done
    Nr2r3zNo licenses providedr0r1r/rdz$Running licenses configured for '%s'z
licenses = %s)r!r/r1zentity = %sFzValidating licenses�licensesr8zvsphere.list_licensesr$csg|]
}|d�kr|�qS)r@rrB��licenserrr#�sz'licenses_configured.<locals>.<listcomp>Tr9z>State {} will add license '{}', and assign it to cluster '{}'.r:zvsphere.add_license)r@�descriptionr%zAdded license 'rfz0License '{}' already exists. Nothing to be done.rzChecking licensed entities...zvsphere.list_assigned_licenses)�entity�entity_display_namer%r@zBLicense '{}' already assigned to cluster '{}'. Nothing to be done.Zcapacity�usedzGCannot assign license '{}' to cluster '{}'. No free capacity available.z2State {} will assign license '{}' to cluster '{}'.zvsphere.assign_license)Zlicense_key�license_namernror%z&Assigned license '{}' to cluster '{}'.z<hidden>Z	UnlimitedrDr;r<rFrGrHr=)rr*ZArgumentValueErrorr)r'rKr(rrLrMrNrOZInvalidLicenseError�itemsrPrQrRZVMwareApiError�err_msgrZr�maxsizerSrTrJrg)r4rjrr-r\rhrnr^r5Z
has_errorsZ
needs_changesr_r`r,Zexisting_licensesrqZfiltered_licensesZexisting_license�exZassigned_licensesZalready_assigned_licenseZassigned_licenserrkr�licenses_configured�s
�
��
��
�����
�
����
��
��������
������rv)N) �__doc__�loggingr�	functoolsrZsalt.exceptionsrZsalt.config.schemas.esxclusterrrZ
salt.utilsrZsalt.utils.dictdifferrZsalt.utils.listdifferrrMr
�ImportErrorZpyVmomir	r�	getLogger�__name__r'rrr r.rcrirvrrrr�<module>sD2��


@
R

Youez - 2016 - github.com/yon3zu
LinuXploit