File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/purefb.cpython-310.pyc
o
�N�g�6 � @ s� d Z ddlZddlmZ ddlmZ zddlmZmZmZm Z m
Z
mZmZ dZ
W n ey3 dZ
Y nw dZd Zd
d� Zdd
� Zdd� Zdd� Zdd� Zd&dd�Zd'dd�Zd&dd�Z d(dd�Zd)dd�Zd d!� Zd"d#� Zd)d$d%�ZdS )*a&
Management of Pure Storage FlashBlade
Installation Prerequisites
--------------------------
- You will need the ``purity_fb`` python package in your python installation
path that is running salt.
.. code-block:: bash
pip install purity_fb
- Configure Pure Storage FlashBlade authentication. Use one of the following
three methods.
1) From the minion config
.. code-block:: yaml
pure_tags:
fb:
san_ip: management vip or hostname for the FlashBlade
api_token: A valid api token for the FlashBlade being managed
2) From environment (PUREFB_IP and PUREFB_API)
3) From the pillar (PUREFB_IP and PUREFB_API)
:maintainer: Simon Dodsley (simon@purestorage.com)
:maturity: new
:requires: purity_fb
:platform: all
.. versionadded:: 2019.2.0
� N)�datetime)�CommandExecutionError)�
FileSystem�FileSystemSnapshot�NfsRule�ProtocolRule�PurityFb�SnapshotSuffix�restTFzrestructuredtext enZpurefbc C s t rtS dS )z6
Determine whether or not to load this module
)FzKpurefb execution module not loaded: purity_fb python library not available.)�
HAS_PURITY_FB�__virtualname__� r
r
�G/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/purefb.py�__virtual__N s r c C s z t d d �d�} t d d �d�}| rtrt| �}|�� W nO tttfyo ztj �d�} tj �d�}| rAt| �}|�� W n* t
ttfyl ztd }ttd �}|�� W n
ttfyi td��w Y nw Y nw z|�
|� W |S ty� td��w ) ad
Get Pure Storage FlasBlade configuration
1) From the minion config
pure_tags:
fb:
san_ip: management vip or hostname for the FlashBlade
api_token: A valid api token for the FlashBlade being managed
2) From environment (PUREFB_IP and PUREFB_API)
3) From the pillar (PUREFB_IP and PUREFB_API)
Z pure_tagsZfbZsan_ip� api_tokenZ PUREFB_IPZ
PUREFB_APIz-No Pure Storage FlashBlade credentials found.z.Pure Storage FlashBlade authentication failed.)Z__opts__�getZapir Zdisable_verify_ssl�KeyError� NameError� TypeError�os�environ�
ValueErrorZ
__pillar__r Zlogin� Exception)Z
blade_namer �blader
r
r �
_get_bladeZ sF ����������r c C s@ g }|� | � z
|jj|d�}|jd W S tjy Y dS w )zE
Private function to
check for existence of a filesystem
)�namesr N)�append�file_systemsZlist_file_systems�itemsr
�ApiException)�namer �_fs�resr
r
r �_get_fs� s
�r# c C sD zd| � d|� d�}|j j|d�}|jd W S tjy! Y dS w )z-
Return name of Snapshot
or None
zsource='z' and suffix='�')�filterr N)�file_system_snapshotsZlist_file_system_snapshotsr r
r )r �suffixr Zfiltr"