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

�
�Udac@s�idd6dgd6dd6ZdZdZdZd	d
lZd	dlmZmZd	dlmZm	Z	d	d
l
mZd�Zd�Z
d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zedkr�e�nd
S(s1.1tmetadata_versiontpreviewtstatustnetworktsupported_bys�
---
module: nxos_snmp_host
extends_documentation_fragment: nxos
version_added: "2.2"
short_description: Manages SNMP host configuration.
description:
    - Manages SNMP host configuration parameters.
author:
    - Jason Edelman (@jedelman8)
    - Gabriele Gerbino (@GGabriele)
notes:
    - Tested against NXOSv 7.3.(0)D1(1) on VIRL
    - C(state=absent) removes the host configuration if it is configured.
options:
    snmp_host:
        description:
            - IP address of hostname of target host.
        required: true
    version:
        description:
            - SNMP version. If this is not specified, v1 is used.
        choices: ['v1', 'v2c', 'v3']
    v3:
        description:
            - Use this when verion is v3. SNMPv3 Security level.
        choices: ['noauth', 'auth', 'priv']
    community:
        description:
            - Community string or v3 username.
    udp:
        description:
            - UDP port number (0-65535).
        default: 162
    snmp_type:
        description:
            - type of message to send to host. If this is not
              specified, trap type is used.
        choices: ['trap', 'inform']
    vrf:
        description:
            - VRF to use to source traffic to source.
              If state = absent, the vrf is removed.
    vrf_filter:
        description:
            - Name of VRF to filter.
              If state = absent, the vrf is removed from the filter.
    src_intf:
        description:
            - Source interface. Must be fully qualified interface name.
              If state = absent, the interface is removed.
    state:
        description:
            - Manage the state of the resource. If state = present, the
              host is added to the configuration. If only vrf and/or
              vrf_filter and/or src_intf are given, they will be added to
              the existing host configuration. If state = absent, the
              host is removed if community parameter is given. It is possible
              to remove only vrf and/or src_int and/or vrf_filter
              by providing only those parameters and no community parameter.
        default: present
        choices: ['present','absent']
sw
# ensure snmp host is configured
- nxos_snmp_host:
    snmp_host: 192.0.2.3
    community: TESTING
    state: present
s�
commands:
    description: commands sent to the device
    returned: always
    type: list
    sample: ["snmp-server host 192.0.2.3 filter-vrf another_test_vrf"]
i����N(tload_configtrun_commands(tnxos_argument_spect
check_args(t
AnsibleModulecCs!i|d6dd6}t||�S(Ntcommandtjsontoutput(R(R
tmodule((sO/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_host.pytexecute_show_commandos
cCsqi}xd|j�D]V\}}|j|�}|r|j|�}|r\t|�||<qi|||<qqW|S(N(titemstgettstr(tkey_mapttabletnew_dicttkeytvaluetnew_key((sO/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_host.pyt
apply_key_mapxscCsGg}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_host.pytflatten_list�s
cCs�td|�}idd6dd6dd6dd6d	d
6}idd6dd6dd6dd6d	d
6}i}|r�yq|ddd}t|t�r�|g}nx=|D]5}t|d�dt|d�j�}	|jd�}
t||�}|
r5|
|d<tjd|
�r5|
j	d�dj�|d<q5n|jd�}|r�|ddj	d�dj	d�}
g|
D]}|j�^qu}||d<n|jd�}|r�|j	d�dj�|d<n|||	<q�WWn�t
k
rfyW|ddd}t|t�r|g}nx#|D]}t|d�dt|d�j�}	|jd�}
t||�}|
r�|
|d<tjd|
�r�|
j	d�dj�|d<q�n|jd�}|r�|j�|d<n|jd �}|r6|d!d"j	d�}
g|
D]}|j�^q}||d<n|||	<q%WWq~t
ttfk
rb|SXnttfk
r}|SX|j|d|�}|r�i}xF|j
�D]8\}	}t|t�r�|j�||	<q�|||	<q�W|SniS(#Nsshow snmp hosttudptporttversiontv3tlevelt	snmp_typettypet	communitytsecnamet	sec_levelt
notif_typetcommun_or_userit
TABLE_hosttROW_hostthostt_tsrc_intfs
interface:t:itTABLE_vrf_filterstROW_vrf_filterst
vrf_filtert,tvrftTABLE_hostst	ROW_hoststaddresstuse_vrf_nametTABLE_filter_vrftROW_filter_vrftfilter_vrf_name(RRtdictRtstripRRtretsearchtsplittKeyErrortAttributeErrort	TypeErrorR(R.R R
tbodythost_mapthost_map_5ktresourcetresource_tableteachRtsrct
host_resourcetvrf_filtR4R6tfilterstfindtfix_findR((sO/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_host.pyt
get_snmp_host�s�


(
#$
 

(
#
cCs�g}|ddkr8d|d<dj|||�}nd|ddkrjd|d<dj|||�}n2|ddkr�d	|d<dj|||�}n|r�|j|�n|S(
NR"R#t3sgno snmp-server host {0} {snmp_type} version                     {version} {v3} {community} udp-port {1}tv2ct2csbno snmp-server host {0} {snmp_type} version                     {version} {community} udp-port {1}tv1t1(tformatR(R.R texistingtcommandsR
((sO/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_host.pytremove_snmp_host�s


cCsAg}|jd�r=|jdj||jd�|��n|S(NR6sDno snmp-server host {0} use-vrf                     {1} udp-port {2}(RRRX(R.R tproposedRYRZ((sO/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_host.pyt
remove_vrfs
"cCsbg}|jd�r^|jd�|jd�kr^|jdj||jd�|��q^n|S(NR4sGno snmp-server host {0} filter-vrf                     {1} udp-port {2}(RRRX(R.R R\RYRZ((sO/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_host.pyt
remove_filter
s%cCsAg}|jd�r=|jdj||jd�|��n|S(NR0sMno snmp-server host {0} source-interface                     {1} udp-port {2}(RRRX(R.R R\RYRZ((sO/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_host.pyt
remove_srcs
"c	Cs)g}g}|d}dj|d�}|jd�}	|jd�}
|jd�}|jd�}|j|�t|	|
||g�r�|	p�|jd�}
|
r�|j|
�n|
p�|jd�}
|
r.|
dkr�d	}n*|
d
kr�d}n|
dkrd}nd
j|�}|j|�n|rY|pF|jd�}|j|�n|r�|pq|jd�}|j|�ndj|�}|j|�dj|�}|j|�nidd6dd6dd6}xH|D]@}|j|�}|r�|j|||�}|j|�q�q�W|S(Nt	snmp_hostssnmp-server host {0}R%R"R#R'R&RVRWRTRURSsversion {0}s
 udp-port {0}t s9snmp-server host {0} filter-vrf {vrf_filter} udp-port {1}R4s/snmp-server host {0} use-vrf {vrf} udp-port {1}R6s=snmp-server host {0} source-interface {src_intf} udp-port {1}R0(RXRRtanytjoin(tdeltaR R\RYR
RZtcommand_builderR.tcmdR%R"tverR'ttype_stringtvntversion_stringt
ver_stringtcommunity_stringt
udp_stringtCMDSRR
((sO/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_host.pytconfig_snmp_hostsV

			


cCsPtdtdtdd�dtdd�dtdddd�d	td
ddd
g�dtdd�d
td
dddg�dtdd�dtdd�dtd
ddg�dtd
ddgdd��
}|jt�td|dt�}t�}t||�itd6gd6|d6}|jd}|jd}|jd}|jd	}|jd}|jd
}	|jd}
|jd}|jd}|jd}
t	|||�}|dkr�|r�|jd	�}q�d}n|dkr|r|jd�}qd}n|	dkrC|d
krC|rC|jd
�}	qCn|dkrn|dkrn|jdd �n|dks�|dkr�|	r�|jdd!�nt
|
||g�s�t||||g�s�|jdd"�q�n|d
kr
|	dkr
|jdd#�n|jd�}|rR|rR|
|dkrEd|d<qR|
|d<ng}td|d|d|d	|d|d|
d
|	d|d|�	}td$�|j�D��}|
dkr}|r}|jd�r�|jt|||��q�|jd�r|jt||||��n|jd�rL|jt||||��n|jd�r�|jt||||��q�nd|
dkr�tt|j��j|j���}|r�t|||||�}|j|�q�nt|�}|r?t|d<|jst||�nd%|kr2|jd&�n||d<n|j|�dS('NR`trequiredR&RR'R tdefaultt162R"tchoicesRVRTR#R0tnoauthtauthtprivR4R6R%ttraptinformtstatetabsenttpresentt
argument_spectsupports_check_modetchangedRZtwarningstmsgsinform requires snmp v2c or v3s;param: "v3" should not be used when using version v1 or v2cs{when not configuring options like vrf_filter, vrf, and src_intf,the following params are required: type, version, communitysRwhen using version=v3, the param v3 (options: auth, noauth, priv) is also requiredcss-|]#\}}|dk	r||fVqdS(N(tNone(t.0tktv((sO/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_host.pys	<genexpr>�st	configurei(R>tTruetupdateRR	RRtFalsetparamsRRR�Rt	fail_jsonRbtallRRR[R_R]R^tsett
differenceRoRt
check_modeRtpopt	exit_json(R|R
RtresultsR`R'R R"R0R#R4R6R%RyRYtstoreRZtargsR\RdR
tcmds((sO/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_host.pytmainXs�
	










		

	"'
	
t__main__(tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR@t&ansible.module_utils.network.nxos.nxosRRRRtansible.module_utils.basicR	RRRRRR[R]R^R_RoR�t__name__(((sO/usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_host.pyt<module>s*


A			
	
	`						:	z

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