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

�
�Udac@s�idd6dgd6dd6ZdZdZdZd	d
lZd	dlmZmZmZd	dlm	Z	m
Z
d	d
lmZd�Z
d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zedkr�e�nd
S(s1.1tmetadata_versiontpreviewtstatustnetworktsupported_bysl
---

module: nxos_ntp_auth
extends_documentation_fragment: nxos
version_added: "2.2"
short_description: Manages NTP authentication.
description:
    - Manages NTP authentication.
author:
    - Jason Edelman (@jedelman8)
notes:
    - Tested against NXOSv 7.3.(0)D1(1) on VIRL
    - If C(state=absent), the module will remove the given key configuration if it exists.
    - If C(state=absent) and C(authentication=on), authentication will be turned off.
options:
    key_id:
        description:
            - Authentication key identifier (numeric).
    md5string:
        description:
            - MD5 String.
    auth_type:
        description:
            - Whether the given md5string is in cleartext or
              has been encrypted. If in cleartext, the device
              will encrypt it before storing it.
        default: text
        choices: ['text', 'encrypt']
    trusted_key:
        description:
            - Whether the given key is required to be supplied by a time source
              for the device to synchronize to the time source.
        choices: [ 'false', 'true' ]
        default: 'false'
    authentication:
        description:
            - Turns NTP authentication on or off.
        choices: ['on', 'off']
    state:
        description:
            - Manage the state of the resource.
        default: present
        choices: ['present','absent']
ss
# Basic NTP authentication configuration
- nxos_ntp_auth:
    key_id: 32
    md5string: hello
    auth_type: text
s�
commands:
    description: command sent to the device
    returned: always
    type: list
    sample: ["ntp authentication-key 32 md5 helloWorld 0", "ntp trusted-key 32"]
i����N(t
get_configtload_configtrun_commands(tnxos_argument_spect
check_args(t
AnsibleModulecCsGd|kr#i|d6dd6}ni|d6dd6}t||g�S(Nsshow runtcommandtjsontoutputttext(R(Rtmodule((sN/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_ntp_auth.pytexecute_show_command^s

cCsGg}x:|D]2}t|t�r2|j|�q
|j|�q
W|S(N(t
isinstancetlisttextendtappend(t
command_liststflat_command_listR((sN/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_ntp_auth.pytflatten_listms
cCsBd}t||�d}|d}d|kr8t}nt}|S(Nsshow ntp authentication-statusitauthenticationtenabled(RtTruetFalse(RRtbodytntp_auth_strtntp_auth((sN/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_ntp_auth.pytget_ntp_authws
	cCsug}d}t||�d}|r4|j�}ng}x4|D],}|rA|jt|j�d��qAqAW|S(Nsshow run | inc ntp.trusted-keyii(Rt
splitlinesRtstrtsplit(Rttrusted_key_listRttrusted_key_strttrusted_keystline((sN/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_ntp_auth.pytget_ntp_trusted_key�s
$cCs�i}dj|�}d}t||�d}yktj||tj�}|j�}|d|d<|d|d<|ddkr�d|d	<n
d
|d	<Wnttfk
r�i}nX|S(Ns)show run | inc ntp.authentication-key.{0}sU.*ntp\sauthentication-key\s(?P<key_id>\d+)\smd5\s(?P<md5string>\S+)\s(?P<atype>\S+).*itkey_idt	md5stringtatypet7tencryptt	auth_typeR(tformatRtretmatchtDOTALLt	groupdicttAttributeErrort	TypeError(R(Rtauthentication_keyRt
auth_regexRtmatch_authenticationtgroup_authentication((sN/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_ntp_auth.pytget_ntp_auth_key�s

cCskt||�}t|�}t|�}||kr@d|d<n
d|d<|r]d|d<n
d|d<|S(Nttruettrusted_keytfalsetonRtoff(R9R'R(R(Rt	auth_infoR#t
auth_power((sN/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_ntp_auth.pytget_ntp_auth_info�s



cCs|dkrdSdSdS(NR,R+t0((R-((sN/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_ntp_auth.pytauth_type_to_num�scCs�g}|r=|r=t|�}|jdj|||��n|dkrb|jdj|��n%|dkr�|jdj|��n|dkr�|jd�n|dkr�|jd	�n|S(
Ns&ntp authentication-key {0} md5 {1} {2}R:sntp trusted-key {0}R<sno ntp trusted-key {0}R=sntp authenticateR>sno ntp authenticate(RCRR.(R(R)R-R;Rt
ntp_auth_cmdst
auth_type_num((sN/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_ntp_auth.pytset_ntp_auth_key�s&

cCsQg}|r7t|�}|jdj|||��n|rM|jd�n|S(Ns)no ntp authentication-key {0} md5 {1} {2}sno ntp authenticate(RCRR.(R(R)R-R;Rtauth_remove_cmdsRE((sN/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_ntp_auth.pytremove_ntp_auth_key�s
cCs�tdtdd�dtdd�dtdddgd	d�d
tdddgd	d�d
tdddg�dtdddgd	d��}|jt�td|dt�}t�}t||�|jd}|jd}|jd}|jd
}|jd
}|jd}|r=|r=|r=|jdd�q=ntd|d|d|d
|d
|�}	t	}
td�|	j
�D��}t||�}|}
tt|j
��j
|j
���}g}|dkr)|r�t|||jd�|jd
�|jd
��}|r&|j|�q&q�ny|dkr�d}|jd
�dkrYt}n|jd�sqd}nt|||||�}|r�|j|�q�nt|�}|r_|jr�|jdtd|�q_t||�t||�}
tt|
j
��j
|j
���}|s7t|�t|
�kr@t}
nd|kr_|jd�q_ni}||d<||d<||d<|
|d<||d<|
|d <|j|�dS(!NR(ttypeR!R)R-tchoicesRR,tdefaultR;R:R<RR=R>tstatetabsenttpresentt
argument_spectsupports_check_modetmsgs*trusted_key or md5string MUST be specifiedcss-|]#\}}|dk	r||fVqdS(N(tNone(t.0tktv((sN/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_ntp_auth.pys	<genexpr>stchangedtcommandst	configureitproposedtexistingtupdatestwarningst	end_state(tdicttupdateRR
RRR	tparamst	fail_jsonRtitemsRAtsett
differenceRFtgetRRRRHRt
check_modet	exit_jsonRtlentpop(RORR\R(R)R-R;RRLtargsRVRYRZR]tdeltaRWRtauth_toggletcmdstresults((sN/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_ntp_auth.pytmain�s�
		






	'			
'	





t__main__(tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR/t&ansible.module_utils.network.nxos.nxosRRRRR	tansible.module_utils.basicR
RRRR'R9RARCRFRHRot__name__(((sN/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_ntp_auth.pyt<module>s*


/		
								T

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