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/na_ontap_interface.pyc

�
�Udac@`s�dZddlmZmZmZeZidd6dgd6dd6Zd	Zd
Z	dZ
ddlZdd
lm
Z
ddlmZddlmZddljjZej�Zdefd��YZd�Zedkr�e�ndS(s� this is interface module

 (c) 2018-2019, NetApp, Inc
 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	certifiedtsupported_bys

---

module: na_ontap_interface
short_description: NetApp ONTAP LIF configuration

extends_documentation_fragment:
    - netapp.na_ontap
version_added: '2.6'
author: NetApp Ansible Team (@carchi8py) <[email protected]>

description:
    - Creating / deleting and modifying the LIF.

options:
  state:
    description:
    - Whether the specified interface should exist or not.
    choices: ['present', 'absent']
    default: present

  interface_name:
    description:
    - Specifies the logical interface (LIF) name.
    required: true

  home_node:
    description:
    - Specifies the LIF's home node.
    - By default, the first node from the cluster is considered as home node

  home_port:
    description:
    - Specifies the LIF's home port.
    - Required when C(state=present)

  role:
    description:
    - Specifies the role of the LIF.
    - When setting role as "intercluster", setting protocol is not supported.
    - Required when C(state=present).

  address:
    description:
    - Specifies the LIF's IP address.
    - Required when C(state=present)

  netmask:
    description:
    - Specifies the LIF's netmask.
    - Required when C(state=present).

  vserver:
    description:
    - The name of the vserver to use.
    required: true

  firewall_policy:
    description:
    - Specifies the firewall policy for the LIF.

  failover_policy:
    choices: ['disabled', 'system-defined', 'local-only', 'sfo-partner-only', 'broadcast-domain-wide']
    description:
    - Specifies the failover policy for the LIF.

  subnet_name:
    description:
    - Subnet where the interface address is allocated from.
      If the option is not used, the IP address will need to be provided by
      the administrator during configuration.
    version_added: '2.8'

  admin_status:
    choices: ['up', 'down']
    description:
    - Specifies the administrative status of the LIF.

  is_auto_revert:
    description:
       If true, data LIF will revert to its home node under certain circumstances such as startup, and load balancing
       migration capability is disabled automatically
    type: bool

  force_subnet_association:
    description:
       Set this to true to acquire the address from the named subnet and assign the subnet to the LIF.
    type: bool
    version_added: '2.9'

  protocols:
    description:
    - Specifies the list of data protocols configured on the LIF. By default, the values in this element are nfs, cifs and fcache.
    - Other supported protocols are iscsi and fcp. A LIF can be configured to not support any data protocols by specifying 'none'.
    - Protocol values of none, iscsi, fc-nvme or fcp can't be combined with any other data protocol(s).
    - address, netmask and firewall_policy parameters are not supported for 'fc-nvme' option.

  dns_domain_name:
    description:
    - Specifies the unique, fully qualified domain name of the DNS zone of this LIF.
    type: str
    version_added: '2.9'

  listen_for_dns_query:
    description:
    - If True, this IP address will listen for DNS queries for the dnszone specified.
    type: bool
    version_added: '2.9'

  is_dns_update_enabled:
    description:
    - Specifies if DNS update is enabled for this LIF. Dynamic updates will be sent for this LIF if updates are enabled at Vserver level.
    type: bool
    version_added: '2.9'

s�
    - name: Create interface
      na_ontap_interface:
        state: present
        interface_name: data2
        home_port: e0d
        home_node: laurentn-vsim1
        role: data
        protocols: nfs
        admin_status: up
        failover_policy: local-only
        firewall_policy: mgmt
        is_auto_revert: true
        address: 10.10.10.10
        netmask: 255.255.255.0
        force_subnet_association: false
        dns_domain_name: test.com
        listen_for_dns_query: true
        is_dns_update_enabled: true
        vserver: svm1
        hostname: "{{ netapp_hostname }}"
        username: "{{ netapp_username }}"
        password: "{{ netapp_password }}"

    - name: Delete interface
      na_ontap_interface:
        state: absent
        interface_name: data2
        vserver: svm1
        hostname: "{{ netapp_hostname }}"
        username: "{{ netapp_username }}"
        password: "{{ netapp_password }}"

s

N(t
AnsibleModule(tNetAppModule(t	to_nativetNetAppOntapInterfacecB`sweZdZd�Zd�Zed��Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�ZRS(s$ object to describe  interface info c*C`sytj�|_|jjtdtdtdddgdd�dtdtdd	�d
tdtdd	dd�dtdtdd	�dtdtdd	�d
tdtdd	�dtdtdd	�dtdtdd	�dtdtdd	dd�dtdtdd	ddddddddg�dtdtdddg�dtdtdd	�dtdtdddd�dtdtdd�dtdtdddd�d tdtdd	�d!tdtdd�d"tdtdd���td#|jd$dd
gddggd%t�|_	t
�|_|jj|j	j
�|_ttkr]|j	jd&d'�ntjd(|j	�|_dS()Ntstatetrequiredtchoicestpresenttabsenttdefaulttinterface_namettypetstrt	home_nodet	home_porttroletaddresstnetmasktvservertfirewall_policytfailover_policytdisabledssystem-defineds
local-onlyssfo-partner-onlysbroadcast-domain-widetadmin_statustuptdowntsubnet_nametis_auto_reverttboolt	protocolstlisttforce_subnet_associationtdns_domain_nametlisten_for_dns_querytis_dns_update_enabledt
argument_spectmutually_exclusivetsupports_check_modetmsgs(the python NetApp-Lib module is requiredtmodule(tnetapp_utilstna_ontap_host_argument_specR*tupdatetdicttFalsetTruetNoneRR.R	t	na_helpertset_parameterstparamst
parameterstHAS_NETAPP_LIBt	fail_jsontsetup_na_ontap_zapitserver(tself((sU/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_interface.pyt__init__�sD		
cC`s9tjjd�}tjjd�}|jd|jd�|jd|jd�tjjd�}|j|�|j|�|jj|t�}d"}|j
d�r5t|jd��dkr5|j
d	�j
d�}i|jdd6|d
d6|dd
6|dd6|dj
dd�d6|ddkr:tntd6}|j
d�rd|d|d<n|j
d�r�|d|d<n|j
d�r�|d|d<n|j
d�dkr�|d|d<n
d"|d<|j
d�r|jjt|d�|d<n|j
d �r5|jjt|d �|d!<q5n|S(#s�
        Return details about the interface
        :param:
            name : Name of the name of the interface

        :return: Details about the interface. None if not found.
        :rtype: dict
        snet-interface-get-itersnet-interface-infosinterface-nameRRtquerysnum-recordsisattributes-listsadministrative-statusRs	home-portRs	home-nodeRsfailover-policyt_t-Rsis-auto-revertttrueR"RRsfirewall-policyRsdns-domain-nametnoneR'slisten-for-dns-queryR(sis-dns-update-enabledR)N(R/tzapit	NaElementt
add_new_childR9tadd_child_elemR=tinvoke_successfullyR4R5tget_child_by_nametinttget_child_contenttreplaceR3R6tget_value_for_bool(R>tinterface_infotinterface_attributesR@tresulttreturn_value((sU/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_interface.pyt
get_interface�sD	

	 
 #cC`s�|jd�dk	r&|d|d<n|jd�dk	rL|d|d<n|jd�dk	rr|d|d<n|jd�dk	r�|d|d<n|jd�dk	r�|d|d<n|jd	�dk	r�|d	|d
<n|jd�dk	r|dtkrdnd
|d<n|jd�dk	rB|d|d<n|jd�dk	rt|drgdnd
|d<n|jd�dk	r�|d|d<n|jd�dk	r�t|d�|d<n|jd�dk	r�t|d�|d<ndS(s% set attributes for create or modify Rs	home-portR!ssubnet-nameRRRsfailover-policyRsfirewall-policyR"RCtfalsesis-auto-revertRsadministrative-statusR&sforce-subnet-associationR'sdns-domain-nameR(slisten-for-dns-queryR)sis-dns-update-enabledN(tgetR5R4R(toptionsR9((sU/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_interface.pytset_optionss0#cC`s|jjd�d
k	rtjjd�}x�|jjd�D]�}|j�dkrd|krq|jd�nd|kr�|jd�nd|kr�|jd�ntdddg�}|j	t|jj
���s|jjd	d
dj
|��qn|jd|�q=W|Sd
S(s set protocols for create R$sdata-protocolssfc-nvmetfcpRRRRR-sbError: Following parameters for creating interface are not supported for data-protocol fc-nvme: %ss, s
data-protocolN(sfc-nvmeRX(R9RUR5R/RERFtlowertremovetsett
isdisjointtkeysR.R;tjoinRG(R>t
required_keystdata_protocols_objtprotocoltnot_required_params((sU/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_interface.pytset_protocol_option0s"cC`s�tjjd�}iiid6d6}|j|�y|jj|dt�}WnOtjjk
r�}|jj	dd|j
dt|�fdtj
��nX|jd	�r�t|jd	��d
kr�|jd�}|jd�jd�Sd
S(s+ get the first node name from this cluster scluster-node-get-iterscluster-node-infoR@tenable_tunnelingR-s(Error fetching node for interface %s: %sRt	exceptionsnum-recordsisattributes-lists	node-nameN(R/RERFttranslate_structR=RIR4t
NaApiErrorR.R;R9R
t	tracebackt
format_excRJRKRLR5(R>tget_nodet
attributesRQtexc((sU/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_interface.pytget_home_node_for_clusterDs
*cC`s�|jjd�d
krC|j�}|d
k	rC||jd<qCn|jt|jj���r�|jjd�d
kr�|jjdddj	|��n|jddkr�|jjd�d
k	r�|jjdd	�nd
S(s�
            Validate if required parameters for create are present.
            Parameter requirement might vary based on given data-protocol.
            :return: None
        RR!R-sIError: Missing one or more required parameters for creating interface: %ss, RtinterclusterR$sTError: Protocol cannot be specified for intercluster role,failed to create interfaceN(
R9RUR5RmtissubsetR[R]R.R;R^(R>R]tnode((sU/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_interface.pytvalidate_create_parametersXs7+cC`sctddg�}d}|jjd�dkrM|jd�|jd�n|j|�}|j|�i|jdd6|jdd6|jjd�d	6|jd
d
6}tj||j�t	j
jjd|�}|dk	r�|j
|�ny|jj|dt�WnOt	j
jk
r^}|jjd
d|jdt|�fdtj��nXdS(s" calling zapi to create interface RRR!RRRsinterface-nameRs	home-nodeRsnet-interface-createRdR-sError Creating interface %s: %sReN(R[R5R9RUtaddRcRqRRWR/RERFtcreate_node_with_childrenRHR=RIR4RgR.R;R
RhRi(R>R_R`RVtinterface_createRl((sU/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_interface.pytcreate_interfaceks(

cC`s�|dkr0d|jd<|jidd6�ntjjjdi|jdd6|jdd6�}y|jj|dt�WnOtjj	k
r�}|j
jd	d
|jdt|�fdt
j��nXdS(
s" calling zapi to delete interface RR Rsnet-interface-deleteRsinterface-nameRRdR-sError deleting interface %s: %sReN(R9tmodify_interfaceR/RERFRsR=RIR4RgR.R;R
RhRi(R>tcurrent_statustinterface_deleteRl((sU/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_interface.pytdelete_interface�s
)cC`s�i|jdd6|jdd6}tj||�tjjjd|�}y|jj|dt	�WnOtjj
k
r�}|jjdd|jdt
|�fdtj��nXd	S(
s'
        Modify the interface.
        Rsinterface-nameRsnet-interface-modifyRdR-s Error modifying interface %s: %sReN(R9RRWR/RERFRsR=RIR4RgR.R;R
RhRi(R>tmodifyRVtinterface_modifyterr((sU/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_interface.pyRv�scC`sAtj|j�}tjd|jd|�}tjd|�dS(NR.Rtna_ontap_interface(R/tget_cserverR=R<R.t
ems_log_event(R>tresultstcserver((sU/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_interface.pytautosupport_log�s	cC`s�|j�|j�}|jj||j�}|jj||j�}|jjr�|jjraq�|dkrz|j	�q�|dkr�|j
|d�q�|r�|j|�q�n|jjd|jj�dS(s  calling all interface features tcreatetdeleteRtchangedN(
R�RSR6t
get_cd_actionR9tget_modified_attributesR�R.t
check_modeRuRyRvt	exit_json(R>tcurrentt	cd_actionRz((sU/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_interface.pytapply�s

(t__name__t
__module__t__doc__R?RStstaticmethodRWRcRmRqRuRyRvR�R�(((sU/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_interface.pyR�s	-	/							cC`st�}|j�dS(N(RR�(t	interface((sU/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_interface.pytmain�s	t__main__(R�t
__future__RRRRt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNRhtansible.module_utils.basicRt"ansible.module_utils.netapp_moduleR	tansible.module_utils._textR
tansible.module_utils.netapptmodule_utilstnetappR/thas_netapp_libR:tobjectRR�R�(((sU/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/na_ontap_interface.pyt<module>s(

v#�	

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