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_pg.pyo

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
mZddlm
Z
mZd
Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zedkr�e�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys
---
module: purefa_pg
version_added: '2.4'
short_description: Manage protection groups on Pure Storage FlashArrays
description:
- Create, delete or modify protection groups on Pure Storage FlashArrays.
- If a protection group exists and you try to add non-valid types, eg. a host
  to a volume protection group the module will ignore the invalid types.
- Protection Groups on Offload targets are supported.
author:
- Pure Storage Ansible Team (@sdodsley) <[email protected]>
options:
  pgroup:
    description:
    - The name of the protection group.
    type: str
    required: true
  state:
    description:
    - Define whether the protection group should exist or not.
    type: str
    default: present
    choices: [ absent, present ]
  volume:
    description:
    - List of existing volumes to add to protection group.
    type: list
  host:
    description:
    - List of existing hosts to add to protection group.
    type: list
  hostgroup:
    description:
    - List of existing hostgroups to add to protection group.
    type: list
  eradicate:
    description:
    - Define whether to eradicate the protection group on delete and leave in trash.
    type : bool
    default: 'no'
  enabled:
    description:
    - Define whether to enabled snapshots for the protection group.
    type : bool
    default: 'yes'
  target:
    description:
    - List of remote arrays or offload target for replication protection group
      to connect to.
    - Note that all replicated protection groups are asynchronous.
    - Target arrays or offload targets must already be connected to the source array.
    - Maximum number of targets per Protection Group is 4, assuming your
      configuration supports this.
    type: list
    version_added: '2.8'
extends_documentation_fragment:
- purestorage.fa
s�
- name: Create new local protection group
  purefa_pg:
    pgroup: foo
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592

- name: Create new replicated protection group
  purefa_pg:
    pgroup: foo
    target:
      - arrayb
      - arrayc
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592

- name: Create new replicated protection group to offload target and remote array
  purefa_pg:
    pgroup: foo
    target:
      - offload
      - arrayc
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592

- name: Create new protection group with snapshots disabled
  purefa_pg:
    pgroup: foo
    enabled: false
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592

- name: Delete protection group
  purefa_pg:
    pgroup: foo
    eradicate: true
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592
    state: absent

- name: Eradicate protection group foo on offload target where source array is arrayA
  purefa_pg:
    pgroup: "arrayA:foo"
    target: offload
    eradicate: true
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592
    state: absent

- name: Create protection group for hostgroups
  purefa_pg:
    pgroup: bar
    hostgroup:
      - hg1
      - hg2
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592

- name: Create protection group for hosts
  purefa_pg:
    pgroup: bar
    host:
      - host1
      - host2
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592

