Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/network/nxos/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_ntp.pyo

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlmZdd
l
mZmZmZmZdd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zedkr�e�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatustnetworktsupported_bysT
---
module: nxos_ntp
extends_documentation_fragment: nxos
version_added: "2.2"
short_description: Manages core NTP configuration.
description:
    - Manages core NTP configuration.
author:
    - Jason Edelman (@jedelman8)
options:
    server:
        description:
            - Network address of NTP server.
    peer:
        description:
            - Network address of NTP peer.
    key_id:
        description:
            - Authentication key identifier to use with
              given NTP server or peer or keyword 'default'.
    prefer:
        description:
            - Makes given NTP server or peer the preferred
              NTP server or peer for the device.
        choices: ['enabled', 'disabled']
    vrf_name:
        description:
            - Makes the device communicate with the given
              NTP server or peer over a specific VRF or
              keyword 'default'.
    source_addr:
        description:
            - Local source address from which NTP messages are sent
              or keyword 'default'
    source_int:
        description:
            - Local source interface from which NTP messages are sent.
              Must be fully qualified interface name or keyword 'default'
    state:
        description:
            - Manage the state of the resource.
        default: present
        choices: ['present','absent']
s�
# Set NTP Server with parameters
- nxos_ntp:
    server: 1.2.3.4
    key_id: 32
    prefer: enabled
    host: "{{ inventory_hostname }}"
    username: "{{ un }}"
    password: "{{ pwd }}"
s�
proposed:
    description: k/v pairs of parameters passed into module
    returned: always
    type: dict
    sample: {"address": "192.0.2.2", "key_id": "48",
            "peer_type": "server", "prefer": "enabled",
            "source": "192.0.2.3", "source_type": "source"}
existing:
    description:
        - k/v pairs of existing ntp server/peer
    returned: always
    type: dict
    sample: {"address": "192.0.2.2", "key_id": "32",
            "peer_type": "server", "prefer": "enabled",
            "source": "ethernet2/1", "source_type": "source-interface"}
end_state:
    description: k/v pairs of ntp info after module execution
    returned: always
    type: dict
    sample: {"address": "192.0.2.2", "key_id": "48",
            "peer_type": "server", "prefer": "enabled",
            "source": "192.0.2.3", "source_type": "source"}
updates:
    description: command sent to the device
    returned: always
    type: list
    sample: ["ntp server 192.0.2.2 prefer key 48",
             "no ntp source-interface ethernet2/1", "ntp source 192.0.2.3"]
changed:
    description: check to see if a change was made on the device
    returned: always
    type: bool
    sample: true
