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

�
�Udac@`sddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
mZddlm
Z
mZd
ZdZdZd�Zed�Zed�Zd�Zd�Zed�Zed�Zd�Zd�Zd�Zd�Zd�Zedkre�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys�
---
module: purefa_host
version_added: '2.4'
short_description: Manage hosts on Pure Storage FlashArrays
description:
- Create, delete or modify hosts on Pure Storage FlashArrays.
author:
- Pure Storage Ansible Team (@sdodsley) <[email protected]>
notes:
- If specifying C(lun) option ensure host support requested value
options:
  host:
    description:
    - The name of the host.
    type: str
    required: true
  state:
    description:
    - Define whether the host should exist or not.
    - When removing host all connected volumes will be disconnected.
    type: str
    default: present
    choices: [ absent, present ]
  protocol:
    description:
    - Defines the host connection protocol for volumes.
    type: str
    default: iscsi
    choices: [ fc, iscsi, nvme, mixed ]
  wwns:
    type: list
    description:
    - List of wwns of the host if protocol is fc or mixed.
  iqn:
    type: list
    description:
    - List of IQNs of the host if protocol is iscsi or mixed.
  nqn:
    type: list
    description:
    - List of NQNs of the host if protocol is nvme or mixed.
    version_added: '2.8'
  volume:
    type: str
    description:
    - Volume name to map to the host.
  lun:
    description:
    - LUN ID to assign to volume for host. Must be unique.
    - If not provided the ID will be automatically assigned.
    - Range for LUN ID is 1 to 4095.
    type: int
    version_added: '2.8'
  personality:
    type: str
    description:
    - Define which operating system the host is. Recommended for
      ActiveCluster integration.
    default: ''
    choices: ['hpux', 'vms', 'aix', 'esxi', 'solaris', 'hitachi-vsp', 'oracle-vm-server', 'delete', '']
    version_added: '2.7'
  preferred_array:
    type: list
    description:
    - List of preferred arrays in an ActiveCluster environment.
    - To remove existing preferred arrays from the host, specify I(delete).
    version_added: '2.9'
extends_documentation_fragment:
- purestorage.fa
s@
- name: Create new AIX host
  purefa_host:
    host: foo
    personaility: aix
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592

- name: Delete host
  purefa_host:
    host: foo
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592
    state: absent

- name: Make host bar with wwn ports
  purefa_host:
    host: bar
    protocol: fc
    wwns:
    - 00:00:00:00:00:00:00
    - 11:11:11:11:11:11:11
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592

- name: Make host bar with iSCSI ports
  purefa_host:
    host: bar
    protocol: iscsi
    iqn:
    - iqn.1994-05.com.redhat:7d366003913
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592

- name: Make host bar with NVMe ports
  purefa_host:
    host: bar
    protocol: nvme
    nqn:
    - nqn.2014-08.com.vendor:nvme:nvm-subsystem-sn-d78432
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592

- name: Make mixed protocol host
  purefa_host:
    host: bar
    protocol: mixed
    nqn:
    - nqn.2014-08.com.vendor:nvme:nvm-subsystem-sn-d78432
    iqn:
    - iqn.1994-05.com.redhat:7d366003914
    wwns:
    - 00:00:00:00:00:00:01
    - 11:11:11:11:11:11:12
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592

- name: Map host foo to volume bar as LUN ID 12
  purefa_host:
    host: foo
    volume: bar
    lun: 12
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592

- name: Add preferred arrays to host foo
  purefa_host:
    host: foo
    preferred_array:
    - array1
    - array2
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592

- name: Delete preferred arrays from host foo
  purefa_host:
    host: foo
    preferred_array: delete
    fa_url: 10.10.10.2
    api_token: e31060a7-21fc-e277-6240-25983c6c4592
t
(t
AnsibleModule(t
get_systemtpurefa_argument_specs1.14s1.15s1.16cC`sQ|jddkro|jdroy%|j|jdd|jd�Wqltk
rh|jdd�qlXqon|jddkr�|jd
r�y%|j|jdd|jd
�Wq�tk
r�|jdd�q�Xq�n|jddkrM|jdrMy%|j|jdd|jd�WqJtk
rF|jdd�qJXqMndS(sSet host initiators.tprotocoltnvmetmixedtnqnthosttnqnlisttmsgsSetting of NVMe NQN failed.tiscsitiqntiqnlistsSetting of iSCSI IQN failed.tfctwwnstwwnlistsSetting of FC WWNs failed.N(R
R(RR(sfcR(tparamstset_hostt	Exceptiont	fail_json(tmoduletarray((sS/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_host.pyt_set_host_initiators�s*





cC`sS|jddkr�|jdr�|j|jd�d}||jdkr�y+|j|jdd|jd�t}Wq�tk
r�|jdd�q�Xq�q�n|jddkrJ|jd
rJ|j|jd�d
}||jd
krGy+|j|jdd|jd
�t}WqDtk
r@|jdd�qDXqGqJn|jddkrO|jdrOg|jdD]}|jdd�^qx|jd<g|jdD]}|j�^q�|jd<|j|jd�d}||jdkrLy+|j|jdd|jd�t}WqItk
rE|jdd�qIXqLqOn|S(s9Change host initiator if iscsi or nvme or add new FC WWNsRR
RRRRRsChange of NVMe NQN failed.RRRsChange of iSCSI IQN failed.RRt:ttwwnRsFC WWN change failed.(snvmesmixed(siscsismixed(sfcsmixed(Rtget_hostRtTrueRRtreplacetupper(RRtanswertcurrent_nqntcurrent_iqnR"tcurrent_wwn((sS/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_host.pyt_update_host_initiators�sB






3-

cC`s�|j�}t|kr�|jdr�y5|j|jd|jdd|jd�t}Wq�tk
r�|jddj|jd��q�Xn$|j|jd|jd�t}|S(sConnect volume to hosttlunRtvolumeRs0LUN ID {0} invalid. Check for duplicate LUN IDs.(t_list_available_rest_versionstAC_REQUIRED_API_VERSIONRtconnect_hostR$RRtformat(RRR'tapi_version((sS/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_host.pyt_connect_new_volume�s


'cC`sU|jddkr7|j|jdd|jd�n|j|jddd�dS(s0Set host personality. Only called when supportedtpersonalitytdeleteRR!N(RR(RR((sS/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_host.pyt_set_host_personalityscC`sX|jddgkr:|j|jdd|jd�n|j|jddd�dS(s4Set preferred array list. Only called when supportedtpreferred_arrayR5RR4R!N(RR(RR((sS/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_host.pyt_set_preferred_arrayscC`sg|j|jddt�d}|d	kr�|jddkr�y+|j|jdd|jd�t}Wq�tk
r�|jdd�q�Xn|d	k	rc|jddkr�y$|j|jddd�t}Wq`tk
r�|jdd�q`Xqc||jdkrcy+|j|jdd|jd�t}Wq`tk
r\|jdd�q`Xqcn|S(
s3Change host personality. Only called when supportedRR4R5RsPersonality setting failed.R!sPersonality deletion failed.sPersonality change failed.N(R#RR$tNoneRRR(RRR'R4((sS/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_host.pyt_update_host_personalitys. 





cC`s�|j|jddt�d}|gkr�|jddgkr�y+|j|jdd|jd�t}Wq�tk
r�|jddj|jd��q�Xn�|gkr�|jddgkr!y$|j|jddg�t}Wq�tk
r|jddj|jd��q�Xq�||jdkr�y+|j|jdd|jd�t}Wq�tk
r�|jddj|jd��q�Xq�n|S(s@Update existing preferred array list. Only called when supportedRR7R5Rs-Preferred array list creation failed for {0}.s-Preferred array list deletion failed for {0}.s+Preferred array list change failed for {0}.(R#RR$RRRR1(RRR'R7((sS/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_host.pyt_update_preferred_array0s. "

'

'

*cC`sBd}x5|j�D]'}|d|jdkr|}PqqW|S(NtnameR(R9t
list_hostsR(RRRthst((sS/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_host.pyR#KscC`s~t}|jsjy|j|jd�Wn1tk
rZ|jddj|jd��nXy�t||�|j�}t	|kr�|jdr�t
||�nt|kr�|jdr�t||�n|jdr2|jdr|j
|jd|jdd|jd�q2|j
|jd|jd�nWqjtk
rf|jddj|jd��qjXn|jd	|�dS(
NRRsHost {0} creation failed.R4R7R-R,sHost {0} configuration failed.tchanged(R$t
check_modetcreate_hostRRRR1RR.R/R6tPREFERRED_ARRAY_API_VERSIONR8R0t	exit_json(RRR?R2((sS/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_host.pyt	make_hostTs,	
$



%
'cC`sYt}|jsEt}}}}|j|jd�}|jds^|jds^|jdrpt||�}n|jdr�g|D]}|d^q�}	|jd|	kr�t||�}q�n|j�}
t|
kr�|jdr�t	||�}q�nt
|
kr*|jdr*t||�}q*n|p?|p?|p?|}n|jd	|�dS(
NRRRRR-tvolR4R7R?(
R$R@tFalsetlist_host_connectionsRR+R3R.R/R:RBR;RC(RRR?tinit_changedtvol_changedtpers_changedtpref_changedtvolumesREtcurrent_volsR2((sS/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_host.pytupdate_hostns&	'


cC`s�t}|js�yTx9|j|jd�D]!}|j|jd|d�q)W|j|jd�Wq�tk
r�|jddj|jd��q�Xn|j	d|�dS(NRRERsHost {0} deletion failedR?(
R$R@RGRtdisconnect_hosttdelete_hostRRR1RC(RRR?RE((sS/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_host.pyRP�s	
'c
"C`s�t�}|jtdtdddt�dtdddddd	dg�d
tdddddddd
dg�dtdd�dtdd�dtdd�dtdd�dtdd�dtddddddddddddddg	�d tdd��
�t|d!t�}t|�}|j�}|jddk	rbt	|krb|j
d"d#�n|jd}t||�}|jdr�d$|jdko�d%knr�|j
d"d&j|jd��n|jdr.y|j
|jd�Wq.tk
r*|j
d"d'j|jd��q.Xn|jd rDy�|jd dgkr|j�}|sy|j
d"d(�n;g}x2td)t|��D]}|j||d*�q�Wxetd)t|jd ��D]D}	|jd |	|kr�|j
d"d+j|jd |	��q�q�WnWqDtk
r@|j
d"d,�qDXn|dkrl|dkrlt||�no|r�|dkr�t||�nM|r�|d	kr�t||�n+|dkr�|d	kr�|jd-t�ndS(.NRttypetstrtrequiredtstatetdefaulttpresenttchoicestabsentRRRR
RRtlistRRR-R,tintR4R!thpuxtvmstaixtesxitsolarisshitachi-vspsoracle-vm-serverR5R7tsupports_check_modeRs7NVMe protocol not supported. Please upgrade your array.ii�s)LUN ID of {0} is out of range (1 to 4095)sVolume {0} not foundsRNo target arrays connected to source array. Setting preferred arrays not possible.it
array_names,Array {0} not in existing array connections.s)Failed to get existing array connections.R?(RtupdatetdictR$R	R
R.RR9tNVME_API_VERSIONRR#R1t
get_volumeRtlist_array_connectionstrangetlentappendRDRNRPRCRF(
t
argument_specRRR2RTRtall_connected_arraystcurrent_arrayst
current_arraytarray_to_connect((sS/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_host.pytmain�sd	!'
1#

'
#2
t__main__N( t
__future__RRRRQt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNtansible.module_utils.basicR	tansible.module_utils.pureR
RR/RBRdRRFR+R3R6R8R:R;R#RDRNRPRot__name__(((sS/usr/lib/python2.7/site-packages/ansible/modules/storage/purestorage/purefa_host.pyt<module>s4


HR	%										:

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