- name: Create replicated protection group for volumes
  purefa_pg:
    pgroup: bar
    volume:
      - vol1
      - vol2
    target: arrayb
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592
t
(t
AnsibleModule(t
get_systemtpurefa_argument_specs1.16cC`s{g}y|j�}Wntk
r*dSXxItdt|��D]2}||ddkrA|j||d�qAqAW|S(sGet Offload TargetsiRt	connectedtnameN(tlist_offloadt	ExceptiontNonetrangetlentappend(tarrayttargetsttarget_detailst	targetcnt((sQ/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_pg.pytget_targets�s
cC`s\g}|j�}xCtdt|��D],}||dr(|j||d�q(q(W|S(s Get Connected ArraysiRt
array_name(tlist_array_connectionsRRR(Rtarrayst
array_detailstarraycnt((sQ/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_pg.pyt
get_arrays�scC`s�d}d|jdkrjx�|jdtdd�D]1}|d|jdkr2|dr2|}Pq2q2WnHxE|jdt�D]1}|d|jdkr}|dr}|}Pq}q}W|S(	s Get Protection Groupt:tpgrouptpendingtont*R
ttime_remainingN(Rtparamstlist_pgroupstTrue(tmoduleRR tpgrp((sQ/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_pg.pytget_pending_pgroup�s!!cC`s�d}d|jdkrZxv|jdd�D]'}|d|jdkr,|}Pq,q,Wn8x5|j�D]'}|d|jdkrg|}PqgqgW|S(s Get Protection GroupRR R"R#R
N(RR%R&(R(RR R)((sQ/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_pg.pyt
get_pgroup�scC`sHd}x;|jdt�D]'}|d|jdkr|}PqqW|S(s Get Protection Group ScheduletscheduleR
R N(RR&R'R%(R(RR R)((sQ/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_pg.pytget_pgroup_sched�scC`s�|j�d}|d|jd}t|�}x^|D]V}|jdtd|�}x5tdt|��D]}|||dkrl|SqlWq8WdS(	s. Check if PG already exists on offload target RRR R!R"iR
N(tgetR%RR&R'RRR(R(RRt	remote_pgRttargett
remote_pgstrpg((sQ/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_pg.pytcheck_pg_on_offload�s
cC`s�t}|jdrt|j�}g}t|�}t|kr�t|�}t||�}|r�||jddd!kr�|jddj|jd|��q�n||}|gkr�|jdd�nt	|jddd!�j
|�ray,|j|jdd|jddd!�Wqqtk
r]|jdd	j|jd|jddd!��qqXq�|jdd
�nLy|j|jd�Wn1tk
r�|jddj|jd��nXyV|jdr�|j
|jdd|jd
�n!|j
|jdd|jd
�Wn1tk
rI|jddj|jd��nX|jdr�y%|j
|jdd|jd�Wq�tk
r�|jddj|jd��q�Xn|jdry%|j
|jdd|jd�Wqtk
r|jddj|jd��qXn|jdr�y%|j
|jdd|jd�Wq�tk
r�|jddj|jd��q�Xnt}|jd|�dS(s Create Protection GroupR0iitmsgs:Protection Group {0} already exists on offload target {1}.R s%No connected targets on source array.t
targetlists-Creation of replicated pgroup {0} failed. {1}s=Check all selected targets are connected to the source array.sCreation of pgroup {0} failed.treplicate_enabledtenabledtsnap_enabledsEnabling pgroup {0} failed.tvolumetvollists$Adding volumes to pgroup {0} failed.thostthostlists"Adding hosts to pgroup {0} failed.t	hostgroupt
hgrouplists'Adding hostgroups to pgroup {0} failed.tchangedN(tFalseR%t_list_available_rest_versionsRtOFFLOAD_API_VERSIONRR3t	fail_jsontformattsettissubsett
create_pgroupRt
set_pgroupR't	exit_json(R(RR?tapi_versiontconnected_targetstconnected_arraystoffload_name((sQ/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_pg.pytmake_pgroup�s\
 )
#,
8
$
$%
$
%
'
%
'
%
'c
`s�t}�jdr��j�}g}t��}t|kr�t��}t���}|r�|�jddd!kr��jddj�jd|��q�n||}|gkr��jdd�n�j	�jd�d}g}|r(x5t
dt|��D]}	|j||	d	�qWnt
�jddd!�t
|�kr�t
�jddd!�j|�s��jdd
�ny2�j�jdd�jddd!�t}Wq�tk
r��jddj�jd��q�Xq�n�jdr�jd
t���dkry+�j�jdd�jd
�t}Wqtk
r{�jddj�jd��qXn��jdr�jd
t���dkry+�j�jdd�jd
�t}Wqtk
r�jddj�jd��qXn�jdrTt	���dd$krTt	���dd$krTt	���dd$kr�y+�j�jdd�jd�t}WqQtk
r��jddj�jd��qQXqTt��fd��jdD��sTy+�j�jdd�jd�t}WqQtk
rM�jddj�jd��qQXqTn�jdr�t	���dd$kr�t	���dd$kr�t	���dd$k	ry+�j�jdd�jd�t}Wq�tk
r
�jddj�jd��q�Xq�t��fd��jdD��s�y+�j�jdd�jd�t}Wq�tk
r��jddj�jd��q�Xq�n�jdr�t	���dd$kr�t	���dd$kr�t	���dd$k	rSy+�j�jdd�jd�t}Wq�tk
rO�jdd j�jd��q�Xq�t��fd!��jdD��s�y+�j�jdd�jd�t}Wq�tk
r��jdd"j�jd��q�Xq�n�jd#|�d$S(%s Update Protection GroupR0iiR4s:Protection Group {0} already exists on offload target {1}.R s%No targets connected to source array.RR
s=Check all selected targets are connected to the source array.R5s'Changing targets for pgroup {0} failed.R7R6s-Changing enabled status of pgroup {0} failed.R8R9thoststhgroupstvolumesR:s$Adding volumes to pgroup {0} failed.c3`s(|]}|t���dkVqdS(RQN(R+(t.0tx(RR((sQ/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_pg.pys	<genexpr>bss&Changing volumes in pgroup {0} failed.R;R<s"Adding hosts to pgroup {0} failed.c3`s(|]}|t���dkVqdS(RON(R+(RRRS(RR((sQ/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_pg.pys	<genexpr>qss$Changing hosts in pgroup {0} failed.R=R>s'Adding hostgroups to pgroup {0} failed.c3`s(|]}|t���dkVqdS(RPN(R+(RRRS(RR((sQ/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_pg.pys	<genexpr>�ss)Changing hostgroups in pgroup {0} failed.R?N(R@R%RARRBRR3RCRDR+RRRRERFRHR'RR-RtallRI(
R(RR?RJRKRLRMtcurrent_connectstcurrent_targetsR((RR(sQ/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_pg.pyt
update_pgroup,s�
 )
&#(

*-!

'.!

'?!

'&!

*?!

'&!

*?!

'&!

*cC`s�t}d|jdkr�y@dj|jd�}|j|jdd|dt�t}Wq�tk
r�|jddj|jd��q�XnXy$|j|jddt�t}Wn1tk
r�|jddj|jd��nX|jd	|�d
S(s Eradicate Protection GroupRR tR0R"t	eradicateR4sEradicating pgroup {0} failed.R?N(	R@R%tjointdestroy_pgroupR'RRCRDRI(R(RR?R0((sQ/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_pg.pyteradicate_pgroup�s 

'

$cC`s
t}d|jdkr�y:dj|jd�}|j|jdd|�t}Wq�tk
r�|jddj|jd��q�XnRy|j|jd�t}Wn1tk
r�|jddj|jd��nX|jdr�t||�n|j	d	|�d
S(s Delete Protection GroupRR RXR0R"R4sDeleting pgroup {0} failed.RYR?N(
R@R%RZR[R'RRCRDR\RI(R(RR?R0((sQ/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_pg.pyt
delete_pgroup�s 

'

$
c
C`s�t�}|jtdtdddt�dtdddddd	dg�d
tdd�dtdd�d
tdd�dtdd�dtdddt�dtdddt���d
dd
gg}t|d|dt�}|jd}t|�}|j�}d|jdkr6t	|kr6|j
dd�nt||�}t||�}|jdr�y)x"|jdD]}|j
|�qrWWq�tk
r�|j
ddj|��q�Xn|jd
r y)x"|jd
D]}	|j|	�q�WWq tk
r|j
ddj|	��q Xn|rB|dkrBt||�n�|rd|d	krdt||�n�|r�|d	kr�|jdr�t||�nU|r�|r�|dkr�t||�n+|dkr�|d	kr�|jdt�ndS(NR ttypetstrtrequiredtstatetdefaulttpresenttchoicestabsentR9tlistR;R=R0RYtboolR7tmutually_exclusivetsupports_check_modeRR4s7API version does not support offload protection groups.sHost {0} not foundsHostgroup {0} not foundR?(RtupdatetdictR'R@R	R%R
RARBRCR+R*tget_hostRRDt
get_hgroupRWR]R\RNRRI(
t
argument_specRhR(RaRRJR txpgroupthstthstg((sQ/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_pg.pytmain�sV	!		


 

 t__main__N(t
__future__RRRR^t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNtansible.module_utils.basicR	tansible.module_utils.pureR
RRBRRR*R+R-R3RNRWR\R]Rrt__name__(((sQ/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_pg.pyt<module>s.


<N						
	6	^			5

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