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_mgmt_interface.pyc

�
�Udac@`sNddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlZddlm
Z
mZddlZddlZyddlZWn ek
r�ddljZnXdd
lmZddlmZmZddlmZidd6dd6Zdefd��YZd�ZedkrJe�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys�
---
module: netapp_e_mgmt_interface
short_description: NetApp E-Series management interface configuration
description:
    - Configure the E-Series management interfaces
version_added: '2.7'
author:
    - Michael Price (@lmprice)
    - Nathan Swartz (@ndswartz)
extends_documentation_fragment:
    - netapp.eseries
options:
    state:
        description:
            - Enable or disable IPv4 network interface configuration.
            - Either IPv4 or IPv6 must be enabled otherwise error will occur.
            - Only required when enabling or disabling IPv4 network interface
        choices:
            - enable
            - disable
        required: no
        aliases:
            - enable_interface
    controller:
        description:
            - The controller that owns the port you want to configure.
            - Controller names are represented alphabetically, with the first controller as A,
             the second as B, and so on.
            - Current hardware models have either 1 or 2 available controllers, but that is not a guaranteed hard
             limitation and could change in the future.
        required: yes
        choices:
            - A
            - B
    name:
        description:
            - The port to modify the configuration for.
            - The list of choices is not necessarily comprehensive. It depends on the number of ports
              that are present in the system.
            - The name represents the port number (typically from left to right on the controller),
              beginning with a value of 1.
            - Mutually exclusive with I(channel).
        aliases:
            - port
            - iface
    channel:
        description:
            - The port to modify the configuration for.
            - The channel represents the port number (typically from left to right on the controller),
              beginning with a value of 1.
            - Mutually exclusive with I(name).
    address:
        description:
            - The IPv4 address to assign to the interface.
            - Should be specified in xx.xx.xx.xx form.
            - Mutually exclusive with I(config_method=dhcp)
        required: no
    subnet_mask:
        description:
            - The subnet mask to utilize for the interface.
            - Should be specified in xx.xx.xx.xx form.
            - Mutually exclusive with I(config_method=dhcp)
        required: no
    gateway:
        description:
            - The IPv4 gateway address to utilize for the interface.
            - Should be specified in xx.xx.xx.xx form.
            - Mutually exclusive with I(config_method=dhcp)
        required: no
    config_method:
        description:
            - The configuration method type to use for network interface ports.
            - dhcp is mutually exclusive with I(address), I(subnet_mask), and I(gateway).
        choices:
            - dhcp
            - static
        required: no
    dns_config_method:
        description:
            - The configuration method type to use for DNS services.
            - dhcp is mutually exclusive with I(dns_address), and I(dns_address_backup).
        choices:
            - dhcp
            - static
        required: no
    dns_address:
        description:
            - Primary IPv4 DNS server address
        required: no
    dns_address_backup:
        description:
            - Backup IPv4 DNS server address
            - Queried when primary DNS server fails
        required: no
    ntp_config_method:
        description:
            - The configuration method type to use for NTP services.
            - disable is mutually exclusive with I(ntp_address) and I(ntp_address_backup).
            - dhcp is mutually exclusive with I(ntp_address) and I(ntp_address_backup).
        choices:
            - disable
            - dhcp
            - static
        required: no
    ntp_address:
        description:
            - Primary IPv4 NTP server address
        required: no
    ntp_address_backup:
        description:
            - Backup IPv4 NTP server address
            - Queried when primary NTP server fails
        required: no
    ssh:
        type: bool
        description:
            - Enable ssh access to the controller for debug purposes.
            - This is a controller-level setting.
            - rlogin/telnet will be enabled for ancient equipment where ssh is not available.
        required: no
    log_path:
        description:
            - A local path to a file to be used for debug logging
        required: no
notes:
    - Check mode is supported.
    - The interface settings are applied synchronously, but changes to the interface itself (receiving a new IP address
      via dhcp, etc), can take seconds or minutes longer to take effect.
    - "Known issue: Changes specifically to down ports will result in a failure. However, this may not be the case in up
      coming NetApp E-Series firmware releases (released after firmware version 11.40.2)."
s�
    - name: Configure the first port on the A controller with a static IPv4 address
      netapp_e_mgmt_interface:
        name: "1"
        controller: "A"
        config_method: static
        address: "192.168.1.100"
        subnet_mask: "255.255.255.0"
        gateway: "192.168.1.1"
        ssid: "1"
        api_url: "10.1.1.1:8443"
        api_username: "admin"
        api_password: "myPass"

    - name: Disable ipv4 connectivity for the second port on the B controller
      netapp_e_mgmt_interface:
        name: "2"
        controller: "B"
        enable_interface: no
        ssid: "{{ ssid }}"
        api_url: "{{ netapp_api_url }}"
        api_username: "{{ netapp_api_username }}"
        api_password: "{{ netapp_api_password }}"

    - name: Enable ssh access for ports one and two on controller A
      netapp_e_mgmt_interface:
        name: "{{ item }}"
        controller: "A"
        ssh: yes
        ssid: "{{ ssid }}"
        api_url: "{{ netapp_api_url }}"
        api_username: "{{ netapp_api_username }}"
        api_password: "{{ netapp_api_password }}"
      loop:
        - 1
        - 2

    - name: Configure static DNS settings for the first port on controller A
      netapp_e_mgmt_interface:
        name: "1"
        controller: "A"
        dns_config_method: static
        dns_address: "192.168.1.100"
        dns_address_backup: "192.168.1.1"
        ssid: "{{ ssid }}"
        api_url: "{{ netapp_api_url }}"
        api_username: "{{ netapp_api_username }}"
        api_password: "{{ netapp_api_password }}"

    - name: Configure static NTP settings for ports one and two on controller B
      netapp_e_mgmt_interface:
        name: "{{ item }}"
        controller: "B"
        ntp_config_method: static
        ntp_address: "129.100.1.100"
        ntp_address_backup: "127.100.1.1"
        ssid: "{{ ssid }}"
        api_url: "{{ netapp_api_url }}"
        api_username: "{{ netapp_api_username }}"
        api_password: "{{ netapp_api_password }}"
      loop:
        - 1
        - 2
s�
msg:
    description: Success message
    returned: on success
    type: str
    sample: The interface settings have been updated.
enabled:
    description:
        - Indicates whether IPv4 connectivity has been enabled or disabled.
        - This does not necessarily indicate connectivity. If dhcp was enabled absent a dhcp server, for instance,
          it is unlikely that the configuration will actually be valid.
    returned: on success
    sample: True
    type: bool
N(tpformattpprint(t
AnsibleModule(trequestteseries_host_argument_spec(t	to_nativesapplication/jsonsContent-TypetAcceptt
MgmtInterfacecB`s�eZdZd�Zed��Zed��Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
dd�Zd
�Zd�Zd�ZRS(ic&C`s�t�}|jtdtdddddgddgd	t�d
tddd	tdddg�d
tdddddg�dtdd�dtddd	t�dtddd	t�dtddd	t�dtddd	tdddg�dtddd	tdddg�dtddd	t�dtddd	t�dtddd	tddddg�dtddd	t�dtddd	t�dtddd	t�d tddd	t���dddggddddggdddggdddggg}d
dgg}td!|d"td#|d$|�|_|jj}|d
|_|d
|_	|d|_
|d|_|d|_|d|_
|d|_|ddkr�dn
|ddk|_|d|_|d|_|d|_|d|_|d|_|d|_|d|_|d%|_|d&|_td'|d(d)|d)d*|d+�|_d,|_|jj|_t�|_|d }tj|j j!�|_"|r�tj#d-tj$d.|d/d0d1d2�n|jj%d3�s�|jd37_ndS(4Ntstatettypetstrtchoicestenabletdisabletaliasestenable_interfacetrequiredt
controllertAtBtnametporttifacetchanneltinttaddresstsubnet_masktgatewayt
config_methodtdhcptstatictdns_config_methodtdns_addresstdns_address_backuptntp_config_methodtntp_addresstntp_address_backuptsshtbooltlog_patht
argument_spectsupports_check_modetrequired_iftmutually_exclusivetssidtapi_urlturl_passwordtapi_passwordtvalidate_certsturl_usernametapi_usernameitleveltfilenametfilemodetwtformatsS%(relativeCreated)dms %(levelname)s %(module)s.%(funcName)s:%(lineno)d
 %(message)st/(&RtupdatetdicttFalsetTrueR
tmoduletparamsRRRR$R!R"R#tNoneRR'R(R)R*R+R,R-R4turltcredstretriest
check_modet	post_bodytloggingt	getLoggert	__class__t__name__t_loggertbasicConfigtDEBUGtendswith(tselfR0R2R3targsR/((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_mgmt_interface.pyt__init__�sx	!!!$






)









	
	
c		C`sy0t|jd|jdt|j�\}}WnBtk
rt}t�}|jjdd|jt	|�f�nX|j
dd��t�}td�}x]|D]U}t
|�}td|d	d
d|dd|d
d�}|||<|d7}q�W|S(s�Retrieve a mapping of controller labels to their references
        {
            'A': '070000000000000000000001',
            'B': '070000000000000000000002',
        }
        :return: the controllers defined on the system
        sstorage-systems/%s/controllerstheaderstmsgsFFailed to retrieve the controller settings. Array Id [%s]. Error [%s].tkeycS`s|ddS(NtphysicalLocationtslot((tc((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_mgmt_interface.pyt<lambda>`sRtcontrollerSlotR[R\t
controllerRefR-tnetworkSettingstremoteAccessEnabledi(RRHR4tHEADERSRIt	ExceptiontlistREt	fail_jsonR
tsortRBtordtchr(	RUtrctcontrollersterrtcontrollers_dicttiRtlabeltsettings((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_mgmt_interface.pyRkNs&	$		


c	"C`sKt�}y0t|jd|jdt|j�\}}Wn9tk
rt}|jjdd|jt	|�f�nX|j
}||j}g|D] }|d|dkr�|^q�}d}xs|D]k}|j
r|d|j
ks�|d|j
kr0|}Pq0q�|jr�|d|jkr0|}Pq0q�q�W|dkr�|j
dk	rX|j
n|j}|jjdd	||jf�ntd|dd|dd
|dd|d
d|dd|dd|dd|dddd|dddd|dddd|dddd|d d|dd!|d!d"|d"d#|d$�S(%Ns4storage-systems/%s/configuration/ethernet-interfacesRXRYsLFailed to retrieve defined management interfaces. Array Id [%s]. Error [%s].R`taliast
interfaceNameRs;We could not find an interface matching [%s] on Array=[%s].tlink_statust
linkStatustenabledtipv4EnabledR!tipv4AddressR#tipv4GatewayAddressR"tipv4SubnetMaskR't
dnsPropertiestacquisitionPropertiestdnsAcquisitionTypetdns_serverst
dnsServersR*t
ntpPropertiestntpAcquisitionTypetntp_serverst
ntpServersR$tipv4AddressConfigMethodR_tipv6EnabledtidtinterfaceRef(ReRRHR4RcRIRdRERfR
RkRRGRRRB(	RUtnet_interfacesRjRlRkRRtnett
identifier((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_mgmt_interface.pyt	interfacensR	$	
-
	&	!









cC`sa|jr)|dst}nt|d<n|dr<t}nt|d<|d|d<|||fS(s-Enable or disable the IPv4 network interface.RuRv(RRDRC(RURtexpected_ifaceRAtbody((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_mgmt_interface.pytget_enable_interface_settings�s	
	

	
cC`s!|jdkr5|ddkr(t}nd|d<n�|ddkrNt}nd|d<|d|jkrtt}n|j|d<|d|jkr�t}n|j|d	<|jr�|d
|jkr�t}n|j|d<|d|d<|d	|d<|d|d
<|d|d<|||fS(s"Update network interface settings.R%R$t
configDhcpR�tconfigStaticR!RwR"RyR#Rx(R$RDR!R"R#(RURR�RAR�((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_mgmt_interface.pytget_interface_settings�s*	
	
	
	
	
c	C`s�|jdkr>|ddkr(t}ntdd�|d<n-|jdkrktddd|j�g}|jr�|jtddd|j��ntdd	d
|�|d<|dd	ksUt|d�t|�ksUt|d�dkr$|dd
d|jksU|ddd|jksUt|d�dkr^|dd
d|jkr^t}n||d<n|dd|d<|||fS(s/Add DNS server information to the request body.R%R'R|tdnsAcquisitionDescriptorR&taddressTypetipv4RwtstatR~R}iii(R'RDRBR(R)tappendtlen(RURR�RAR�R}((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_mgmt_interface.pytget_dns_server_settings�s(		"	
c
C`s�|jdkr>|ddkr(t}ntdd�|d<n�|jdkr||ddkrft}ntdd�|d<nW|jdkr�tdd	d
tddd
|j��g}|jr�|jtdd	d
tddd
|j���ntddd|�|d<|ddks�t|d�t|�ks�t|d�dkr�|ddd
d
|jks�|ddd
d
|jks�t|d�dkr�|ddd
d
|jkr�t}n||d<n|dd|d<|||fS(s/Add NTP server information to the request body.RR*tdisabledR�tntpAcquisitionDescriptorR%R&taddrTypetipvxtipvxAddressR�R�RwR�R�R�iii(R*RDRBR+R,R�R�(RURR�RAR�R�((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_mgmt_interface.pytget_ntp_server_settings�s2		*		
cC`s3|j|dkrt}n|j|d<||fS(s8Configure network interface ports for remote ssh access.R-tenableRemoteAccess(R-RD(RURpRAR�((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_mgmt_interface.pytget_remote_ssh_settings
s	
c
`s�t}td|dd|d�}|j�}t}|jr�|jr�ttj|j��d}|jd�d}t	j
|d�}	t	j
|dd��t�fd	�|	D��}n|jj
d
|�|jd!k	r|j||||�\}}}n|jd!k	r6|j||||�\}}}n|jd!k	ri|j||||�\}}}n|jd!k	r�|j||||�\}}}n|jd!k	r�|j|||�\}}|j|d<|j|d<n|jj
t|��|jj
t|��|jj
t|��|jr2|S|r�|jr�|s�y
t|jd|jd
ddtj|�dtdddt|j�\}
}|
dkr%|ddks�|ddkrT|dp�|ds�|j j!dd|j|df�q"|j j!dd|j|f�qTn/|
dkrT|j j!dd|j|f�nWq�t"k
r�}|j j!dd|jt#|�f�q�Xq�|j$|�n|r�|dd kr�|j%|�S|S("s�Update controller with new interface, dns service, ntp service and/or remote ssh access information.

        :returns: whether information passed will modify the controller's current state
        :rtype: bool
        R`R�R�it:ii� R!c3`s|]}|�kVqdS(N((t.0tinfo(turl_address_info(sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_mgmt_interface.pys	<genexpr>'ss update_used_matching_address: %sR-s4storage-systems/%s/configuration/ethernet-interfacestmethodtPOSTtdataRXttimeouti,t
ignore_errorsi�tretcodet4tillegalParamRvR�RYs�This storage-system already has IPv6 connectivity disabled. DHCP configuration for IPv4 is required at a minimum. Array Id [%s] Message [%s].terrorMessagesLWe failed to configure the management interface. Array Id [%s] Message [%s].sXConnection failure: we failed to modify the network settings! Array Id [%s]. Error [%s].RstupN(&RCRBtcopyRR$ReturlparseRHtsplittsockettgetaddrinfotanyRQR�RGR�R�R'R�R*R�R-R�RRKRR4tjsontdumpsRcRDRIRERfRdR
t"update_api_address_interface_matchtvalidate_changes(
RURpRRAR�R�tupdate_used_matching_addresstnetlocR!taddress_infoRjR�Rl((R�sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_mgmt_interface.pytupdate_arraysh
$$$$
	& cC`skyy]t|jd|jdtdtdtdddtj|�dtd	d
|j�\}}Wn�t	k
rt
tj|j��}|djd�}|j
|d
<dj|�|d<tj|�}|jjt|��t|d|jdtd	d|j�\}}dSXWnOt	k
rf}|jjt|��|jjdd|jt|�f�nXdS(s>Change network interface address which matches the api_addresss4storage-systems/%s/configuration/ethernet-interfacest	use_proxytforceR�R�R�R�RXR�i
iR�ii,NRYsXConnection failure: we failed to modify the network settings! Array Id [%s]. Error [%s].(RRHR4RCRDR�R�RcRIRdReR�R�R!tjoint
urlunparseRQR�RRRERfR
(RUR�RjR�t	url_partstdomaintexpected_urlRl((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_mgmt_interface.pyR�ds(.

	icC`sP|j|krLtjd�|r6|j||d�S|jjdd�ntS(s[Validate interface changes were applied to the controller interface port. 30 second timeoutiiRYs?Update failure: we failed to verify the necessary state change.(R�ttimetsleepR�RERfRD(RUR�tretry((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_mgmt_interface.pyR�|s
cC`sjy�t|jd|jdtdt|j�\}}|dkr�|j|jkr�|jd7_|jj	d�t
jd�|j�q�|j
jdd	|j|f�n/|d
kr�|j
jdd	|j|f�nWn�tk
re}|j|jkr<|jj	d�|jd7_t
jd�|j�qf|j
jdd|jt|�f�nXd
S(s�It's possible, due to a previous operation, for the API to report a 424 (offline) status for the
         storage-system. Therefore, we run a manual check with retries to attempt to contact the system before we
         continue.
        sstorage-systems/%s/controllersRXR�i�isWe hit a 424, retrying in 5s.iRYsIWe failed to pull storage-system information. Array Id [%s] Message [%s].i,s,We hit a connection failure, retrying in 5s.sXConnection failure: we failed to modify the network settings! Array Id [%s]. Error [%s].N(RRHR4RcRDRIRJtMAX_RETRIESRQR�R�R�tcheck_healthRERfRdR
(RURjR�Rl((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_mgmt_interface.pyR��s4



cC`s~|j�|j|j}|j}|jjt|��|jjt|��|j||�}|jj	ddd|�dS(s-Update storage system with necessary changes.RYs)The interface settings have been updated.tchangedN(
R�RkRR�RQR�RR�REt	exit_json(RURpRRA((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_mgmt_interface.pyRA�s
	cO`s|j�dS(N(RA(RURVtkwargs((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_mgmt_interface.pyt__call__�s(RPt
__module__R�RWtpropertyRkR�R�R�R�R�R�R�R�R�R�RAR�(((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_mgmt_interface.pyR�s	S 2		!		"		O		%	cC`st�}|�dS(N(R(R((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_mgmt_interface.pytmain�s	t__main__( t
__future__RRRRt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR�RMR	RR�R�R�tImportErrorturllib.parsetparsetansible.module_utils.basicR
tansible.module_utils.netappRRtansible.module_utils._textR
RctobjectRR�RP(((sZ/usr/lib/python2.7/site-packages/ansible/modules/storage/netapp/netapp_e_mgmt_interface.pyt<module>s6


�A

��	

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