Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/storage/purestorage/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_hg.pyo

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
mZddlm
Z
mZydd
lmZeZWnek
r�eZnXd�Zd�Zd�Zd�Zd�Zedkr�e�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys�
---
module: purefa_hg
version_added: '2.4'
short_description: Manage hostgroups on Pure Storage FlashArrays
description:
- Create, delete or modify hostgroups on Pure Storage FlashArrays.
author:
- Pure Storage ansible Team (@sdodsley) <[email protected]>
options:
  hostgroup:
    description:
    - The name of the hostgroup.
    type: str
    required: true
  state:
    description:
    - Define whether the hostgroup should exist or not.
    type: str
    default: present
    choices: [ absent, present ]
  host:
    type: list
    description:
    - List of existing hosts to add to hostgroup.
  volume:
    type: list
    description:
    - List of existing volumes to add to hostgroup.
extends_documentation_fragment:
- purestorage.fa
s6
- name: Create empty hostgroup
  purefa_hg:
    hostgroup: foo
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592

- name: Add hosts and volumes to existing or new hostgroup
  purefa_hg:
    hostgroup: foo
    host:
      - host1
      - host2
    volume:
      - vol1
      - vol2
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592

- name: Delete hosts and volumes from hostgroup
  purefa_hg:
    hostgroup: foo
    host:
      - host1
      - host2
    volume:
      - vol1
      - vol2
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592
    state: absent

# This will disconnect all hosts and volumes in the hostgroup
- name: Delete hostgroup
  purefa_hg:
    hostgroup: foo
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592
    state: absent

- name: Create host group with hosts and volumes
  purefa_hg:
    hostgroup: bar
    host:
      - host1
      - host2
    volume:
      - vol1
      - vol2
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592
t
(t
AnsibleModule(t
get_systemtpurefa_argument_spec(tpurestoragecC`sBd}x5|j�D]'}|d|jdkr|}PqqW|S(Ntnamet	hostgroup(tNonetlist_hgroupstparams(tmoduletarrayRthost((sQ/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_hg.pyt
get_hostgrouprscC`s�t}y|j|jd�Wntk
r7t}nX|jdri|j|jdd|jd�n|jdr�x/|jdD]}|j|jd|�q�Wn|jd|�dS(NRRthostlisttvolumetchanged(tTruet
create_hgroupRt	ExceptiontFalset
set_hgrouptconnect_hgroupt	exit_json(RRRtvol((sQ/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_hg.pytmake_hostgroup~s


$
cC`s�t}t||�}|j|jd�}|jddkr�|jdr�tt|jd�j|d��}|r�y$|j|jdd|�t}Wq�t	k
r�|j
dd�q�Xq�n|jd	r�|rlg|D]}|d
^q�}tt|jd	�jt|���}x�|D]A}	y!|j|jd|	�t}Wq$t	k
rdt}q$Xq$Wq�xS|jd	D]A}	y!|j|jd|	�t}Wqzt	k
r�t}qzXqzWq�n|jdrBtt|jd�j|d��}
|
rBy$|j|jdd|
�t}Wq?t	k
r;t}q?XqBn|jd	r�tt|jd	�jtg|D]}|d^qo���}xL|D]A}	y!|j
|jd|	�t}Wq�t	k
r�t}q�Xq�Wn|jd
|�dS(NRtstatetpresentRthoststaddhostlisttmsgs"Failed to add host(s) to hostgroupRR tremhostlistR
R(RRtlist_hgroup_connectionsRtlisttsett
differenceRRRt	fail_josnRtintersectiontdisconnect_hgroupR(RRRthgrouptvolumest	new_hostsR tcurrent_volstnew_volumestcvolt	old_hoststold_volumes((sQ/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_hg.pytupdate_hostgroup�sZ
&


(





&


?


cC`st}y�|j|jd�}xG|D]?}y|j|jd|d�Wq&tk
rdt}q&Xq&W|j|jd�}yT|j|jdd|d�y|j|jd�Wntk
r�t}nXWntk
r�t}nXWntk
rt}nX|j	d|�dS(NRR R'R$R(
RR(RR.RRt
get_hgroupRt
delete_hgroupR(RRRtvolsR R((sQ/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_hg.pytdelete_hostgroup�s(





c
C`sjt�}|jtdtdddt�dtdddddd	dg�d
tdd�dtdd���t|d
t�}ts�|jdd�n|jd}t	|�}t
||�}|jd
r&y)x"|jd
D]}|j|�q�WWq&tk
r"|jddj
|��q&Xn|jdr�y)x"|jdD]}|j|�qDWWq�tk
r�|jddj
|��q�Xn|r�|dkr�t||�n�|r�|jdr�|d	kr�t||�n�|r|jd
r|d	krt||�nZ|r.|d	kr.t||�n8|dkrY|d	krY|jdt�n
t||�dS(NRttypetstrtrequiredR"tdefaultR#tchoicestabsentRR)Rtsupports_check_modeR&s3purestorage sdk is required for this module in hostsHost {0} not foundsVolume {0} not foundR(RtupdatetdictRR	RtHAS_PURESTORAGEt	fail_jsonRR
Rtget_hostRtformatt
get_volumeR7R;RRR!(t
argument_specRR"RRthstR ((sQ/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_hg.pytmain�sF	!


 

 t__main__N(t
__future__RRRR<t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNtansible.module_utils.basicR	tansible.module_utils.pureR
RRRREtImportErrorRRR!R7R;RLt__name__(((sQ/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_hg.pyt<module>s*


!5


			3		.

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]