File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/__pycache__/vsan.cpython-310.pyc
o
�N�g\D � @ s d Z ddlZddlZddlZddlZddlmZmZm Z zddl
mZmZ dZ
W n ey3 dZ
Y nw z
ddlmZ dZW n eyI dZY nw e�e�Zdd � Zd
d� Zdd
� Zdd� Zd dd�Zdd� Zdd� Z d!dd�Z d"dd�Zdd� Zdd� Zdd� Z dS )#a^
Connection library for VMware vSAN endpoint
This library used the vSAN extension of the VMware SDK
used to manage vSAN related objects
:codeauthor: Alexandru Bleotu <alexandru.bleotu@morganstaley.com>
Dependencies
~~~~~~~~~~~~
- pyVmomi Python Module
pyVmomi
-------
PyVmomi can be installed via pip:
.. code-block:: bash
pip install pyVmomi
.. note::
versions of Python. If using version 6.0 of pyVmomi, Python 2.6,
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 VMware utils file
was developed against.
� N)�VMwareApiError�VMwareObjectRetrievalError�VMwareRuntimeError)�vim�vmodlTF)�vsanapiutilsc C s t rtrdS dS )z,
Only load if PyVmomi is installed.
T)Fz`Missing dependency: The salt.utils.vsan module requires pyvmomi and the pyvsan extension library)�
HAS_PYVSAN�HAS_PYVMOMI� r
r
�C/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/vsan.py�__virtual__J s r c
C s� z| j jj}W nH tjjy" } z
t�|� td|j � ���d}~w tjj
y9 } z
t�|� t|j��d}~w tj
yO } z
t�|� t|j��d}~ww t|�d�d �dk r]dS dS )z�
Returns whether vsan is supported on the vCenter:
api version needs to be 6 or higher
service_instance
Service instance to the host or vCenter
�,Not enough permissions. Required privilege: N�.r � FT)�contentZaboutZ
apiVersionr �fault�NoPermission�log� exceptionr �privilegeId�VimFault�msgr �RuntimeFaultr �int�split)�service_instance�api_version�excr
r
r �vsan_supportedX s(
��
�
��r c C �H d}t jdd� dkrt�� }d|_tj|_| j}tj ||d�}|d S )z�
Returns a vim.cluster.VsanVcClusterConfigSystem object
service_instance
Service instance to the host or vCenter
N� �� � � F��contextzvsan-cluster-config-system�
�sys�version_info�ssl�create_default_context�check_hostname� CERT_NONE�verify_modeZ_stubr ZGetVsanVcMos�r r&