Anons79 Mini Shell

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

�
�Udac@`s	ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlZddlZddl
mZdd
lmZddlmZmZddlmZidd6dd6Zdefd��YZd�Zedkre�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys^
---
module: netapp_e_host
short_description: NetApp E-Series manage eseries hosts
description: Create, update, remove hosts on NetApp E-series storage arrays
version_added: '2.2'
author:
    - Kevin Hulquest (@hulquest)
    - Nathan Swartz (@ndswartz)
extends_documentation_fragment:
    - netapp.eseries
options:
    name:
        description:
            - If the host doesn't yet exist, the label/name to assign at creation time.
            - If the hosts already exists, this will be used to uniquely identify the host to make any required changes
        required: True
        aliases:
            - label
    state:
        description:
            - Set to absent to remove an existing host
            - Set to present to modify or create a new host definition
        choices:
            - absent
            - present
        default: present
        version_added: 2.7
    host_type:
        description:
            - This is the type of host to be mapped
            - Required when C(state=present)
            - Either one of the following names can be specified, Linux DM-MP, VMWare, Windows, Windows Clustered, or a
              host type index which can be found in M(netapp_e_facts)
        type: str
        aliases:
            - host_type_index
    ports:
        description:
            - A list of host ports you wish to associate with the host.
            - Host ports are uniquely identified by their WWN or IQN. Their assignments to a particular host are
             uniquely identified by a label and these must be unique.
        required: False
        suboptions:
            type:
                description:
                  - The interface type of the port to define.
                  - Acceptable choices depend on the capabilities of the target hardware/software platform.
                required: true
                choices:
                  - iscsi
                  - sas
                  - fc
                  - ib
                  - nvmeof
                  - ethernet
            label:
                description:
                    - A unique label to assign to this port assignment.
                required: true
            port:
                description:
                    - The WWN or IQN of the hostPort to assign to this port definition.
                required: true
    force_port:
        description:
            - Allow ports that are already assigned to be re-assigned to your current host
        required: false
        type: bool
        version_added: 2.7
    group:
        description:
            - The unique identifier of the host-group you want the host to be a member of; this is used for clustering.
        required: False
        aliases:
            - cluster
    log_path:
        description:
            - A local path to a file to be used for debug logging
        required: False
        version_added: 2.7
s;
    - name: Define or update an existing host named 'Host1'
      netapp_e_host:
        ssid: "1"
        api_url: "10.113.1.101:8443"
        api_username: admin
        api_password: myPassword
        name: "Host1"
        state: present
        host_type_index: Linux DM-MP
        ports:
          - type: 'iscsi'
            label: 'PORT_1'
            port: 'iqn.1996-04.de.suse:01:56f86f9bd1fe'
          - type: 'fc'
            label: 'FC_1'
            port: '10:00:FF:7C:FF:FF:FF:01'
          - type: 'fc'
            label: 'FC_2'
            port: '10:00:FF:7C:FF:FF:FF:00'

    - name: Ensure a host named 'Host2' doesn't exist
      netapp_e_host:
        ssid: "1"
        api_url: "10.113.1.101:8443"
        api_username: admin
        api_password: myPassword
        name: "Host2"
        state: absent
s
msg:
    description:
        - A user-readable description of the actions performed.
    returned: on success
    type: str
    sample: The host has been created.
id:
    description:
        - the unique identifier of the host on the E-Series storage-system
    returned: on success when state=present
    type: str
    sample: 00000000600A098000AAC0C3003004700AD86A52
    version_added: "2.6"

ssid:
    description:
        - the unique identifier of the E-Series storage-system with the current api
    returned: on success
    type: str
    sample: 1
    version_added: "2.6"

api_url:
    description:
        - the url of the API that this request was processed by
    returned: on success
    type: str
    sample: https://webservices.example.com:8443
    version_added: "2.6"
N(tpformat(t
AnsibleModule(trequestteseries_host_argument_spec(t	to_nativesapplication/jsonsContent-TypetAccepttHostcB`s�eZidd6dd6dd6dd6Zd�Zd	�Zed
�Zd�Zd�Zd
�Z	d�Z
d�Zd�Zd�Z
dd�Zd�ZRS(islinux dm-mpi
tvmwareitwindowsiswindows clusteredcC`s�t�}|jtdtdddddddg�dtddd	td
dg�dtdd
d	t�dtdddt�dtddd	td
dg�dtddd
dg�dtddd	t���td|dt�|_|jj|_|jj}|d|_	|d|_
|d|_|d|_|d|_
|d|_|d|_|d|_|d|_|d|_t�|_t�|_t�|_t�|_t�|_t�|_|d}|re|j�}|gt|jj��D]}|j�^q�kr-|j||_qe|j�rOt|d�|_qe|jj dd�nt!j"|j#j$�|_%|dr�t!j&dt!j'd|dd d!d"d#�n|jj(d$�s�|jd$7_n|j
dkr|jdkr|jj dd%|j�n|j
dk	r�x�|j
D]�}|dj�|d<|dj�|d<|d&j�|d&<t*j+d'|d&j,d(d)��r+|d&j,d(d)�j,d*d)�|d&<q+q+WndS(+Ntstatettypetstrtdefaulttpresenttchoicestabsenttgrouptrequiredtaliasestclustertportstlistt
force_porttbooltnametlabelthost_type_indext	host_typetlog_patht
argument_spectsupports_check_modetssidtapi_urltapi_usernametapi_passwordtvalidate_certstmsgs]host_type must be either a host type name or host type index found integer the documentation.tleveltfilenametfilemodetwtformatsS%(relativeCreated)dms %(levelname)s %(module)s.%(funcName)s:%(lineno)d
 %(message)st/sAHost_type_index is required when state=='present'. Array Id: [%s]tports^(0x)?[0-9a-f]{16}$t:tt0x(-RtupdatetdicttFalsetTrueR	tmodulet
check_modetparamsRRRR RR'turltusertpwdtcertst	post_bodyRt	all_hoststhost_objtnewPortstportsForUpdatetportsForRemovaltlowertHOST_TYPE_INDEXEStkeysR"tisdigittintt	fail_jsontloggingt	getLoggert	__class__t__name__t_loggertbasicConfigtDEBUGtendswithtNonetretmatchtreplace(tselfR%targsR#tkeyR3((sP/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_host.pyt__init__�sh	!










4
	
"c
`s�d}yEt�jd�jd�jd�jd�jdt�\}}Wn9tk
r�}�j	j
dd�jt|�f�nXy*tt
�fd�|��d	}tSWn+tk
r��j	j
dd
�j�nXdS(Nsstorage-systems/%s/host-typesturl_passwordturl_usernameR+theadersR,s4Failed to get host types. Array Id [%s]. Error [%s].c`s|d�jkS(Ntindex(R"(R#(RZ(sP/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_host.pyt<lambda>sis#There is no host type with index %s(RVR
R>R'R@R?RAtHEADERSt	ExceptionR;RMRRtfilterR:t
IndexErrorR"(RZt
host_typestrcterrRX((RZsP/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_host.pytvalid_host_type�s %"
cC`s�i}x�|jD]�}|d|jkrZx�|dD]}x|jD]}|d|dksr|d|dkrD|js�|jjdd�qOg|dD]$}|d|dkr�|d	^q�}|jg|d
D](}|dd|dkr�|d
^q��|d|j�kr7|ji||d6�qO||dj|�qDqDWq4WqxS|dD]G}x>|jD]3}|d|dkr�|d|dks�|d|dkru|d|dkru|js�|jjdd�q�g|dD]$}|d|dkr�|d	^q�}|jg|d
D](}|dd|dkr0|d
^q0�|d|j�kr�|ji||d6�q�||dj|�ququWqeWqW|r�x�|j�D]�}ykt	|j
d|j|fd|jd|j
dtd|jdddtji||d6��\}}	Wq�tk
r�}
|jjdd|jd|j||t|
�f�q�Xq�Wn|S(sgDetermine if the hostPorts requested have already been assigned and return list of required used ports.R!t
hostSidePortsR3taddressR,sOThere are no host ports available OR there are not enough unassigned host portsRthostPortNamethostPortReft
initiatorstnodeNamet
iscsiNodeNametinitiatorRefthostRefsstorage-systems/%s/hosts/%sR_R^R`R+tmethodtPOSTtdatat
portsToRemovesRFailed to unassign host port. Host Id [%s]. Array Id [%s]. Ports [%s]. Error [%s].tid(RCR RRR;RMtextendRJR7R
R>R'R?R@RcRAtjsontdumpsRdRDR(RZtapply_unassigningtused_host_portsthostt	host_portR3tport_refthost_refRhtrespRi((sP/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_host.pytassigned_host_portssP(	$)#((	$)$'#c
`s��jr�yEt�jd�jd�jd�jd�jdt�\}}Wn9tk
r�}�j	j
dd�jt|�f�nXy.tt
�fd�|��d	}|d
SWq�tk
r��j	j
dd�j�q�XndSdS(
Nsstorage-systems/%s/host-groupsR^R_R+R`R,s5Failed to get host groups. Array Id [%s]. Error [%s].c`s|d�jkS(NR (R(R(RZ(sP/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_host.pyRbLsiRxs!No group with the name: %s existst(0000000000000000000000000000000000000000(RR
R>R'R@R?RARcRdR;RMRRReRf(RZRht
all_groupsRit	group_obj((RZsP/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_host.pytgroup_idAs		%"
!c	
C`s�t}t�}yEt|jd|jd|jd|jd|jdt�\}}Wn9t	k
r�}|j
jdd|jt|�f�nXx�|D]�}xN|dD]B}|d	j
�|d	<|d
j
�|d
<|dj
�|d<q�Wtd�|d
D��}|jd�|dD��x7|dD]+}|d|kr.||d|d<q.q.W|d|jkr�||_t}q�q�W||_|S(s�Determine if the requested host exists
        As a side effect, set the full list of defined hosts in 'all_hosts', and the target host in 'host_obj'.
        sstorage-systems/%s/hostsR^R_R+R`R,s>Failed to determine host existence. Array Id [%s]. Error [%s].RkRRlR!cs`s#|]}|d|dfVqdS(R!RxN((t.0R3((sP/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_host.pys	<genexpr>jsRcs`s#|]}|d|dfVqdS(R!RxN((R�R3((sP/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_host.pys	<genexpr>ksRoRx(R9RR
R>R'R@R?RARcRdR;RMRRHR8R7R RDR:RC(	RZRXRCRhRiR~R3Rthost_side_port((sP/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_host.pythost_existsTs.	 %
	
	c	C`s�t}|jdj�|j�j�ksA|jd|jkrZ|jjd�t}ntd�|jdD��}|j	r�x#|j	D]}x|j
�D]�}|||kr�|j|�Pq�|d||dkr�|j|�r|j
r|jjdd|�n|d	||d	ks?|d
||d
kr�|j|�|jji|d6|dd6|d	d	6|jdd6�Pq�q�q�W|jj|�q�Wt|j
��|_t|j|j|j|g�}n|S(
s�Determine whether we need to update the Host object
        As a side effect, we will set the ports that we need to update (portsForUpdate), and the ports we need to add
        (newPorts), on self.
        t
clusterReft
hostTypeIndexsGEither hostType or the clusterRef doesn't match, an update is required.cs`s@|]6}|di|dd6|dd6|dd6fVqdS(RxRRlR3R!N((R�R3((sP/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_host.pys	<genexpr>�sRkR3R,sxThe port you specified [%s] is associated with a different host. Specify force_port as True or try a different port specR!RtportRefRs(R9RDRHR�R"RRtinfoR:R8RRJtpoptport_on_diff_hostRR;RMRFtappendRERRGtany(RZtchangedtcurrent_host_portsR3tcurrent_host_port_id((sP/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_host.pytneeds_updatexs6%			

$cC`sxxq|jD]f}|d|jkr
xJ|dD];}|d|dks\|d|dkr.||_tSq.Wq
q
WtS(sF Checks to see if a passed in port arg is present on a different host R RkR!R3Rl(RCR t
other_hostR:R9(RZtarg_portR~R3((sP/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_host.pyR��s(	cC`s�|jjd|j�|jrn|jdt�|j|jd<|j|jd<|jjdt	|j��n|jjd�|j
r�|j�|jd<ntd|j
�|jd	<|jd
|j|jdf}|jjd|t	|j��|js�yRt|d
|jd|jdtd|jdddtj|j��\}|_Wq�tk
r�}|jjdd|jt|�f�q�Xn|j|j�}|jjdt|�dS(Ns!Beginning the update for host=%s.R|t
portsToUpdateRsRequested ports: %ssNo host ports were defined.tgroupIdRathostTypesstorage-systems/%s/hosts/%sRxsPOST => url=%s, body=%s.R_R^R`R+RtRuRvR,s1Failed to update host. Array Id [%s]. Error [%s].R�(RRR�R RR�R:RFRBRERRR�R8R"R>R'RDR<R
R?R@RcRARzR{RdR;RMRtbuild_success_payloadt	exit_json(RZtapiRhRitpayload((sP/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_host.pytupdate_host�s*		!	!1!cC`s�|jjd�|jdt�td|jdtd|j�d|j��}|jro|j	d|j�n|j
d|j}|jjd	|t|��|j
s�|j�sByOt|d
dd|jd
|jd|jdtj|�dt�\}|_Wq�tk
r>}|jjdd|jt|�f�q�Xq�|j|j�}|jjdtdd|j|jf|�n|j|j�}|jjdtdd|�dS(NsCreating host definition.R|R R�RaR�Rsstorage-systems/%s/hostssPOST => url=%s, body=%sRtRuR_R^R+RvR`R,s1Failed to create host. Array Id [%s]. Error [%s].R�s(Host already exists. Id [%s]. Host [%s].s
Host created.(RRR�R�R:R8R R"R�RR7R>R'RR<R�R
R?R@RARzR{RcRDRdR;RMRR�R�R9(RZRBR�RhRiR�((sP/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_host.pytcreate_host�s,			*%!/c
C`s�yRt|jd|j|jdfddd|jd|jd|j�\}}WnCtk
r�}|jj	dd	|jd|jt
|�f�nXdS(
Nsstorage-systems/%s/hosts/%sRxRttDELETER_R^R+R,s<Failed to remove host.  Host[%s]. Array Id [%s]. Error [%s].(R
R>R'RDR?R@RARdR;RMR(RZRhR�Ri((sP/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_host.pytremove_host�s$(
c`s[dg}�dk	r4t�fd�|D��}n	t�}|j|d<|j|d<|S(NRxc3`s|]}|�|fVqdS(N((R�R\(R~(sP/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_host.pys	<genexpr>�sR'R((RVR8R'R>(RZR~RJtresult((R~sP/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_host.pyR��s		

cC`s�|jdkr�|j�rq|j�r@|j�r@|j�q�|j|j�}|jjdt	dd|�q�|j�r�|j
�q�n]|j�}|j�r�|j�|jjdtdd|�n|jjdt	dd|�dS(NRR�R,s*Host already present; no changes required.s
Host removed.sHost already absent.(
RR�R�RjR�R�RDR;R�R9R�R�R:(RZR�((sP/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_host.pytapplys

N(RQt
__module__RIR]RjR9R�R�R�R�R�R�R�R�RVR�R�(((sP/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_host.pyR�s"	F	;		$	&		!	"	
cC`st�}|j�dS(N(RR�(R~((sP/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_host.pytmains	t__main__(t
__future__RRRRt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNRzRNRWtpprintRtansible.module_utils.basicR	tansible.module_utils.netappR
Rtansible.module_utils._textRRctobjectRR�RQ(((sP/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_host.pyt<module>s,


S 
�h	

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