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

�
�Udac@s�idd6dgd6dd6ZdZdZdZd	d
lZd	dlmZmZd	dlmZm	Z	d	d
l
mZed�Z
d�Zd�Zd�Zd�Zd
d�Zd�Zd�Zedkr�e�nd
S(s1.1tmetadata_versiontpreviewtstatustnetworktsupported_bys�
---
module: nxos_snmp_user
extends_documentation_fragment: nxos
version_added: "2.2"
short_description: Manages SNMP users for monitoring.
description:
    - Manages SNMP user configuration.
author:
    - Jason Edelman (@jedelman8)
notes:
    - Tested against NXOSv 7.3.(0)D1(1) on VIRL
    - Authentication parameters not idempotent.
options:
    user:
        description:
            - Name of the user.
        required: true
    group:
        description:
            - Group to which the user will belong to.
              If state = present, and the user is existing,
              the group is added to the user. If the user
              is not existing, user entry is created with this
              group argument.
              If state = absent, only the group is removed from the
              user entry. However, to maintain backward compatibility,
              if the existing user belongs to only one group, and if
              group argument is same as the existing user's group,
              then the user entry also is deleted.
    authentication:
        description:
            - Authentication parameters for the user.
        choices: ['md5', 'sha']
    pwd:
        description:
            - Authentication password when using md5 or sha.
              This is not idempotent
    privacy:
        description:
            - Privacy password for the user.
              This is not idempotent
    encrypt:
        description:
            - Enables AES-128 bit encryption when using privacy password.
        type: bool
    state:
        description:
            - Manage the state of the resource.
        default: present
        choices: ['present','absent']
sl
- nxos_snmp_user:
    user: ntc
    group: network-operator
    authentication: md5
    pwd: test_password
s�
commands:
    description: commands sent to the device
    returned: always
    type: list
    sample: ["snmp-server user ntc network-operator auth md5 test_password"]
i����N(tload_configtrun_commands(tnxos_argument_spect
check_args(t
AnsibleModulecCs4i|d6dd6}|r'd|d<nt||�S(Ntcommandtjsontoutputttext(R(R
tmoduleR
((sO/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_user.pytexecute_show_commandds

cCsGg}x:|D]2}t|t�r2|j|�q
|j|�q
W|S(N(t
isinstancetlisttextendtappend(t
command_liststflat_command_listR
((sO/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_user.pytflatten_listos
cCsltd|�d}g}y4|dd}x|D]}|j|d�q1WWnttfk
rg|SX|S(Nsshow snmp groupit
TABLE_roletROW_rolet	role_name(RRtKeyErrortAttributeError(Rtdatat
group_listtgroup_tabletgroup((sO/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_user.pytget_snmp_groupsys
cCs�dj|�}t||dt�}|d}d|dkrPt||�}ni}y#|djd�r�d}d}d}d}	d	}
d
}d}n@|djd�r�d}d
}d}d}	d}
d}d}n|d||}
t|
t�r|
d}n|
}||d<t||
�j�|d<t||�j�}|jd�rcd|d<n
d|d<g}||kr:|||	}y2x+|D]#}|j	t||�j��q�WWn.t
k
r�|j	t||�j��nXt|
t�rn|
jd�x(|
D]}|j	|dj��qWqnn4d|krn|d}t|t�rn|g}qnn||d<WnEtt
tt
fk
r�|r�|r�d|kr�t|�}q�nX|S(Nsshow snmp user {0}R
is
No such entrytTABLE_snmp_usert
ROW_snmp_usertTABLE_snmp_group_namestROW_snmp_group_namest
auth_protocolt
priv_protocoltgroup_namestTABLE_snmp_userstROW_snmp_userstTABLE_groupst
ROW_groupstauthtprivRtusertauthenticationtaessaes-128tencrypttnone(tformatRtTruetgetRRtstrtstript
startswithRt	TypeErrortpopRRt
IndexErrortget_non_structured_snmp_user(R.RR
tbodyt	body_texttresourcettablekeytrowkeyttablegrpkeyt	rowgrpkeytauthkeytprivkeytgrpkeytrttresource_tableR1tgroupsRRteach((sO/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_user.pyt
get_snmp_user�sl
		




%
!

!
cCs�i}|jd�d}tjdtj�}tj||�}|sJ|S|jd�|d<|jd�|d<dt|jd��kr�dnd	|d
<|jd�g|d<tjd|tj�}|r�|dc|7<n|S(
Nt
__________i����s^^(?P<user>\S+)\s+(?P<auth>\S+)\s+(?P<priv>[\w\d-]+)(?P<enforce>\([\w\d-]+\))*\s+(?P<group>\S+)R.R,R0R-saes-128R2R1Rs^\s+([\w\d-]+)\s*$(trsplittretcompiletMtsearchRR6tfindall(R>R?Rtpattmtmore_groups((sO/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_user.pyR<�s	+cCs-|rdj||�gSdj|�gSdS(Nsno snmp-server user {0} {1}sno snmp-server user {0}(R3(R.R((sO/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_user.pytremove_snmp_user�sc	Cs|rt|�}ng}|jd�r?dj||�}ndj|�}|jdd�}|jdd�}|r�|r�|dj|�7}n|jdd�}|jdd�}|r�|r�|d	j|�7}n|r�|d
j|�7}n|r|j|�n|S(NRssnmp-server user {0} {group}ssnmp-server user {0}R/tpwds auth {authentication} {pwd}R1tprivacys priv {encrypt} {privacy}s priv {privacy}(RVR5R3tNoneR(	tproposedR.tresettcommandstcmdR,RWR1RX((sO/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_user.pytconfig_snmp_users&cCsVtdtdtdd�dtdd�dtdddt�dtdd�d	td
ddg�d
tdd�dtd
ddgdd��}|jt�td|dd	dgd
dggdt�}t�}t||�itd6gd6|d6}|jd}|jd}|jd}|jd}|jd
}|jd	}	|jd}
|r�|r�|r�|	r�|j	dd�q�n|r�|t
|�kr�|j	dd�nt||�}|
dkr|r|r||dkr�d|d<q||d<qd|d<ng}|
dkr�|r�|r�||dkr�t
|d�dkrh|jt|��q�|jt||��q�q�|jt|��nM|
dkr�t}
td|d|d|d|d
|d	|	�}td�|j�D��}|s*|rd|d
<n|jt|||
��q�|r�|r]|d
jd�r]t}
d|d
<ntt|j��j|j���}|jd�r�|	|d	<n|r�|r�d|d
<n|r�t|||
�}|j|�q�q�nt|�}|rEt|d<|jst||�nd |kr8|jd!�n||d<n|j|�dS("NR.trequiredttypeR6RRWtno_logRXR/tchoicestmd5tshaR1tbooltstatetabsenttpresenttdefaultt
argument_spectrequired_togethertsupports_check_modetchangedR\twarningstmsgsFpwd and authentication must be provided when using privacy and encrypts#group not configured yet on switch.icss-|]#\}}|dk	r||fVqdS(N(RY(t.0tktv((sO/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_user.pys	<genexpr>fssaes-128R0t	configurei(tdictR4tupdateRR	RRtFalsetparamst	fail_jsonR RKRYtlenRRVtitemsR^R8tsett
differenceR5Rt
check_modeRR:t	exit_json(RjRRntresultsR.RRWRXR1R/RftexistingR\R[targsRZtdeltaR
tcmds((sO/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_user.pytmain$s�
			













'


	
t__main__(tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNRNt&ansible.module_utils.network.nxos.nxosRRRRtansible.module_utils.basicR	RvRRR RKR<RYRVR^R�t__name__(((sO/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_user.pyt<module>s&


6	
		S	$		g

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