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_community.pyo

�
�Udac@s�idd6dgd6dd6ZdZdZdZd	d
lZd	dlmZmZd	dlmZm	Z	d	d
l
mZd�Zd�Z
d�Zd�Zd�Zd�Zedkr�e�nd
S(s1.1tmetadata_versiontpreviewtstatustnetworktsupported_bysk
---
module: nxos_snmp_community
extends_documentation_fragment: nxos
version_added: "2.2"
short_description: Manages SNMP community configs.
description:
    - Manages SNMP community configuration.
author:
    - Jason Edelman (@jedelman8)
    - Gabriele Gerbino (@GGabriele)
notes:
    - Tested against NXOSv 7.3.(0)D1(1) on VIRL
options:
    community:
        description:
            - Case-sensitive community string.
        required: true
    access:
        description:
            - Access type for community.
        choices: ['ro','rw']
    group:
        description:
            - Group to which the community belongs.
    acl:
        description:
            - ACL name to filter snmp requests or keyword 'default'.
    state:
        description:
            - Manage the state of the resource.
        default: present
        choices: ['present','absent']
s�
# ensure snmp community is configured
- nxos_snmp_community:
    community: TESTING7
    group: network-operator
    state: present
s�
commands:
    description: commands sent to the device
    returned: always
    type: list
    sample: ["snmp-server community TESTING7 group network-operator"]
i����N(tload_configtrun_commands(tnxos_argument_spect
check_args(t
AnsibleModulecCsEd|krd}nd}i|d6|d6g}t||�}|S(Nsshow runtjsonttexttcommandtoutput(R(RtmoduleR
tcmdstbody((sT/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_community.pytexecute_show_commandQs	
cCsGg}x:|D]2}t|t�r2|j|�q
|j|�q
W|S(N(t
isinstancetlisttextendtappend(t
command_liststflat_command_listR((sT/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_community.pytflatten_list_s
cCsktd|�d}g}y4|dd}x|D]}|j|d�q1WWnttfk
rfnX|S(Nsshow snmp groupit
TABLE_roletROW_rolet	role_name(RRtKeyErrortAttributeError(Rtdatat
group_listtgroup_tabletgroup((sT/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_community.pytget_snmp_groupsis
c
Cs�dj|�}t||�d}i}|s2|Sd}tj||�}|rb|jd�}n|Sd|d<dj|�}tj||�}|r�|jd�|d<nd|d<dj|�}	tj|	|�}|r�|jd�|d<n|S(	Nsshow run snmp all | grep {0}issnmp-server community (\S+)iR!s%snmp-server community {0} group (\S+)tacls'snmp-server community {0} use-acl (\S+)(tformatRtretsearchR!tNone(
RtnameRRtcommunity_dicttcommunity_retmotcommunity_nametgroup_retacl_re((sT/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_community.pytget_snmp_communityws*

cCs�idd6dd6dd6}g}xj|j�D]\}|j|�j||�}|r.d|krt|jd|�n
|j|�d}q.q.W|S(Ns'snmp-server community {0} group {group}R!s'snmp-server community {0} use-acl {acl}R#s-no snmp-server community {0} use-acl {no_acl}tno_acli(tkeystgetR$tinsertRR'(tdeltat	communitytCMDStcommandstktcmd((sT/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_community.pytconfig_snmp_community�s


cCstdtdtdd�dtdddg�d	tdd�d
tdd�dtddd
gdd
��}|jt�td|ddd	ggddd	ggdt�}t�}t||�itd6gd6|d6}|jd}|jd	}|jd}|jd
}|jd}|rQ|dkr9d}qQ|dkrQd}qQnt	|�}	||	kr||j
dd�nt||�}
td	|d
|�}td�|j�D��}tt
|j��j|
j���}
|
jd
�dkr-|
jd
�|
jd
�r-|
jd
�|
d<q-ng}|dkrg|
r�dj|�}|j|�q�n:|d
kr�|
r�tt|
�|�}|j|�q�nt|�}|r�t|d<|js�t||�nd|kr�|jd�n||d<n|j|�dS(NR5trequiredttypetstrtaccesstchoicestrotrwR!R#tstatetabsenttpresenttdefaultt
argument_spectrequired_one_oftmutually_exclusivetsupports_check_modetchangedR7twarningssnetwork-operators
network-admintmsgs5Group not on switch. Please add before moving forwardcss-|]#\}}|dk	r||fVqdS(N(R'(t.0R8tv((sT/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_community.pys	<genexpr>�sR0sno snmp-server community {0}t	configurei(tdicttTruetupdateRR	RRtFalsetparamsR"t	fail_jsonR/titemstsett
differenceR2tpopR$RR:Rt
check_modeRt	exit_json(RFRRKtresultsR>R!R5R#RBtconfigured_groupstexistingtargstproposedR4R7RR((sT/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_community.pytmain�sj
		





	'

	
t__main__(tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR%t&ansible.module_utils.network.nxos.nxosRRRRtansible.module_utils.basicR	RRR"R/R:Rat__name__(((sT/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_community.pyt<module>s"


$		
				H

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