N(t
AnsibleModule(t
check_argstload_configtnxos_argument_spectrun_commandstcli_showcC`s?d|krd}nd}i|d6|d6g}t||�S(Nsshow runtjsonttexttcommandtoutput(R(Rtmoduletcommand_typeRtcommands((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_ntp.pytexecute_show_commandqs	
cC`sGg}x:|D]2}t|t�r2|j|�q
|j|�q
W|S(N(t
isinstancetlisttextendtappend(t
command_liststflat_command_listR((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_ntp.pytflatten_list~s
cC`s�d}d}d}t||dd�}|r�y=d|dkrId}nd}|dj�dj�}Wq�ttfk
r�d}d}q�Xn||fS(	Nsshow run | inc ntp.sourceRtcli_show_asciit	interfaceissource-interfacetsourcei(tNoneRtsplittlowertAttributeErrort
IndexError(Rtsource_typeRRR((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_ntp.pytget_ntp_source�s	
cC`s�d}g}t||dd�}|r�t|t�rC|d}n|}|r�d}|j�}xP|D]E}d|kr�qhni}y
d}	d}
d}d}tj||tj�}
|
j�}|d}|d	}	|d
}|d}
|d}|dk	rd
}nd}|dk	r'd}n|	dk	rBd}|	}nt	d|d|d
|d|
d|�}t	d�|j
�D��}|j|�Wqhtk
r�g}qhXqhWq�n|S(Ns show run | inc ntp.(server|peer)RRis�.*ntp\s(server\s(?P<address>\S+)|peer\s(?P<peer_address>\S+))\s*((?P<prefer>prefer)\s*)?(use-vrf\s(?P<vrf_name>\S+)\s*)?(key\s(?P<key_id>\d+))?.*saccess-grouptdefaulttaddresstpeer_addresstprefertvrf_nametkey_idtenabledtdisabledtservertpeert	peer_typecs`s!|]\}}||fVqdS(N((t.0tktv((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_ntp.pys	<genexpr>�s(
RRRt
splitlinesR tretmatchtDOTALLt	groupdicttdicttitemsRR#(RRt
ntp_peer_listtresponsetntpt	ntp_regext	split_ntpt	peer_linetntp_peerR)R+R*R,t	match_ntpt	group_ntpR(R1targs((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_ntp.pytget_ntp_peer�sT






			
c	C`s�i}g}t|�}x;|D]3}|d|krE|j|�q|j|�qWt|�\}}|dk	r�|dk	r�||d<||d<n||fS(NR(R%R(RFtupdateRR&R (	R(R1Rt	peer_dicttpeer_server_listt	peer_listR0R%R((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_ntp.pytget_ntp_existing�s


cC`s�g}|r|jd�n|r;|jdj|��n|rZ|jdj|��n|jddj||��dj|�}|S(Ns prefers key {0}s use-vrf {0}isntp {0} {1}t(Rtformattinserttjoin(R1R(R*R,R+tcommand_stringsR((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_ntp.pytset_ntp_server_peer�scC`s�|jd�sK|jd�sK|jd�sK|jd�sK|jd�r�|jd|jd��}|jd|jd��}|jd|jd��}|jd|jd��}|jd|jd��}|jd�dkr�d}q�nd}d}|jd�}|jd�}|rP|d	kr8t}qP|d
krPt}qPn|rt|jd|jd��}ng}	|r�|jd�r�|jd�r�|	jdj|jd�|jd���n|	jt|||||��n|r�|jd�}
|jd�}|
r@||
kr@|	jdj|
|��n|dkrw|
r�|r�|	jdj|
|��q�q�|	jdj||��n|	S(
NR(R1R+R,R*R'R%RR-R.sno ntp {0} {1}sntp {0} {1}(tgetR tTruetFalseRRMRQ(tdeltatexistingR(R1R,R*R+R%Rtntp_cmdstexisting_source_typetexisting_source((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_ntp.pyt
config_ntp�sJ-		cC`stdtdd�dtdd�dtdd�dtddddd	g�d
tdd�dtdd�dtdd�d
tdddgdd��}|jt�td|dddgddggdt�}t�}t||�|jdp�d}|jdpd}|jd}|jd}|jd
}|jd}|jd}	|jd
}
|	dk	rx|	j	�}	n|r�d}|}n!|r�d}|}nd}d}d}
d}|r�d}
|}n|	r�d}
|	}n|s�|s�|r|r|r|j
dd�qntd|d|d|d|d
|d|
d|�}td�|j�D��}t|||�\}}|}t
}g}|
dkr=tt|j��j|j���}|jd�r|jd�dkr|jd�s|jd�qn|r.t||�}|r:|j|�q:q.n�|
dkr.|jd�r�|jd�r�dj|d|d�}|r�|j|g�q�n|jd�}|jd�}|jd�}|jd�}|r.||kr+||kr(dj||�}|r%|j|g�q%q(q+q.nt|�}|r�|jrb|jdtd|�q�t}t||�t|||�d}d |kr�|jd�q�ni}||d!<||d"<||d#<||d<||d$<||d%<||d&<|j|�dS('NR/ttypetstrR0R,R*tchoicesR-R.R+tsource_addrt
source_inttstatetabsenttpresentR't
argument_spectmutually_exclusivetsupports_check_modeRssource-interfacetmsgs*Please supply the server or peer parameterR1R(R%cs`s-|]#\}}|dk	r||fVqdS(N(R (R2R3R4((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_ntp.pys	<genexpr>jssno ntp {0} {1}tchangedRit	configuretproposedRVtupdatestwarningst	end_stateRI(R:RGRRRSRR	tparamsR R"t	fail_jsonR;RKRTtsett
differenceRRtpopRZRRMRt
check_modet	exit_jsonR
(RcRRkR/R0R,R*R+R^R_R`R1R(R%RRERiRVRIRlRgRRURRXRYtproposed_source_typetproposed_sourcetcmdstresults((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_ntp.pytmain+s�
			






					
	'$	







t__main__(t
__future__RRRR[t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR6tansible.module_utils.basicRt&ansible.module_utils.network.nxos.nxosR	R
RRRRR&RFRKRQRZRxt__name__(((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_ntp.pyt<module>s(


/$"
	
		;			/	|

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