�
�Udac @ s� i d d 6d g d 6d d 6Z d Z d Z d Z d d
l Z d d l m Z m Z d d l m Z m Z d d
l
m Z d � Z d � Z
d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z e d k r� e � n d
S( s 1.1t metadata_versiont previewt statust networkt 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( t load_configt run_commands( t nxos_argument_spect
check_args( t
AnsibleModulec C s! i | d 6d d 6} t | | � S( Nt commandt jsont output( R ( R
t module( ( sO /usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_host.pyt execute_show_commando s
c C sq i } xd | j � D]V \ } } | j | � } | r | j | � } | r\ t | � | | <qi | | | <q q W| S( N( t itemst gett str( t key_mapt tablet new_dictt keyt valuet new_key( ( sO /usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_host.pyt
apply_key_mapx s c C sG g } x: | D]2 } t | t � r2 | j | � q
| j | � q
W| S( N( t
isinstancet listt extendt append( t
command_listst flat_command_listR
( ( sO /usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snmp_host.pyt flatten_list� s
c C s� t d | � } i d d 6d d 6d d 6d d 6d d
6} i d d 6d d 6d d 6d d 6d d
6} i } | r�yq| d d d } t | t � r� | g } n x=| D]5} t | d � d t | d � j � } | j d � }
t | | � } |
r5|
| d <t j d |
� r5|
j d � d j � | d <q5n | j d � } | r�| d d j d � d j d � }
g |
D] } | j � ^ qu} | | d <n | j d � } | r�| j d � d j � | d <n | | | <q� WWn�t
k
rfyW| d d d } t | t � r| g } n x#| D]} t | d � d t | d � j � } | j d � }
t | | � } |
r�|
| d <t j d |
� r�|
j d � d j � | d <q�n | j d � } | r�| j � | d <n | j d � } | r6| d! d"