From d632fe097f337f70e2f02816f1efd7c0912fcc32 Mon Sep 17 00:00:00 2001 From: ambroise Date: Thu, 25 May 2023 22:09:33 +0200 Subject: [PATCH] ios_snmp_server: Update the module to take in count a lot of missing traps --- .../fragments/ios_snmp_server_changes.yml | 4 + .../ios/argspec/snmp_server/snmp_server.py | 445 +++- .../ios/config/snmp_server/snmp_server.py | 117 +- .../ios/facts/snmp_server/snmp_server.py | 2 +- .../network/ios/rm_templates/snmp_server.py | 1958 +++++++++++++---- plugins/modules/ios_snmp_server.py | 700 +++++- .../network/ios/test_ios_snmp_server.py | 254 ++- 7 files changed, 2785 insertions(+), 695 deletions(-) create mode 100644 changelogs/fragments/ios_snmp_server_changes.yml diff --git a/changelogs/fragments/ios_snmp_server_changes.yml b/changelogs/fragments/ios_snmp_server_changes.yml new file mode 100644 index 0000000000..1132985b49 --- /dev/null +++ b/changelogs/fragments/ios_snmp_server_changes.yml @@ -0,0 +1,4 @@ +--- +minor_changes: + - ios_snmp_server - Update the module to manage correctly a lot of traps not take in count + - ios_snmp_server - Fixe an issue with cbgp2 to take in count correctly for bgp traps diff --git a/plugins/module_utils/network/ios/argspec/snmp_server/snmp_server.py b/plugins/module_utils/network/ios/argspec/snmp_server/snmp_server.py index d0473cc971..b7476e76cc 100644 --- a/plugins/module_utils/network/ios/argspec/snmp_server/snmp_server.py +++ b/plugins/module_utils/network/ios/argspec/snmp_server/snmp_server.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2022 Red Hat +# Copyright 2023 Red Hat # GNU General Public License v3.0+ # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) @@ -13,15 +13,16 @@ ############################################# # # This file is auto generated by the -# cli_rm_builder. +# ansible.content_builder. # # Manually editing this file is not advised. # # To update the argspec make the desired changes -# in the module docstring and re-run -# cli_rm_builder. +# in the documentation in the module file and re-run +# ansible.content_builder commenting out +# the path to external 'docstring' in build.yaml. # -############################################# +############################################## """ The arg spec for the ios_snmp_server module @@ -34,7 +35,10 @@ class Snmp_serverArgs(object): # pylint: disable=R0903 argument_spec = { "config": { "options": { - "accounting": {"options": {"command": {"type": "str"}}, "type": "dict"}, + "accounting": { + "options": {"command": {"type": "str"}}, + "type": "dict", + }, "cache": {"type": "int"}, "chassis_id": {"type": "str"}, "communities": { @@ -52,7 +56,10 @@ class Snmp_serverArgs(object): # pylint: disable=R0903 "contact": {"type": "str"}, "context": {"elements": "str", "type": "list"}, "drop": { - "options": {"unknown_user": {"type": "bool"}, "vrf_traffic": {"type": "bool"}}, + "options": { + "unknown_user": {"type": "bool"}, + "vrf_traffic": {"type": "bool"}, + }, "type": "dict", }, "engine_id": { @@ -82,7 +89,11 @@ class Snmp_serverArgs(object): # pylint: disable=R0903 "elements": "dict", "options": { "context": {"type": "str"}, - "version_option": {"choices": ["auth", "noauth", "priv"], "type": "str"}, + "match": {"choices": ["exact", "prefix"], "type": "str"}, + "version_option": { + "choices": ["auth", "noauth", "priv"], + "type": "str", + }, "group": {"type": "str"}, "notify": {"type": "str"}, "read": {"type": "str"}, @@ -101,7 +112,10 @@ class Snmp_serverArgs(object): # pylint: disable=R0903 "community_string": {"type": "str"}, "traps": {"type": "list", "elements": "str"}, "version": {"choices": ["1", "2c", "3"], "type": "str"}, - "version_option": {"choices": ["auth", "noauth", "priv"], "type": "str"}, + "version_option": { + "choices": ["auth", "noauth", "priv"], + "type": "str", + }, "vrf": {"type": "str"}, }, "type": "list", @@ -116,7 +130,10 @@ class Snmp_serverArgs(object): # pylint: disable=R0903 "type": "dict", }, "ip": { - "options": {"dscp": {"type": "int"}, "precedence": {"type": "int"}}, + "options": { + "dscp": {"type": "int"}, + "precedence": {"type": "int"}, + }, "type": "dict", }, "location": {"type": "str"}, @@ -124,7 +141,6 @@ class Snmp_serverArgs(object): # pylint: disable=R0903 "packet_size": {"type": "int"}, "password_policy": { "elements": "dict", - "no_log": False, "options": { "change": {"type": "int"}, "digits": {"type": "int"}, @@ -145,6 +161,7 @@ class Snmp_serverArgs(object): # pylint: disable=R0903 "trap_timeout": {"type": "int"}, "traps": { "options": { + "aaa_server": {"type": "bool"}, "auth_framework": { "options": { "sec_violation": {"type": "bool"}, @@ -188,6 +205,22 @@ class Snmp_serverArgs(object): # pylint: disable=R0903 }, "type": "dict", }, + "bulkstat": { + "options": { + "enable": {"type": "bool"}, + "collection": {"type": "bool"}, + "transfer": {"type": "bool"}, + }, + "type": "dict", + }, + "call_home": { + "options": { + "enable": {"type": "bool"}, + "message_send_fail": {"type": "bool"}, + "server_fail": {"type": "bool"}, + }, + "type": "dict", + }, "casa": {"type": "bool"}, "cef": { "options": { @@ -204,7 +237,10 @@ class Snmp_serverArgs(object): # pylint: disable=R0903 "config_copy": {"type": "bool"}, "config_ctid": {"type": "bool"}, "cpu": { - "options": {"enable": {"type": "bool"}, "threshold": {"type": "bool"}}, + "options": { + "enable": {"type": "bool"}, + "threshold": {"type": "bool"}, + }, "type": "dict", }, "dhcp": {"type": "bool"}, @@ -218,19 +254,29 @@ class Snmp_serverArgs(object): # pylint: disable=R0903 }, "eigrp": {"type": "bool"}, "entity": {"type": "bool"}, + "entity_diag": { + "options": { + "boot_up_fail": {"type": "bool"}, + "enable": {"type": "bool"}, + "hm_test_recover": {"type": "bool"}, + "hm_thresh_reached": {"type": "bool"}, + "scheduled_test_fail": {"type": "bool"}, + }, + "type": "dict", + }, + "entity_perf": { + "options": { + "enable": {"type": "bool"}, + "throughput_notif": {"type": "bool"}, + }, + "type": "dict", + }, + "entity_state": {"type": "bool"}, "energywise": {"type": "bool"}, "envmon": { "options": { - "fan": { - "options": { - "shutdown": {"type": "bool"}, - "enable": {"type": "bool"}, - "status": {"type": "bool"}, - "supply": {"type": "bool"}, - "temperature": {"type": "bool"}, - }, - "type": "dict", - }, + "enable": {"type": "bool"}, + "fan": {"type": "bool"}, "shutdown": {"type": "bool"}, "status": {"type": "bool"}, "supply": {"type": "bool"}, @@ -238,6 +284,7 @@ class Snmp_serverArgs(object): # pylint: disable=R0903 }, "type": "dict", }, + "errdisable": {"type": "bool"}, "ethernet": { "options": { "cfm": { @@ -275,8 +322,24 @@ class Snmp_serverArgs(object): # pylint: disable=R0903 }, "type": "dict", }, + "ether_oam": {"type": "bool"}, "event_manager": {"type": "bool"}, - "flowmon": {"type": "bool"}, + "flash": { + "options": { + "enable": {"type": "bool"}, + "insertion": {"type": "bool"}, + "lowspace": {"type": "bool"}, + "removal": {"type": "bool"}, + }, + "type": "dict", + }, + "flex_links": { + "options": { + "enable": {"type": "bool"}, + "status": {"type": "bool"}, + }, + "type": "dict", + }, "firewall": { "options": { "enable": {"type": "bool"}, @@ -284,6 +347,7 @@ class Snmp_serverArgs(object): # pylint: disable=R0903 }, "type": "dict", }, + "flowmon": {"type": "bool"}, "frame_relay": { "options": { "enable": {"type": "bool"}, @@ -343,6 +407,15 @@ class Snmp_serverArgs(object): # pylint: disable=R0903 "type": "dict", }, "ipsla": {"type": "bool"}, + "isis": {"type": "bool"}, + "l2tc": { + "options": { + "enable": {"type": "bool"}, + "sys_threshold": {"type": "bool"}, + "threshold": {"type": "bool"}, + }, + "type": "dict", + }, "l2tun": { "options": { "pseudowire_status": {"type": "bool"}, @@ -350,9 +423,139 @@ class Snmp_serverArgs(object): # pylint: disable=R0903 }, "type": "dict", }, + "license": {"type": "bool"}, + "lisp": {"type": "bool"}, + "local_auth": {"type": "bool"}, + "mac_notification": { + "options": { + "enable": {"type": "bool"}, + "change": {"type": "bool"}, + "move": {"type": "bool"}, + "threshold": {"type": "bool"}, + }, + "type": "dict", + }, + "memory": { + "options": { + "enable": {"type": "bool"}, + "bufferpeak": {"type": "bool"}, + }, + "type": "dict", + }, + "mpls": { + "options": { + "fast_reroute": { + "options": { + "enable": {"type": "bool"}, + "protected": {"type": "bool"}, + }, + "type": "dict", + }, + "ldp": { + "options": { + "enable": {"type": "bool"}, + "pv_limit": {"type": "bool"}, + "session_down": {"type": "bool"}, + "session_up": {"type": "bool"}, + "threshold": {"type": "bool"}, + }, + "type": "dict", + }, + "rfc": { + "options": { + "ldp": { + "options": { + "enable": {"type": "bool"}, + "pv_limit": {"type": "bool"}, + "session_down": {"type": "bool"}, + "session_up": {"type": "bool"}, + "threshold": {"type": "bool"}, + }, + "type": "dict", + }, + "traffic_eng": { + "options": { + "enable": {"type": "bool"}, + "down": {"type": "bool"}, + "reoptimized": {"type": "bool"}, + "reroute": {"type": "bool"}, + "up": {"type": "bool"}, + }, + "type": "dict", + }, + "vpn": { + "options": { + "enable": {"type": "bool"}, + "illegal_label": {"type": "bool"}, + "max_thresh_cleared": { + "type": "bool", + }, + "max_threshold": {"type": "bool"}, + "mid_threshold": {"type": "bool"}, + "vrf_down": {"type": "bool"}, + "vrf_up": {"type": "bool"}, + }, + "type": "dict", + }, + }, + }, + "traffic_eng": { + "options": { + "enable": {"type": "bool"}, + "down": {"type": "bool"}, + "reroute": {"type": "bool"}, + "up": {"type": "bool"}, + }, + "type": "dict", + }, + "vpn": { + "options": { + "enable": {"type": "bool"}, + "illegal_label": {"type": "bool"}, + "max_thresh_cleared": {"type": "bool"}, + "max_threshold": {"type": "bool"}, + "mid_threshold": {"type": "bool"}, + "vrf_down": {"type": "bool"}, + "vrf_up": {"type": "bool"}, + }, + "type": "dict", + }, + }, + "type": "dict", + }, "msdp": {"type": "bool"}, "mvpn": {"type": "bool"}, - "mpls_vpn": {"type": "bool"}, + "nhrp": { + "options": { + "enable": {"type": "bool"}, + "nhc": { + "options": { + "enable": {"type": "bool"}, + "down": {"type": "bool"}, + "up": {"type": "bool"}, + }, + "type": "dict", + }, + "nhp": { + "options": { + "enable": {"type": "bool"}, + "down": {"type": "bool"}, + "up": {"type": "bool"}, + }, + "type": "dict", + }, + "nhs": { + "options": { + "enable": {"type": "bool"}, + "down": {"type": "bool"}, + "up": {"type": "bool"}, + }, + "type": "dict", + }, + "quota_exceeded": {"type": "bool"}, + }, + "type": "dict", + }, "ospf": { "options": { "cisco_specific": { @@ -362,11 +565,17 @@ class Snmp_serverArgs(object): # pylint: disable=R0903 "retransmit": {"type": "bool"}, "state_change": { "options": { - "nssa_trans_change": {"type": "bool"}, + "nssa_trans_change": { + "type": "bool", + }, "shamlink": { "options": { - "interface": {"type": "bool"}, - "neighbor": {"type": "bool"}, + "interface": { + "type": "bool", + }, + "neighbor": { + "type": "bool", + }, }, "type": "dict", }, @@ -383,6 +592,44 @@ class Snmp_serverArgs(object): # pylint: disable=R0903 }, "type": "dict", }, + "ospfv3": { + "options": { + "errors": { + "options": { + "enable": {"type": "bool"}, + "bad_packet": {"type": "bool"}, + "config_error": {"type": "bool"}, + "virt_bad_packet": {"type": "bool"}, + "virt_config_error": {"type": "bool"}, + }, + "type": "dict", + }, + "rate_limit": {"type": "int"}, + "state_change": { + "options": { + "enable": {"type": "bool"}, + "if_state_change": {"type": "bool"}, + "neighbor_restart_helper_status_change": { + "type": "bool", + }, + "neighbor_state_change": {"type": "bool"}, + "nssa_translator_status_change": { + "type": "bool", + }, + "restart_status_change": {"type": "bool"}, + "virtif_state_change": {"type": "bool"}, + "virtneighbor_restart_helper_status_change": { + "type": "bool", + }, + "virtneighbor_state_change": { + "type": "bool", + }, + }, + "type": "dict", + }, + }, + "type": "dict", + }, "pim": { "options": { "invalid_pim_message": {"type": "bool"}, @@ -392,19 +639,35 @@ class Snmp_serverArgs(object): # pylint: disable=R0903 }, "type": "dict", }, - "vrfmib": { + "pki": {"type": "bool"}, + "port_security": {"type": "bool"}, + "power_ethernet": { "options": { - "vrf_up": {"type": "bool"}, - "vrf_down": {"type": "bool"}, - "vnet_trunk_up": {"type": "bool"}, - "vnet_trunk_down": {"type": "bool"}, + "enable": {"type": "bool"}, + "group": { + "options": { + "slot_id": {"type": "int"}, + "threshold": {"type": "int"}, + }, + "elements": "dict", + "type": "list", + }, + "police": {"type": "bool"}, }, "type": "dict", }, - "pki": {"type": "bool"}, - "rsvp": {"type": "bool"}, - "isis": {"type": "bool"}, "pw_vc": {"type": "bool"}, + "rep": {"type": "bool"}, + "rsvp": {"type": "bool"}, + "rf": {"type": "bool"}, + "smart_license": { + "options": { + "enable": {"type": "bool"}, + "entitlement": {"type": "bool"}, + "global": {"type": "bool"}, + }, + "type": "dict", + }, "snmp": { "options": { "authentication": {"type": "bool"}, @@ -415,10 +678,103 @@ class Snmp_serverArgs(object): # pylint: disable=R0903 }, "type": "dict", }, + "stackwise": {"type": "bool"}, + "stpx": { + "options": { + "enable": {"type": "bool"}, + "inconsistency": {"type": "bool"}, + "loop_inconsistency": {"type": "bool"}, + "root_inconsistency": {"type": "bool"}, + }, + "type": "dict", + }, "syslog": {"type": "bool"}, "transceiver_all": {"type": "bool"}, + "trustsec": { + "options": { + "authz_file_error": {"type": "bool"}, + "cache_file_error": {"type": "bool"}, + "enable": {"type": "bool"}, + "keystore_file_error": {"type": "bool"}, + "keystore_sync_fail": {"type": "bool"}, + "random_number_fail": {"type": "bool"}, + "src_entropy_fail": {"type": "bool"}, + }, + "type": "dict", + }, + "trustsec_interface": { + "options": { + "enable": {"type": "bool"}, + "authc_fail": {"type": "bool"}, + "authz_fail": {"type": "bool"}, + "sap_fail": {"type": "bool"}, + "supplicant_fail": {"type": "bool"}, + "unauthorized": {"type": "bool"}, + }, + "type": "dict", + }, + "trustsec_policy": { + "options": { + "enable": {"type": "bool"}, + "authz_sgacl_fail": {"type": "bool"}, + "peer_policy_updated": {"type": "bool"}, + }, + "type": "dict", + }, + "trustsec_server": { + "options": { + "enable": {"type": "bool"}, + "provision_secret": {"type": "bool"}, + "radius_server": {"type": "bool"}, + }, + "type": "dict", + }, + "trustsec_sxp": { + "options": { + "enable": {"type": "bool"}, + "binding_conflict": {"type": "bool"}, + "binding_err": {"type": "bool"}, + "binding_expn_fail": {"type": "bool"}, + "conn_config_err": {"type": "bool"}, + "conn_down": {"type": "bool"}, + "conn_srcaddr_err": {"type": "bool"}, + "conn_up": {"type": "bool"}, + "msg_parse_err": {"type": "bool"}, + "oper_nodeid_change": {"type": "bool"}, + }, + "type": "dict", + }, "tty": {"type": "bool"}, + "udld": { + "options": { + "enable": {"type": "bool"}, + "link_fail_rpt": {"type": "bool"}, + "status_change": {"type": "bool"}, + }, + "type": "dict", + }, + "vlan_membership": {"type": "bool"}, + "vlancreate": {"type": "bool"}, + "vlandelete": {"type": "bool"}, + "vrfmib": { + "options": { + "vrf_up": {"type": "bool"}, + "vrf_down": {"type": "bool"}, + "vnet_trunk_up": {"type": "bool"}, + "vnet_trunk_down": {"type": "bool"}, + }, + "type": "dict", + }, "vrrp": {"type": "bool"}, + "vswitch": { + "options": { + "dual_active": {"type": "bool"}, + "enable": {}, + "vsl": {"type": "bool"}, + }, + "type": "dict", + }, + "vtp": {"type": "bool"}, }, "type": "dict", }, @@ -431,17 +787,23 @@ class Snmp_serverArgs(object): # pylint: disable=R0903 "no_log": False, "type": "dict", "options": { - "algorithm": {"type": "str", "choices": ["md5", "sha"]}, - "password": {"type": "str", "no_log": True}, + "algorithm": { + "type": "str", + "choices": ["md5", "sha"], + }, + "password": {"type": "str"}, }, }, "encryption": { "no_log": False, "type": "dict", "options": { - "priv": {"type": "str", "choices": ["3des", "aes", "des"]}, + "priv": { + "type": "str", + "choices": ["3des", "aes", "des"], + }, "priv_option": {"type": "str"}, - "password": {"type": "str", "no_log": True}, + "password": {"type": "str"}, }, }, "group": {"type": "str"}, @@ -449,7 +811,10 @@ class Snmp_serverArgs(object): # pylint: disable=R0903 "udp_port": {"type": "int"}, "username": {"type": "str"}, "version": {"choices": ["v1", "v2c", "v3"], "type": "str"}, - "version_option": {"choices": ["encrypted"], "type": "str"}, + "version_option": { + "choices": ["encrypted"], + "type": "str", + }, "vrf": {"type": "str"}, }, "type": "list", diff --git a/plugins/module_utils/network/ios/config/snmp_server/snmp_server.py b/plugins/module_utils/network/ios/config/snmp_server/snmp_server.py index ff45f7b5fb..61e58d55d6 100644 --- a/plugins/module_utils/network/ios/config/snmp_server/snmp_server.py +++ b/plugins/module_utils/network/ios/config/snmp_server/snmp_server.py @@ -75,74 +75,124 @@ def __init__(self, module): "password_policy", "users", "views", + #"traps.power_ethernet.group", ] self.complex_parsers = [ + "traps.aaa_server", "traps.auth_framework", "traps.bfd", - "traps.bgp", + #"traps.bgp", + #"traps.bgp.cbgp2", "traps.bridge", + "traps.bulkstat", + "traps.call_home", "traps.casa", + "traps.cef", "traps.cnpd", "traps.config", "traps.config_copy", "traps.config_ctid", + "traps.cpu", "traps.dhcp", + "traps.dlsw", "traps.eigrp", - "traps.entity", "traps.energywise", + "traps.entity", + "traps.entity_diag", + "traps.entity_perf", + "traps.entity_state", + "traps.envmon", + "traps.errdisable", + "traps.ether_oam", + "traps.ethernet.cfm.alarm", + "traps.ethernet.cfm.cc", + "traps.ethernet.cfm.crosscheck", + "traps.ethernet.evc", "traps.event_manager", + "traps.flash", + "traps.flex_links", + "traps.firewall", "traps.flowmon", + "traps.frame_relay", + "traps.frame_relay.subif", "traps.fru_ctrl", "traps.hsrp", - "traps.ipsla", - "traps.isis", - "traps.msdp", - "traps.mvpn", - "traps.mpls_vpn", - "traps.pki", - "traps.pw_vc", - "traps.rsvp", - "traps.syslog", - "traps.transceiver_all", - "traps.tty", - "traps.vrrp", - "traps.vrfmib", - "traps.ipmulticast", "traps.ike.policy.add", "traps.ike.policy.delete", "traps.ike.tunnel.start", "traps.ike.tunnel.stop", + "traps.ipmulticast", "traps.ipsec.cryptomap.add", - "traps.ipsec.cryptomap.delete", "traps.ipsec.cryptomap.attach", + "traps.ipsec.cryptomap.delete", "traps.ipsec.cryptomap.detach", + "traps.ipsec.too_many_sas", "traps.ipsec.tunnel.start", "traps.ipsec.tunnel.stop", - "traps.ipsec.too_many_sas", + "traps.ipsla", + "traps.isis", + "traps.l2tc", + "traps.l2tun.pseudowire_status", + "traps.l2tun.session", + "traps.lisp", + "traps.license", + "traps.local_auth", + "traps.mac_notification", + "traps.memory", + "traps.mpls.fast_reroute", + "traps.mpls.ldp", + "traps.mpls.rfc.ldp", + "traps.mpls.rfc.traffic_eng", + "traps.mpls.rfc.vpn", + "traps.mpls.traffic_eng", + "traps.mpls.vpn", + "traps.msdp", + "traps.mvpn", + "traps.nhrp.nhc", + "traps.nhrp.nhp", + "traps.nhrp.nhs", + "traps.nhrp.quota_exceeded", "traps.ospf.cisco_specific.error", - "traps.ospf.cisco_specific.retransmit", "traps.ospf.cisco_specific.lsa", + "traps.ospf.cisco_specific.retransmit", "traps.ospf.cisco_specific.state_change.nssa_trans_change", "traps.ospf.cisco_specific.state_change.shamlink.interface", "traps.ospf.cisco_specific.state_change.shamlink.neighbor", "traps.ospf.error", - "traps.ospf.retransmit", "traps.ospf.lsa", + "traps.ospf.retransmit", "traps.ospf.state_change", - "traps.l2tun.pseudowire_status", - "traps.l2tun.session", - "traps.cpu", - "traps.firewall", + "traps.ospfv3.errors", + "traps.ospfv3.rate_limit", + "traps.ospfv3.state_change", "traps.pim", + "traps.pki", + "traps.port_security", + "traps.power_ethernet", + "traps.pw_vc", + "traps.rep", + "traps.rsvp", + "traps.rf", + "traps.smart_license", "traps.snmp", - "traps.frame_relay", - "traps.frame_relay.subif", - "traps.cef", - "traps.dlsw", - "traps.ethernet.evc", - "traps.ethernet.cfm.alarm", - "traps.ethernet.cfm.cc", - "traps.ethernet.cfm.crosscheck", + "traps.stackwise", + "traps.stpx", + "traps.syslog", + "traps.transceiver_all", + "traps.trustsec", + "traps.trustsec_interface", + "traps.trustsec_policy", + "traps.trustsec_server", + "traps.trustsec_sxp", + "traps.tty", + "traps.udld", + "traps.vlan_membership", + "traps.vlancreate", + "traps.vlandelete", + "traps.vrfmib", + "traps.vrrp", + "traps.vswitch", + "traps.vtp", ] def execute_module(self): @@ -242,7 +292,8 @@ def _snmp_list_to_dict(self, data): tmp_data[k]["protocol"] = tmp elif k == "groups": tmp_data[k] = { - str(i[p_key.get(k)] + i.get("version_option", "")): i for i in tmp_data[k] + str(i[p_key.get(k)] + i.get("version_option", "") + i.get("context", "")): i + for i in tmp_data[k] } elif k == "views": tmp_data[k] = { diff --git a/plugins/module_utils/network/ios/facts/snmp_server/snmp_server.py b/plugins/module_utils/network/ios/facts/snmp_server/snmp_server.py index e8db3117b5..f0dd067da4 100644 --- a/plugins/module_utils/network/ios/facts/snmp_server/snmp_server.py +++ b/plugins/module_utils/network/ios/facts/snmp_server/snmp_server.py @@ -33,7 +33,7 @@ def __init__(self, module, subspec="config", options="options"): self.argument_spec = Snmp_serverArgs.argument_spec def get_snmp_data(self, connection): - return connection.get("show running-config | section ^snmp-server") + return connection.get("show running-config | section ^snmp") def sort_list_dicts(self, objs): p_key = { diff --git a/plugins/module_utils/network/ios/rm_templates/snmp_server.py b/plugins/module_utils/network/ios/rm_templates/snmp_server.py index 87f9e7c079..259b2bca9d 100644 --- a/plugins/module_utils/network/ios/rm_templates/snmp_server.py +++ b/plugins/module_utils/network/ios/rm_templates/snmp_server.py @@ -85,8 +85,6 @@ def cmd_option_trap_bgp(config_data): if conf: if conf.get("enable"): cmd += "snmp-server enable traps bgp" - if conf.get("cbgp2"): - cmd += " cbgp2" if conf.get("state_changes"): if conf.get("state_changes").get("enable"): cmd += " state-changes" @@ -109,7 +107,7 @@ def __init__(self, lines=None, module=None): # fmt: off PARSERS = [ - { + { "name": "accounting", "getval": re.compile( r""" @@ -281,6 +279,7 @@ def __init__(self, lines=None, module=None): (\s(?Pv1|v3|v2c))? (\s(?Pauth|noauth|priv))? (\scontext\s(?P\S+))? + (\smatch\s(?P\S+))? (\sread\s(?P\S+))? (\swrite\s(?P\S+))? (\snotify\s(?P\S+))? @@ -293,6 +292,7 @@ def __init__(self, lines=None, module=None): "{{ (' ' + version) if version is defined else '' }}" "{{ (' ' + version_option) if version_option is defined else '' }}" "{{ (' context ' + context) if context is defined else '' }}" + "{{ (' match ' + match) if match is defined else '' }}" "{{ (' read ' + read) if read is defined else '' }}" "{{ (' write ' + write) if write is defined else '' }}" "{{ (' notify ' + notify) if notify is defined else '' }}" @@ -305,6 +305,7 @@ def __init__(self, lines=None, module=None): "version": "{{ version }}", "version_option": "{{ version_option }}", "context": "{{ context }}", + "match": "{{ match }}", "notify": "{{ notify }}", "read": "{{ read }}", "write": "{{ write }}", @@ -464,7 +465,7 @@ def __init__(self, lines=None, module=None): "name": "if_index", "getval": re.compile( r""" - ^snmp-server\sifindex + ^snmp(-server|\sifmib)\sifindex (\s(?Ppersist))? """, re.VERBOSE, ), @@ -501,7 +502,7 @@ def __init__(self, lines=None, module=None): r""" ^snmp-server\sip\sdscp (\s(?P\d+))? - (\sprecedence(?P\d+))? + (\sprecedence\s(?P\d+))? """, re.VERBOSE, ), "setval": "snmp-server ip dscp " @@ -605,25 +606,38 @@ def __init__(self, lines=None, module=None): "trap_source": "{{ interface }}", }, }, - - { # only traps - "name": "traps.auth_framework", + # only traps + { + "name": "traps.aaa_server", "getval": re.compile( r""" + ^snmp-server\senable\straps\saaa_server + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps aaa_server", + "result": { + "traps": { + "aaa_server": True, + }, + }, + }, + { + "name": "traps.auth_framework", + "getval": re.compile( + r""" ^snmp-server\senable\straps\sauth-framework (\s(?Psec-violation))? """, re.VERBOSE, ), - "setval": "snmp-server enable traps" - "{{ (' auth-framework') if traps.auth_framework.enable is defined else '' }}" - "{{ (' sec-violation') if traps.auth_framework.sec_violation is defined else '' }}", + "setval": "snmp-server enable traps auth-framework" + "{{ (' sec-violation') if traps.auth_framework.sec_violation|d(False) is defined else '' }}", "result": { "traps": { "auth_framework": { "enable": True, - "sec_violation": "{{ not not excluded }}", - }, - }, + "sec_violation": "{{ not not sec_violation }}", + }, + }, }, }, { @@ -653,12 +667,11 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" ^snmp-server\senable\straps\sbgp - (\s(?Pcbgp2))? (\s(?Pstate-changes))? (\s(?Pall))? (\s(?Pbackward-trans))? (\s(?Plimited))? - (\sthreshold(?Pprefix))? + (\sthreshold(?Pprefix))?\s*$ """, re.VERBOSE, ), "setval": cmd_option_trap_bgp, @@ -666,7 +679,6 @@ def __init__(self, lines=None, module=None): "result": { "traps": { "bgp": { - "cbgp2": "{{ not not cbgp2 }}", "enable": True, "state_changes": { "enable": "{{ not not state_changes }}", @@ -681,6 +693,22 @@ def __init__(self, lines=None, module=None): }, }, }, + { + "name": "traps.bgp.cbgp2", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\sbgp\scbgp2 + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps bgp cbgp2", + "result": { + "traps": { + "bgp": { + "cbgp2": True, + }, + }, + }, + }, { "name": "traps.bridge", "getval": re.compile( @@ -703,6 +731,50 @@ def __init__(self, lines=None, module=None): }, }, }, + { + "name": "traps.bulkstat", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\sbulkstat + (\s(?Pcollection))? + (\s(?Ptransfer))? + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps bulkstat" + "{{ ' collection' if traps.bulkstat.collection|d(False) else '' }}" + "{{ ' transfer' if traps.bulkstat.transfer|d(False) else '' }}", + "result": { + "traps": { + "bulkstat": { + "enable": True, + "collection": "{{ not not collection }}", + "transfer": "{{ not not transfer }}", + }, + }, + }, + }, + { + "name": "traps.call_home", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\scall-home + (\s(?Pmessage-send-fail))? + (\s(?Pserver-fail))? + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps call-home" + "{{ ' message-send-fail' if traps.call_home.message_send_fail|d(False) else '' }}" + "{{ ' server-fail' if traps.call_home.server_fail|d(False) else '' }}", + "result": { + "traps": { + "call_home": { + "enable": True, + "message_send_fail": "{{ not not message_send_fail }}", + "server_fail": "{{ not not server_fail }}", + }, + }, + }, + }, { "name": "traps.casa", "getval": re.compile( @@ -718,59 +790,73 @@ def __init__(self, lines=None, module=None): }, }, { - "name": "traps.cnpd", + "name": "traps.cef", "getval": re.compile( r""" - ^snmp-server\senable\straps\scnpd + ^snmp-server\senable\straps\scef + (\s(?Presource-failure))? + (\s(?Ppeer-state-change))? + (\s(?Ppeer-fib-state-change))? + (\s(?Pinconsistency))? """, re.VERBOSE, ), - "setval": "snmp-server enable traps cnpd", + "setval": "snmp-server enable traps cef" + "{{ ' resource-failure' if traps.cef.resource_failure|d(False) else '' }}" + "{{ ' peer-state-change' if traps.cef.peer_state_change|d(False) else '' }}" + "{{ ' peer-fib-state-change' if traps.cef.peer_fib_state_change|d(False) else '' }}" + "{{ ' inconsistency' if traps.cef.inconsistency|d(False) else '' }}", "result": { "traps": { - "cnpd": True, + "cef": { + "enable": True, + "inconsistency": "{{ not not inconsistency }}", + "peer_fib_state_change": "{{ not not peer_fib_state_change }}", + "peer_state_change": "{{ not not peer_state_change }}", + "resource_failure": "{{ not not resource_failure }}", + }, }, }, }, { - "name": "traps.config", + "name": "traps.cnpd", "getval": re.compile( r""" - ^snmp-server\senable\straps\sconfig + ^snmp-server\senable\straps\scnpd """, re.VERBOSE, ), - "setval": "snmp-server enable traps config", + "setval": "snmp-server enable traps cnpd", "result": { "traps": { - "config": True, + "cnpd": True, }, }, }, { - "name": "traps.isis", + "name": "traps.config", "getval": re.compile( - r""" - ^snmp-server\senable\straps\sisis$ + r""" + ^snmp-server\senable\straps\sconfig\s*$ """, re.VERBOSE, ), - "setval": "snmp-server enable traps isis", + "setval": "snmp-server enable traps config", "result": { - "traps": { - "isis": True, + "traps": { + "config": True, }, - }, + }, }, { "name": "traps.config_copy", "getval": re.compile( r""" - ^snmp-server\senable\straps\sconfig-copy + ^snmp-server\senable\straps\s(config-copy|copy-config) """, re.VERBOSE, ), "setval": "snmp-server enable traps config-copy", "result": { "traps": { "config_copy": True, - }, + } }, }, { @@ -787,6 +873,26 @@ def __init__(self, lines=None, module=None): }, }, }, + { + "name": "traps.cpu", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\scpu + ((?P_threshold))? + (\s(?Pthreshold))? + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps cpu" + "{{ ' threshold' if traps.cpu.threshold|d(False) else '' }}", + "result": { + "traps": { + "cpu": { + "enable": True, + "threshold": "{{ not not threshold or not not threshold_old }}", + }, + }, + }, + }, { "name": "traps.dhcp", "getval": re.compile( @@ -802,30 +908,38 @@ def __init__(self, lines=None, module=None): }, }, { - "name": "traps.eigrp", + "name": "traps.dlsw", "getval": re.compile( r""" - ^snmp-server\senable\straps\seigrp + ^snmp-server\senable\straps\sdlsw + (\s(?Pcircuit))? + (\s(?Ptconn))? """, re.VERBOSE, ), - "setval": "snmp-server enable traps eigrp", + "setval": "snmp-server enable traps dlsw" + "{{ ' circuit' if traps.dlsw.circuit|d(False) else '' }}" + "{{ ' tconn' if traps.dlsw.tconn|d(False) else '' }}", "result": { "traps": { - "eigrp": True, + "dlsw": { + "enable": True, + "circuit": "{{ not not circuit }}", + "tconn": "{{ not not tconn }}", + }, }, }, }, { - "name": "traps.entity", + "name": "traps.eigrp", "getval": re.compile( r""" - ^snmp-server\senable\straps\sentity + ^snmp-server\senable\straps\seigrp """, re.VERBOSE, ), - "setval": "snmp-server enable traps entity", + "setval": "snmp-server enable traps eigrp", "result": { "traps": { - "entity": True, + "eigrp": True, }, }, }, @@ -844,380 +958,402 @@ def __init__(self, lines=None, module=None): }, }, { - "name": "traps.event_manager", + "name": "traps.entity", "getval": re.compile( r""" - ^snmp-server\senable\straps\sevent-manager + ^snmp-server\senable\straps\sentity\s*$ """, re.VERBOSE, ), - "setval": "snmp-server enable traps event-manager", + "setval": "snmp-server enable traps entity", "result": { "traps": { - "event_manager": True, + "entity": True, }, }, }, { - "name": "traps.flowmon", + "name": "traps.entity_diag", "getval": re.compile( r""" - ^snmp-server\senable\straps\sflowmon + ^snmp-server\senable\straps\sentity-diag + (\s(?Pboot-up-fail))? + (\s(?Phm-test-recover))? + (\s(?Phm-thresh-reached))? + (\s(?Pscheduled-test-fail))? """, re.VERBOSE, ), - "setval": "snmp-server enable traps flowmon", + "setval": "snmp-server enable traps entity-diag" + "{{ ' boot-up-fail' if traps.entity_diag.boot_up_fail|d(False) else '' }}" + "{{ ' hm-test-recover' if traps.entity_diag.hm_test_recover|d(False) else '' }}" + "{{ ' hm-thresh-reached' if traps.entity_diag.hm_thresh_reached|d(False) else '' }}" + "{{ ' scheduled-test-fail' if traps.entity_diag.scheduled_test_fail|d(False) else '' }}", "result": { "traps": { - "flowmon": True, + "entity_diag": { + "enable": True, + "boot_up_fail": "{{ not not boot_up_fail }}", + "hm_test_recover": "{{ not not hm_test_recover }}", + "hm_thresh_reached": "{{ not not hm_thresh_reached }}", + "scheduled_test_fail": "{{ not not scheduled_test_fail }}", + }, }, - }, + } }, { - "name": "traps.fru_ctrl", + # entity-perf throughput-notif + "name": "traps.entity_perf", "getval": re.compile( r""" - ^snmp-server\senable\straps\sfru-ctrl + ^snmp-server\senable\sttraps\sentity-perf + (\s(?Pthroughput-notif))? """, re.VERBOSE, ), - "setval": "snmp-server enable traps fru-ctrl", + "setval": "snmp-server enable traps entity-perf" + "{{ ' throughput-notif' if traps.entity_perf.throughput_notif|d(False) else '' }}", "result": { "traps": { - "fru_ctrl": True, + "entity_perf": { + "enable": True, + "throughput_notif": "{{ not not throughput_notif }}", + }, }, }, }, { - "name": "traps.hsrp", + "name": "traps.entity_state", "getval": re.compile( r""" - ^snmp-server\senable\straps\shsrp + ^snmp-server\senable\straps\sentity-state """, re.VERBOSE, ), - "setval": "snmp-server enable traps hsrp", + "setval": "snmp-server enable traps entity-state", "result": { "traps": { - "hsrp": True, + "entity_state": True, }, }, }, { - "name": "traps.ipsla", + "name": "traps.envmon", "getval": re.compile( r""" - ^snmp-server\senable\straps\sipsla + ^snmp-server\senable\straps\senvmon + (\s(?Pfan))? + (\s(?Pshutdown))? + (\s(?Psupply))? + (\s(?Ptemperature))? + (\s(?Pstatus))? """, re.VERBOSE, ), - "setval": "snmp-server enable traps ipsla", + "setval": "snmp-server enable traps envmon" + "{{ ' fan' if traps.envmon.fan|d(False) else '' }}" + "{{ ' shutdown' if traps.envmon.shutdown|d(False) else '' }}" + "{{ ' supply' if traps.envmon.supply|d(False) else '' }}" + "{{ ' temperature' if traps.envmon.temperature|d(False) else '' }}" + "{{ ' status' if traps.envmon.status|d(False) else '' }}", "result": { "traps": { - "ipsla": True, + "envmon": { + "enable": True, + "fan": "{{ True if fan else False }}", + "shutdown": "{{ True if shutdown else False }}", + "supply": "{{ True if supply else False }}", + "temperature": "{{ True if temperature else False }}", + "status": "{{ True if status else False }}", + }, }, }, }, { - "name": "traps.msdp", + "name": "traps.errdisable", "getval": re.compile( r""" - ^snmp-server\senable\straps\smsdp$ + ^snmp-server\senable\straps\serrdisable """, re.VERBOSE, ), - "setval": "snmp-server enable traps msdp", + "setval": "snmp-server enable traps errdisable", "result": { "traps": { - "msdp": True, + "errdisable": True, }, }, }, { - "name": "traps.pw_vc", + "name": "traps.ether_oam", "getval": re.compile( r""" - ^snmp-server\senable\straps\spw\svc$ + ^snmp-server\senable\straps\sether-oam """, re.VERBOSE, ), - "setval": "snmp-server enable traps pw vc", + "setval": "snmp-server enable traps ether-oam", "result": { "traps": { - "pw_vc": True, + "ether_oam": True, }, }, }, { - "name": "traps.mvpn", + "name": "traps.ethernet.cfm.alarm", "getval": re.compile( r""" - ^snmp-server\senable\straps\smvpn + ^snmp-server\senable\straps\sethernet\scfm\salarm """, re.VERBOSE, ), - "setval": "snmp-server enable traps mvpn", + "setval": "snmp-server enable traps ethernet cfm alarm", "result": { "traps": { - "mvpn": True, + "ethernet": { + "cfm": { + "alarm": True, + }, + }, }, }, }, { - "name": "traps.mpls_vpn", + "name": "traps.ethernet.cfm.cc", "getval": re.compile( r""" - ^snmp-server\senable\straps\smpls\svpn + ^snmp-server\senable\straps\sethernet\scfm\scc + (\s(?Pmep-up))? + (\s(?Pmep-down))? + (\s(?Pcross-connect))? + (\s(?Ploop))? + (\s(?Pconfig))? """, re.VERBOSE, ), - "setval": "snmp-server enable traps mpls vpn", + "setval": "snmp-server enable traps ethernet cfm cc" + "{{ ' mep-up' if traps.ethernet.cfm.cc.mep_up|d(False) else ''}}" + "{{ ' mep-down' if traps.ethernet.cfm.cc.mep_down|d(False) else ''}}" + "{{ ' cross-connect' if traps.ethernet.cfm.cc.cross_connect|d(False) else ''}}" + "{{ ' loop' if traps.ethernet.cfm.cc.loop|d(False) else ''}}" + "{{ ' config' if traps.ethernet.cfm.cc.config|d(False) else ''}}", "result": { "traps": { - "mpls_vpn": True, + "ethernet": { + "cfm": { + "cc": { + "mep_up": "{{ not not mep_up }}", + "mep_down": "{{ not not mep_down }}", + "cross_connect": "{{ not not cross_connect }}", + "loop": "{{ not not loop }}", + "config": "{{ not not config }}", + }, + }, + }, }, }, }, { - "name": "traps.pki", + "name": "traps.ethernet.cfm.crosscheck", "getval": re.compile( r""" - ^snmp-server\senable\straps\spki + ^snmp-server\senable\straps\sethernet\scfm\scrosscheck + (\s(?Pmep-missing))? + (\s(?Pmep-unknown))? + (\s(?Pservice-up))? """, re.VERBOSE, ), - "setval": "snmp-server enable traps pki", + "setval": "snmp-server enable traps ethernet cfm crosscheck" + "{{ ' mep-missing' if traps.ethernet.cfm.crosscheck.mep_missing|d(False) else ''}}" + "{{ ' mep-unknown' if traps.ethernet.cfm.crosscheck.mep_unknown|d(False) else ''}}" + "{{ ' service-up' if traps.ethernet.cfm.crosscheck.service_up|d(False) else ''}}", "result": { "traps": { - "pki": True, + "ethernet": { + "cfm": { + "crosscheck": { + "mep_missing": "{{ not not mep_missing }}", + "mep_unknown": "{{ not not mep_unknown }}", + "service_up": "{{ not not service_up }}", + }, + }, + }, }, }, }, { - "name": "traps.rsvp", + "name": "traps.ethernet.evc", "getval": re.compile( r""" - ^snmp-server\senable\straps\srsvp + ^snmp-server\senable\straps\sethernet\sevc + (\s(?Pstatus))? + (\s(?Pcreate))? + (\s(?Pdelete))? """, re.VERBOSE, ), - "setval": "snmp-server enable traps rsvp", + "setval": "snmp-server enable traps ethernet evc" + "{{ ' create' if traps.ethernet.evc.create|d(False) else ''}}" + "{{ ' delete' if traps.ethernet.evc.delete|d(False) else ''}}" + "{{ ' status' if traps.ethernet.evc.status|d(False) else ''}}", "result": { "traps": { - "rsvp": True, + "ethernet": { + "evc": { + "create": "{{ not not create }}", + "delete": "{{ not not delete }}", + "status": "{{ not not status }}", + }, + }, }, }, }, { - "name": "traps.syslog", + "name": "traps.event_manager", "getval": re.compile( r""" - ^snmp-server\senable\straps\ssyslog + ^snmp-server\senable\straps\sevent-manager """, re.VERBOSE, ), - "setval": "snmp-server enable traps syslog", + "setval": "snmp-server enable traps event-manager", "result": { "traps": { - "syslog": True, + "event_manager": True, }, }, }, { - "name": "traps.transceiver_all", + "name": "traps.flash", "getval": re.compile( r""" - ^snmp-server\senable\straps\stransceiver\sall + ^snmp-server\senable\straps\sflash + (\s(?Pinsertion))? + (\s(?Premoval))? + (\s(?Plowspace))? """, re.VERBOSE, ), - "setval": "snmp-server enable traps transceiver all", + "setval": "snmp-server enable traps flash" + "{{ ' insertion' if traps.flash.insertion|d(False) else '' }}" + "{{ ' removal' if traps.flash.removal|d(False) else '' }}" + "{{ ' lowspace' if traps.flash.lowspace|d(False) else '' }}", "result": { "traps": { - "transceiver_all": True, + "flash": { + "enable": True, + "insertion": "{{ not not insertion }}", + "removal": "{{ not not removal }}", + "lowspace": "{{ not not lowspace }}", + }, }, }, }, { - "name": "traps.tty", + "name": "traps.flex_links", "getval": re.compile( r""" - ^snmp-server\senable\straps\stty - """, re.VERBOSE, - ), - "setval": "snmp-server enable traps tty", - "result": { - "traps": { - "tty": True, - }, - }, - }, - { - "name": "traps.envmon.shutdown", - "getval": re.compile( - r""" - ^snmp-server\senable\straps\senvmon\sshutdown$ - """, re.VERBOSE, - ), - "setval": "snmp-server enable traps envmon shutdown", - "result": { - "traps": { - "envmon": { - "shutdown": True, - }, - }, - }, - }, - { - "name": "traps.envmon.status", - "getval": re.compile( - r""" - ^snmp-server\senable\straps\senvmon\sstatus$ - """, re.VERBOSE, - ), - "setval": "snmp-server enable traps envmon status", - "result": { - "traps": { - "envmon": { - "status": True, - }, - }, - }, - }, - { - "name": "traps.envmon.supply", - "getval": re.compile( - r""" - ^snmp-server\senable\straps\senvmon\ssupply$ - """, re.VERBOSE, - ), - "setval": "snmp-server enable traps envmon supply", - "result": { - "traps": { - "envmon": { - "supply": True, - }, - }, - }, - }, - { - "name": "traps.envmon.temperature", - "getval": re.compile( - r""" - ^snmp-server\senable\straps\senvmon\stemperature$ - """, re.VERBOSE, - ), - "setval": "snmp-server enable traps envmon temperature", - "result": { - "traps": { - "envmon": { - "temperature": True, - }, - }, - }, - }, - { - "name": "traps.envmon.fan.enable", - "getval": re.compile( - r""" - ^snmp-server\senable\straps\senvmon\sfan$ + ^snmp-server\senable\straps\sflex-links + (\s(?Pstatus))? """, re.VERBOSE, ), - "setval": "snmp-server enable traps envmon fan", + "setval": "snmp-server enable traps flex-links" + "{{ ' status' if traps.flex_links.status|d(False) else '' }}", "result": { "traps": { - "envmon": { - "fan": { - "enable": True, - }, + "flex_links": { + "enable": True, + "status": "{{ not not status }}", }, }, }, }, { - "name": "traps.envmon.fan.shutdown", + "name": "traps.firewall", "getval": re.compile( r""" - ^snmp-server\senable\straps\senvmon\sfan\sshutdown$ + ^snmp-server\senable\straps\sfirewall + (\s(?Pserverstatus))? """, re.VERBOSE, ), - "setval": "snmp-server enable traps envmon fan shutdown", + "setval": "snmp-server enable traps firewall" + "{{ ' serverstatus' if traps.firewall.serverstatus|d(False) else '' }}", "result": { "traps": { - "envmon": { - "fan": { - "shutdown": True, - }, + "firewall": { + "enable": True, + "serverstatus": "{{ not not serverstatus }}", }, }, }, }, { - "name": "traps.envmon.fan.status", + "name": "traps.flowmon", "getval": re.compile( r""" - ^snmp-server\senable\straps\senvmon\sfan\sstatus$ + ^snmp-server\senable\straps\sflowmon """, re.VERBOSE, ), - "setval": "snmp-server enable traps envmon fan status", + "setval": "snmp-server enable traps flowmon", "result": { "traps": { - "envmon": { - "fan": { - "status": True, - }, - }, + "flowmon": True, }, }, }, { - "name": "traps.envmon.fan.supply", + "name": "traps.frame_relay", "getval": re.compile( r""" - ^snmp-server\senable\straps\senvmon\sfan\ssupply$ + ^snmp-server\senable\straps\s(framerelay|frame-relay)$ """, re.VERBOSE, ), - "setval": "snmp-server enable traps envmon fan supply", + "setval": "snmp-server enable traps frame-relay", "result": { "traps": { - "envmon": { - "fan": { - "supply": True, - }, + "frame_relay": { + "enable": True, }, }, }, }, { - "name": "traps.envmon.fan.temperature", + "name": "traps.frame_relay.subif", "getval": re.compile( r""" - ^snmp-server\senable\straps\senvmon\sfan\stemperature$ + ^snmp-server\senable\straps\sframe-relay\ssubif + (\sinterval(?P\d+))? + (\scount(?P\d+))? """, re.VERBOSE, ), - "setval": "snmp-server enable traps envmon fan temperature", + "setval": "snmp-server enable traps frame-relay subif" + "{{ ' interval ' + interval|string if traps.frame_relay.subif.interval|d(False) else '' }}" + "{{ ' count ' + count|string if traps.frame_relay.subif.count|d(False) else '' }}", "result": { "traps": { - "envmon": { - "fan": { - "temperature": True, + "frame_relay": { + "subif": { + "enable": "{{ not not subif }}", + "interval": "{{ interval }}", + "count": "{{ count }}", }, }, }, }, }, { - "name": "traps.vrrp", + "name": "traps.fru_ctrl", "getval": re.compile( r""" - ^snmp-server\senable\straps\svrrp + ^snmp-server\senable\straps\sfru-ctrl """, re.VERBOSE, ), - "setval": "snmp-server enable traps vrrp", + "setval": "snmp-server enable traps fru-ctrl", "result": { "traps": { - "vrrp": True, + "fru_ctrl": True, }, }, }, { - "name": "traps.ipmulticast", + "name": "traps.hsrp", "getval": re.compile( r""" - ^snmp-server\senable\straps\sipmulticast + ^snmp-server\senable\straps\shsrp """, re.VERBOSE, ), - "setval": "snmp-server enable traps ipmulticast", + "setval": "snmp-server enable traps hsrp", "result": { "traps": { - "ipmulticast": True, + "hsrp": True, }, }, }, @@ -1293,6 +1429,20 @@ def __init__(self, lines=None, module=None): }, }, }, + { + "name": "traps.ipmulticast", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\sipmulticast + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps ipmulticast", + "result": { + "traps": { + "ipmulticast": True, + }, + }, + }, { "name": "traps.ipsec.cryptomap.add", "getval": re.compile( @@ -1312,36 +1462,36 @@ def __init__(self, lines=None, module=None): }, }, { - "name": "traps.ipsec.cryptomap.delete", + "name": "traps.ipsec.cryptomap.attach", "getval": re.compile( r""" - ^snmp-server\senable\straps\sipsec\scryptomap\sdelete + ^snmp-server\senable\straps\sipsec\scryptomap\sattach """, re.VERBOSE, ), - "setval": "snmp-server enable traps ipsec cryptomap delete", + "setval": "snmp-server enable traps ipsec cryptomap attach", "result": { "traps": { "ipsec": { "cryptomap": { - "delete": True, + "attach": True, }, }, }, }, }, { - "name": "traps.ipsec.cryptomap.attach", + "name": "traps.ipsec.cryptomap.delete", "getval": re.compile( r""" - ^snmp-server\senable\straps\sipsec\scryptomap\sattach + ^snmp-server\senable\straps\sipsec\scryptomap\sdelete """, re.VERBOSE, ), - "setval": "snmp-server enable traps ipsec cryptomap attach", + "setval": "snmp-server enable traps ipsec cryptomap delete", "result": { "traps": { "ipsec": { "cryptomap": { - "attach": True, + "delete": True, }, }, }, @@ -1365,6 +1515,22 @@ def __init__(self, lines=None, module=None): }, }, }, + { + "name": "traps.ipsec.too_many_sas", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\sipsec\stoo-many-sas + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps ipsec too-many-sas", + "result": { + "traps": { + "ipsec": { + "too_many_sas": True, + }, + }, + }, + }, { "name": "traps.ipsec.tunnel.start", "getval": re.compile( @@ -1402,552 +1568,1366 @@ def __init__(self, lines=None, module=None): }, }, { - "name": "traps.ipsec.too_many_sas", + "name": "traps.ipsla", "getval": re.compile( r""" - ^snmp-server\senable\straps\sipsec\stoo-many-sas + ^snmp-server\senable\straps\sipsla """, re.VERBOSE, ), - "setval": "snmp-server enable traps ipsec too-many-sas", + "setval": "snmp-server enable traps ipsla", "result": { "traps": { - "ipsec": { - "too_many_sas": True, - }, + "ipsla": True, }, }, }, { - "name": "traps.ospf.cisco_specific.error", + "name": "traps.isis", "getval": re.compile( r""" - ^snmp-server\senable\straps\sospf\scisco-specific\serrors + ^snmp-server\senable\straps\sisis$ """, re.VERBOSE, ), - "setval": "snmp-server enable traps ospf cisco-specific errors", + "setval": "snmp-server enable traps isis", "result": { "traps": { - "ospf": { - "cisco_specific": { - "error": True, - }, - }, + "isis": True, }, }, }, { - "name": "traps.ospf.cisco_specific.retransmit", + "name": "traps.l2tc", "getval": re.compile( r""" - ^snmp-server\senable\straps\sospf\scisco-specific\sretransmit + ^snmp-server\senable\straps\sl2tc + (\s(?Pthreshold))? + (\s(?Psys-threshold))? """, re.VERBOSE, ), - "setval": "snmp-server enable traps ospf cisco-specific retransmit", + "setval": "snmp-server enable traps l2tc" + "{{ ' threshold' if traps.l2tc.threshold|d(False) else '' }}" + "{{ ' sys-threshold' if traps.l2tc.sys_threshold|d(False) else '' }}", "result": { "traps": { - "ospf": { - "cisco_specific": { - "retransmit": True, - }, + "l2tc": { + "enable": True, + "sys_threshold": "{{ not not sys_threshold }}", + "threshold": "{{ not not threshold }}", }, }, }, }, { - "name": "traps.ospf.cisco_specific.lsa", + "name": "traps.l2tun.pseudowire_status", "getval": re.compile( r""" - ^snmp-server\senable\straps\sospf\scisco-specific\slsa + ^snmp-server\senable\straps\sl2tun\spseudowire\sstatus + (\s(?P))? """, re.VERBOSE, ), - "setval": "snmp-server enable traps ospf cisco-specific lsa", + "setval": "snmp-server enable traps l2tun pseudowire status", "result": { "traps": { - "ospf": { - "cisco_specific": { - "lsa": True, - }, + "l2tun": { + "pseudowire_status": True, }, }, }, }, { - "name": "traps.ospf.cisco_specific.state_change.nssa_trans_change", + "name": "traps.l2tun.session", "getval": re.compile( r""" - ^snmp-server\senable\straps\sospf\scisco-specific\sstate-change\snssa-trans-change + ^snmp-server\senable\straps\sl2tun\ssession """, re.VERBOSE, ), - "setval": "snmp-server enable traps ospf cisco-specific state-change nssa-trans-change", + "setval": "snmp-server enable traps l2tun session", "result": { "traps": { - "ospf": { - "cisco_specific": { - "state_change": { - "nssa_trans_change": True, - }, - }, + "l2tun": { + "session": True, }, }, }, }, { - "name": "traps.ospf.cisco_specific.state_change.shamlink.interface", + "name": "traps.license", "getval": re.compile( r""" - ^snmp-server\senable\straps\sospf\scisco-specific\sstate-change\sshamlink\sinterface + ^snmp-server\senable\straps\slicense """, re.VERBOSE, ), - "setval": "snmp-server enable traps ospf cisco-specific state-change shamlink interface", + "setval": "snmp-server enable traps license", "result": { "traps": { - "ospf": { - "cisco_specific": { - "state_change": { - "shamlink": { - "interface": True, - }, - }, - }, - }, + "license": True, }, }, }, { - "name": "traps.ospf.cisco_specific.state_change.shamlink.neighbor", + "name": "traps.lisp", "getval": re.compile( r""" - ^snmp-server\senable\straps\sospf\scisco-specific\sstate-change\sshamlink\sneighbor + ^snmp-server\senable\straps\slisp """, re.VERBOSE, ), - "setval": "snmp-server enable traps ospf cisco-specific state-change shamlink neighbor", + "setval": "snmp-server enable traps lisp", "result": { "traps": { - "ospf": { - "cisco_specific": { - "state_change": { - "shamlink": { - "neighbor": True, - }, - }, - }, - }, + "lisp": True, }, }, }, { - "name": "traps.ospf.error", + "name": "traps.local_auth", "getval": re.compile( r""" - ^snmp-server\senable\straps\sospf\serrors + ^snmp-server\senable\straps\slocal-auth """, re.VERBOSE, ), - "setval": "snmp-server enable traps ospf errors", + "setval": "snmp-server enable traps local-auth", "result": { "traps": { - "ospf": { - "error": True, - }, + "local_auth": True, }, }, }, { - "name": "traps.ospf.retransmit", + "name": "traps.mac_notification", "getval": re.compile( r""" - ^snmp-server\senable\straps\sospf\sretransmit + ^snmp-server\senable\straps\smac-notification + (\s(?Pchange))? + (\s(?Pmove))? + (\s(?Pthreshold))? """, re.VERBOSE, ), - "setval": "snmp-server enable traps ospf retransmit", + "setval": "snmp-server enable traps mac-notification" + "{{ ' change' if traps.mac_notification.change|d(False) else '' }}" + "{{ ' move' if traps.mac_notification.move|d(False) else '' }}" + "{{ ' threshold' if traps.mac_notification.threshold|d(False) else '' }}", "result": { "traps": { - "ospf": { - "retransmit": True, - }, + "mac_notification": { + "enable": True, + "change": "{{ not not change }}", + "move": "{{ not not move }}", + "threshold": "{{ not not threshold }}", + }, }, }, }, { - "name": "traps.ospf.lsa", + "name": "traps.memory", "getval": re.compile( r""" - ^snmp-server\senable\straps\sospf\slsa + ^snmp-server\senable\straps\smemory + (\s(?Pbufferpeak))? """, re.VERBOSE, ), - "setval": "snmp-server enable traps ospf lsa", + "setval": "snmp-server enable traps memory" + "{{ ' bufferpeak' if traps.memory.bufferpeak|d(False) else '' }}", "result": { "traps": { - "ospf": { - "lsa": True, + "memory": { + "enable": True, + "bufferpeak": "{{ not not bufferpeak }}", }, }, }, }, { - "name": "traps.ospf.state_change", + "name": "traps.mpls.fast_reroute", "getval": re.compile( r""" - ^snmp-server\senable\straps\sospf\sstate-change + ^snmp-server\senable\straps\smplssfast-reroute + (\s(?Pprotected))? """, re.VERBOSE, ), - "setval": "snmp-server enable traps ospf state-change", + "setval": "snmp-server enable traps mpls fast-reroute" + "{{ ' protected' if traps.mpls.fast_reroute.protected|d(False) else '' }}", "result": { "traps": { - "ospf": { - "state_change": True, + "mpls": { + "fast_reroute": { + "enable": True, + "protected": "{{ not not protected }}", + }, }, }, }, }, { - "name": "traps.l2tun.pseudowire_status", + "name": "traps.mpls.ldp", "getval": re.compile( r""" - ^snmp-server\senable\straps\sl2tun\spseudowire\sstatus - (\s(?P))? + ^snmp-server\senable\straps\smpls\sldp + (\s(?Ppv-limit))? + (\s(?Psession-down))? + (\s(?Psession-up))? + (\s(?Pthreshold))? """, re.VERBOSE, ), - "setval": "snmp-server enable traps l2tun pseudowire status", - "result": { + "setval": "snmp-server enable traps mpls ldp" + "{{ ' pv-limit' if traps.mpls.ldp.pv_limit|d(False) else '' }}" + "{{ ' session-down' if traps.mpls.ldp.session_down|d(False) else '' }}" + "{{ ' session-up' if traps.mpls.ldp.session_up|d(False) else '' }}" + "{{ ' threshold' if traps.mpls.ldp.threshold|d(False) else '' }}", + "result": { "traps": { - "l2tun": { - "pseudowire_status": True, + "mpls": { + "ldp": { + "enable": True, + "pv_limit": "{{ not not pv_limit }}", + "session_down": "{{ not not session_down }}", + "session_up": "{{ not not session_up }}", + "threshold": "{{ not not threshold }}", + }, }, }, }, }, { - "name": "traps.l2tun.session", + "name": "traps.mpls.rfc.ldp", "getval": re.compile( r""" - ^snmp-server\senable\straps\sl2tun\ssession + ^snmp-server\senable\straps\smpls\srfc\sldp + (\s(?Ppv-limit))? + (\s(?Psession-down))? + (\s(?Psession-up))? + (\s(?Pthreshold))? """, re.VERBOSE, ), - "setval": "snmp-server enable traps l2tun session", - "result": { - "traps": { - "l2tun": { - "session": True, + "setval": "snmp-server enable traps mpls rfc ldp" + "{{ ' pv-limit' if traps.mpls.rfc.ldp.pv_limit|d(False) else '' }}" + "{{ ' session-down' if traps.mpls.rfc.ldp.session_down|d(False) else '' }}" + "{{ ' session-up' if traps.mpls.rfc.ldp.session_up|d(False) else '' }}" + "{{ ' threshold' if traps.mpls.rfc.ldp.threshold|d(False) else '' }}", + "result": { + "traps": { + "mpls": { + "rfc": { + "ldp": { + "enable": True, + "pv_limit": "{{ not not pv_limit }}", + "session_down": "{{ not not session_down }}", + "session_up": "{{ not not session_up }}", + "threshold": "{{ not not threshold }}", + }, + }, }, }, }, }, { - "name": "traps.cpu", + "name": "traps.mpls.rfc.traffic_eng", "getval": re.compile( r""" - ^snmp-server\senable\straps\scpu - (\s(?Pthreshold))? + ^snmp-server\senable\straps\smpls\srfc\straffic-eng + (\s(?Pdown))? + (\s(?Preoptimized))? + (\s(?Preroute))? + (\s(?Pup))? """, re.VERBOSE, ), - "setval": "{{ 'snmp-server enable traps cpu' if traps.cpu.enable is defined else '' }}" - "{{ ' threshold' if traps.cpu.threshold is defined else '' }}", - "result": { + "setval": "snmp-server enable traps mpls rfc traffic-eng" + "{{ ' down' traps.mpls.rfc.traffic_eng.down|d(False) else '' }}" + "{{ ' reoptimized' traps.mpls.rfc.traffic_eng.reoptimized|d(False) else '' }}" + "{{ ' reroute' traps.mpls.rfc.traffic_eng.reroute|d(False) else '' }}" + "{{ ' up' traps.mpls.rfc.traffic_eng.up|d(False) else '' }}", + "result": { "traps": { - "cpu": { - "enable": True, - "threshold": "{{ not not threshold }}", + "mpls": { + "rfc": { + "traffic_eng": { + "enable": True, + "down": "{{ not not down }}", + "reoptimized": "{{ not not reoptimized }}", + "reroute": "{{ not not reroute }}", + "up": "{{ not not up }}", + }, + }, }, }, }, }, { - "name": "traps.firewall", + "name": "traps.mpls.rfc.vpn", "getval": re.compile( r""" - ^snmp-server\senable\straps\sfirewall - (\s(?Pserverstatus))? + ^snmp-server\senable\straps\smpls\srfc\svpn + (\s(?Pillegal-label))? + (\s(?Pmax-thresh-cleared))? + (\s(?Pmax-threshold))? + (\s(?Pmid-threshold))? + (\s(?Pvrf-down))? + (\s(?Pvrf-up))? """, re.VERBOSE, ), - "setval": "{{ 'snmp-server enable traps firewall' if traps.firewall.enable is defined else '' }}" - "{{ ' serverstatus' if traps.firewall.serverstatus|d(False) else ''}}", - "result": { - "traps": { - "firewall": { - "enable": True, - "serverstatus": "{{ not not serverstatus }}", + "setval": "snmp-server enable traps mpls rfc vpn" + "{{ ' illegal-label' if traps.mpls.rfc.vpn.illegal_label|d(False) else '' }}" + "{{ ' max-thresh-cleared' if traps.mpls.rfc.vpn.max_thresh_cleared|d(False) else '' }}" + "{{ ' max-threshold' if traps.mpls.rfc.vpn.max_threshold|d(False) else '' }}" + "{{ ' mid-threshold' if traps.mpls.rfc.vpn.mid_threshold|d(False) else '' }}" + "{{ ' vrf-down' if traps.mpls.rfc.vpn.vrf_down|d(False) else '' }}" + "{{ ' vrf-up' if traps.mpls.rfc.vpn.vrf_up|d(False) else '' }}", + "result": { + "traps": { + "mpls": { + "rfc": { + "vpn": { + "enable": True, + "illegal_label": "{{ not not illegal_label }}", + "max_thresh_cleared": "{{ not not max_thresh_cleared }}", + "max_threshold": "{{ not not max_threshold }}", + "mid_threshold": "{{ not not mid_threshold }}", + "vrf_down": "{{ not not vrf_down }}", + "vrf_up": "{{ not not vrf_up }}", + }, + }, }, }, }, }, { - "name": "traps.pim", + "name": "traps.mpls.traffic_eng", "getval": re.compile( r""" - ^snmp-server\senable\straps\spim - (\s(?Pneighbor-change))? - (\s(?Prp-mapping-change))? - (\s(?Pinvalid-pim-message))? + ^snmp-server\senable\straps\smpls\straffic-eng + (\s(?Pdown))? + (\s(?Preroute))? + (\s(?Pup))? """, re.VERBOSE, ), - "setval": "{{ 'snmp-server enable traps pim' if traps.pim.enable is defined else '' }}" - "{{ ' neighbor-change' if traps.pim.neighbor_change|d(False) else ''}}" - "{{ ' rp-mapping-change' if traps.pim.rp_mapping_change|d(False) else ''}}" - "{{ ' invalid-pim-message' if traps.pim.invalid_pim_message|d(False) else ''}}", + "setval": "snmp-server enable traps mpls traffic-eng" + "{{ ' down' if traps.mpls.traffic_eng.down|d(False) else '' }}" + "{{ ' reroute' if traps.mpls.traffic_eng.reroute|d(False) else '' }}" + "{{ ' up' if traps.mpls.traffic_eng.up|d(False) else '' }}", "result": { "traps": { - "pim": { - "enable": True, - "neighbor_change": "{{ not not neighbor_change }}", - "rp_mapping_change": "{{ not not rp_mapping_change }}", - "invalid_pim_message": "{{ not not invalid_pim_message }}", + "mpls": { + "traffic_eng": { + "enable": True, + "down": "{{ not not down }}", + "reroute": "{{ not not reroute }}", + "up": "{{ not not up }}", + }, }, }, }, }, { - "name": "traps.vrfmib", + "name": "traps.mpls.vpn", "getval": re.compile( r""" - ^snmp-server\senable\straps\svrfmib - (\s(?Pvrf-up))? + ^snmp-server\senable\straps\smpls(-|\s)vpn + (\s(?Pillegal-label))? + (\s(?Pmax-thresh-cleared))? + (\s(?Pmax-threshold))? + (\s(?Pmid-threshold))? (\s(?Pvrf-down))? - (\s(?Pvnet-trunk-up))? - (\s(?Pvnet-trunk-down))? + (\s(?Pvrf-up))? """, re.VERBOSE, ), - "setval": "snmp-server enable traps vrfmib" - "{{ ' vrf-up' if traps.vrfmib.vrf_up|d(False) else ''}}" - "{{ ' vrf-down' if traps.vrfmib.vrf_down|d(False) else ''}}" - "{{ ' vnet-trunk-up' if traps.vrfmib.vnet_trunk_up|d(False) else ''}}" - "{{ ' vnet-trunk-down' if traps.vrfmib.vnet_trunk_down|d(False) else ''}}", + "setval": "snmp-server enable traps mpls vpn" + "{{ ' illegal-label' if traps.mpls.vpn.illegal_label|d(False) else '' }}" + "{{ ' max-thresh-cleared' if traps.mpls.vpn.max_thresh_cleared|d(False) else '' }}" + "{{ ' max-threshold' if traps.mpls.vpn.max_threshold|d(False) else '' }}" + "{{ ' mid-threshold' if traps.mpls.vpn.mid_threshold|d(False) else '' }}" + "{{ ' vrf-down' if traps.mpls.vpn.vrf_down|d(False) else '' }}" + "{{ ' vrf-up' if traps.mpls.vpn.vrf_up|d(False) else '' }}", "result": { "traps": { - "vrfmib": { - "vrf_up": "{{ not not vrf_up }}", - "vrf_down": "{{ not not vrf_down }}", - "vnet_trunk_up": "{{ not not vnet_trunk_up }}", - "vnet_trunk_down": "{{ not not vnet_trunk_down }}", + "mpls": { + "vpn": { + "enable": True, + "illegal_label": "{{ not not illegal_label }}", + "max_thresh_cleared": "{{ not not max_thresh_cleared }}", + "max_threshold": "{{ not not max_threshold }}", + "mid_threshold": "{{ not not mid_threshold }}", + "vrf_down": "{{ not not vrf_down }}", + "vrf_up": "{{ not not vrf_up }}", + }, }, }, }, }, { - "name": "traps.snmp", + "name": "traps.msdp", "getval": re.compile( r""" - ^snmp-server\senable\straps\ssnmp - (\s(?Pauthentication))? - (\s(?Plinkdown))? - (\s(?Plinkup))? - (\s(?Pcoldstart))? - (\s(?Pwarmstart))? + ^snmp-server\senable\straps\smsdp$ """, re.VERBOSE, ), - "setval": "snmp-server enable traps snmp" - "{{ ' authentication' if traps.snmp.authentication is defined else '' }}" - "{{ ' linkdown' if traps.snmp.linkdown|d(False) else ''}}" - "{{ ' linkup' if traps.snmp.linkup|d(False) else ''}}" - "{{ ' warmstart' if traps.snmp.warmstart|d(False) else ''}}" - "{{ ' coldstart' if traps.snmp.coldstart|d(False) else ''}}", + "setval": "snmp-server enable traps msdp", "result": { "traps": { - "snmp": { - "authentication": "{{ not not authentication }}", - "linkdown": "{{ not not linkdown }}", - "linkup": "{{ not not linkup }}", - "coldstart": "{{ not not coldstart }}", - "warmstart": "{{ not not warmstart }}", - }, + "msdp": True, }, }, }, { - "name": "traps.frame_relay", + "name": "traps.mvpn", "getval": re.compile( r""" - ^snmp-server\senable\straps\sframe-relay$ + ^snmp-server\senable\straps\smvpn """, re.VERBOSE, ), - "setval": "snmp-server enable traps frame-relay", + "setval": "snmp-server enable traps mvpn", "result": { "traps": { - "frame_relay": { + "mvpn": True, + }, + }, + }, + { + "name": "traps.nhrp.nhc", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\snhrp\snhc + (\s(?Pdown))? + (\s(?Pup))? + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps nhrp nhc" + "{{ ' down' if traps.nhrp.nhc.down|d(False) else '' }}" + "{{ ' up' if traps.nhrp.nhc.up|d(False) else '' }}", + "result": { + "traps": { + "nhrp": { "enable": True, + "nhc": { + "enable": True, + "down": "{{ not not down }}", + "up": "{{ not not up }}", + }, }, }, }, }, { - "name": "traps.frame_relay.subif", + "name": "traps.nhrp.nhp", "getval": re.compile( r""" - ^snmp-server\senable\straps\sframe-relay\ssubif - (\scount(?P\d+))? - (\sinterval(?P\d+))? + ^snmp-server\senable\straps\snhrp\snhp + (\s(?Pdown))? + (\s(?Pup))? """, re.VERBOSE, ), - "setval": "snmp-server enable traps frame-relay subif" - "{{ (' count ' + count|string) if traps.frame_relay.count else '' }}" - "{{ (' interval ' + interval|string) if traps.frame_relay.interval else '' }}", + "setval": "snmp-server enable traps nhrp nhp" + "{{ ' down' if traps.nhrp.nhc.down|d(False) else '' }}" + "{{ ' up' if traps.nhrp.nhc.up|d(False) else '' }}", "result": { "traps": { - "frame_relay": { - "subif": { - "enable": "{{ not not subif }}", - "interval": "{{ interval }}", - "count": "{{ count }}", + "nhrp": { + "enable": True, + "nhp": { + "enable": True, + "down": "{{ not not down }}", + "up": "{{ not not up }}", }, }, }, }, }, { - "name": "traps.cef", + "name": "traps.nhrp.nhs", "getval": re.compile( r""" - ^snmp-server\senable\straps\scef - (\s(?Presource-failure))? - (\s(?Ppeer-state-change))? - (\s(?Ppeer-fib-state-change))? - (\s(?Pinconsistency))? + ^snmp-server\senable\straps\snhrp\snhs + (\s(?Pdown))? + (\s(?Pup))? """, re.VERBOSE, ), - "setval": "{{ 'snmp-server enable traps cef' if traps.cef.enable is defined else '' }}" - "{{ ' resource-failure' if traps.cef.resource_failure|d(False) else ''}}" - "{{ ' peer-state-change' if traps.cef.peer_state_change|d(False) else ''}}" - "{{ ' peer-fib-state-change' if traps.cef.peer_fib_state_change|d(False) else ''}}" - "{{ ' inconsistency' if traps.cef.inconsistency|d(False) else ''}}", + "setval": "snmp-server enable traps nhrp nhs" + "{{ ' down' if traps.nhrp.nhc.down|d(False) else '' }}" + "{{ ' up' if traps.nhrp.nhc.up|d(False) else '' }}", "result": { "traps": { - "cef": { + "nhrp": { "enable": True, - "inconsistency": "{{ not not inconsistency }}", - "peer_fib_state_change": "{{ not not peer_fib_state_change }}", - "peer_state_change": "{{ not not peer_state_change }}", - "resource_failure": "{{ not not resource_failure }}", + "nhs": { + "enable": True, + "down": "{{ not not down }}", + "up": "{{ not not up }}", + }, }, }, }, }, { - "name": "traps.dlsw", + "name": "traps.nhrp.quota_exceeded", "getval": re.compile( r""" - ^snmp-server\senable\straps\sdlsw - (\s(?Pcircuit))? - (\s(?Ptconn))? + ^snmp-server\senable\straps\snhrp + (\s(?Pquota-exceeded))?$ """, re.VERBOSE, ), - "setval": "{{ 'snmp-server enable traps dlsw' if traps.dlsw.enable is defined else '' }}" - "{{ ' circuit' if traps.dlsw.circuit|d(False) else ''}}" - "{{ ' tconn' if traps.dlsw.tconn|d(False) else ''}}", + "setval": "snmp-server enable traps nhrp" + "{{ ' quota-exceeded' if traps.nhrp.nhc.quota_exceeded|d(False) else '' }}", "result": { "traps": { - "dlsw": { + "nhrp": { "enable": True, - "circuit": "{{ not not circuit }}", - "tconn": "{{ not not tconn }}", + "quota_exceeded": "{{ not not quota_exceeded }}", }, }, }, }, { - "name": "traps.ethernet.evc", + "name": "traps.ospf.cisco_specific.error", "getval": re.compile( r""" - ^snmp-server\senable\straps\sethernet\sevc - (\s(?Pstatus))? - (\s(?Pcreate))? - (\s(?Pdelete))? + ^snmp-server\senable\straps\sospf\scisco-specific\serrors """, re.VERBOSE, ), - "setval": "snmp-server enable traps ethernet evc" - "{{ ' create' if traps.ethernet.evc.create|d(False) else ''}}" - "{{ ' delete' if traps.ethernet.evc.delete|d(False) else ''}}" - "{{ ' status' if traps.ethernet.evc.status|d(False) else ''}}", + "setval": "snmp-server enable traps ospf cisco-specific errors", "result": { "traps": { - "ethernet": { - "evc": { - "create": "{{ not not create }}", - "delete": "{{ not not delete }}", - "status": "{{ not not status }}", + "ospf": { + "cisco_specific": { + "error": True, }, }, }, }, }, { - "name": "traps.ethernet.cfm.cc", + "name": "traps.ospf.cisco_specific.lsa", "getval": re.compile( r""" - ^snmp-server\senable\straps\sethernet\scfm\scc - (\s(?Pmep-up))? - (\s(?Pmep-down))? - (\s(?Pcross-connect))? - (\s(?Ploop))? - (\s(?Pconfig))? + ^snmp-server\senable\straps\sospf\scisco-specific\slsa """, re.VERBOSE, ), - "setval": "snmp-server enable traps ethernet cfm cc" - "{{ ' mep-up' if traps.ethernet.cfm.cc.mep_up|d(False) else ''}}" - "{{ ' mep-down' if traps.ethernet.cfm.cc.mep_down|d(False) else ''}}" - "{{ ' cross-connect' if traps.ethernet.cfm.cc.cross_connect|d(False) else ''}}" - "{{ ' loop' if traps.ethernet.cfm.cc.loop|d(False) else ''}}" - "{{ ' config' if traps.ethernet.cfm.cc.config|d(False) else ''}}", + "setval": "snmp-server enable traps ospf cisco-specific lsa", "result": { "traps": { - "ethernet": { - "cfm": { - "cc": { - "mep_up": "{{ not not mep_up }}", - "mep_down": "{{ not not mep_down }}", - "cross_connect": "{{ not not cross_connect }}", - "loop": "{{ not not loop }}", - "config": "{{ not not config }}", - }, + "ospf": { + "cisco_specific": { + "lsa": True, }, }, }, }, }, { - "name": "traps.ethernet.cfm.crosscheck", + "name": "traps.ospf.cisco_specific.retransmit", "getval": re.compile( r""" - ^snmp-server\senable\straps\sethernet\scfm\scrosscheck - (\s(?Pmep-missing))? - (\s(?Pmep-unknown))? - (\s(?Pservice-up))? + ^snmp-server\senable\straps\sospf\scisco-specific\sretransmit """, re.VERBOSE, ), - "setval": "snmp-server enable traps ethernet cfm crosscheck" - "{{ ' mep-missing' if traps.ethernet.cfm.crosscheck.mep_missing|d(False) else ''}}" - "{{ ' mep-unknown' if traps.ethernet.cfm.crosscheck.mep_unknown|d(False) else ''}}" - "{{ ' service-up' if traps.ethernet.cfm.crosscheck.service_up|d(False) else ''}}", + "setval": "snmp-server enable traps ospf cisco-specific retransmit", "result": { "traps": { - "ethernet": { - "cfm": { - "crosscheck": { - "mep_missing": "{{ not not mep_missing }}", - "mep_unknown": "{{ not not mep_unknown }}", - "service_up": "{{ not not service_up }}", - }, + "ospf": { + "cisco_specific": { + "retransmit": True, }, }, }, }, }, { - "name": "traps.ethernet.cfm.alarm", + "name": "traps.ospf.cisco_specific.state_change.nssa_trans_change", "getval": re.compile( r""" - ^snmp-server\senable\straps\sethernet\scfm\salarm + ^snmp-server\senable\straps\sospf\scisco-specific\sstate-change\snssa-trans-change """, re.VERBOSE, ), - "setval": "snmp-server enable traps ethernet cfm alarm", + "setval": "snmp-server enable traps ospf cisco-specific state-change nssa-trans-change", "result": { "traps": { - "ethernet": { - "cfm": { - "alarm": True, + "ospf": { + "cisco_specific": { + "state_change": { + "nssa_trans_change": True, + }, }, }, }, }, }, + { + "name": "traps.ospf.cisco_specific.state_change.shamlink.interface", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\sospf\scisco-specific\sstate-change\sshamlink\sinterface + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps ospf cisco-specific state-change shamlink interface", + "result": { + "traps": { + "ospf": { + "cisco_specific": { + "state_change": { + "shamlink": { + "interface": True, + }, + }, + }, + }, + }, + }, + }, + { + "name": "traps.ospf.cisco_specific.state_change.shamlink.neighbor", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\sospf\scisco-specific\sstate-change\sshamlink\sneighbor + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps ospf cisco-specific state-change shamlink neighbor", + "result": { + "traps": { + "ospf": { + "cisco_specific": { + "state_change": { + "shamlink": { + "neighbor": True, + }, + }, + }, + }, + }, + }, + }, + { + "name": "traps.ospf.error", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\sospf\serrors + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps ospf errors", + "result": { + "traps": { + "ospf": { + "error": True, + }, + }, + }, + }, + { + "name": "traps.ospf.lsa", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\sospf\slsa + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps ospf lsa", + "result": { + "traps": { + "ospf": { + "lsa": True, + }, + }, + }, + }, + { + "name": "traps.ospf.retransmit", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\sospf\sretransmit + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps ospf retransmit", + "result": { + "traps": { + "ospf": { + "retransmit": True, + }, + }, + }, + }, + { + "name": "traps.ospf.state_change", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\sospf\sstate-change + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps ospf state-change", + "result": { + "traps": { + "ospf": { + "state_change": True, + }, + }, + }, + }, + { + "name": "traps.ospfv3.errors", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\sospfv3\serrors + (\s(?Pbad-packet))? + (\s(?Pconfig-error))? + (\s(?Pvirt-bad-packet))? + (\s(?Pvirt-config-error))? + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps ospfv3 errors" + "{{ ' bad-packet' if traps.ospfv3.errors.bad_packet|d(False) else '' }}" + "{{ ' config-error' if traps.ospfv3.errors.config_error|d(False) else '' }}" + "{{ ' virt-bad-packet' if traps.ospfv3.errors.virt_bad_packet|d(False) else '' }}" + "{{ ' virt-config-error' if traps.ospfv3.errors.virt_config_error|d(False) else '' }}", + "result": { + "traps": { + "ospfv3": { + "errors": { + "enable": True, + "bad_packet": "{{ not not bad_packet }}", + "config_error": "{{ not not config_error }}", + "virt_bad_packet": "{{ not not virt_bad_packet }}", + "virt_config_error": "{{ not not virt_config_error }}", + }, + }, + }, + }, + }, + { + "name": "traps.ospfv3.rate_limit", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\sospfv3\srate-limit + (\s(?P[0-9]+))? + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps ospfv3 rate_limit" + "{{ traps.ospfv3.rate_limit|int if traps.ospfv3.rate_limit|int > 0 else '' }}", + "result": { + "traps": { + "ospfv3": { + "rate_limit": "{{ rate_limit if rate_limit|int >=2 or rate_limit|int <= 60 }}", + }, + }, + }, + }, + { + "name": "traps.ospfv3.state_change", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\sospfv3\sstate-change + (\s(?Pif-state-change))? + (\s(?Pneighbor-restart-helper-status-change))? + (\s(?Pneighbor-state-change))? + (\s(?Pnssa-translator-status-change))? + (\s(?Prestart-status-change))? + (\s(?Pvirtif-state-change))? + (\s(?Pvirtneighbor-restart-helper-status-change))? + (\s(?Pvirtneighbor-state-change))? + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps ospfv3 state-change" + "{{ ' if-state-change' if traps.ospfv3.state_change.if_state_change|d(False) else '' }}" + "{{ ' neighbor-restart-helper-status-change' if traps.ospfv3.state_change.neighbor_restart_helper_status_change|d(False) else '' }}" + "{{ ' neighbor-state-change' if traps.ospfv3.state_change.neighbor_state_change|d(False) else '' }}" + "{{ ' nssa-translator-status-change' if traps.ospfv3.state_change.nssa_translator_status_change|d(False) else '' }}" + "{{ ' restart-status-change' if traps.ospfv3.state_change.restart_status_change|d(False) else '' }}" + "{{ ' virtif-state-change' if traps.ospfv3.state_change.virtif_state_change|d(False) else '' }}" + "{{ ' virtneighbor-restart-helper-status-change' if traps.ospfv3.state_change.virtneighbor_restart_helper_status_change|d(False) else '' }}" + "{{ ' virtneighbor-state-change' if traps.ospfv3.state_change.virtneighbor_state_change|d(False) else '' }}", + "result": { + "traps": { + "ospfv3": { + "state_change": { + "enable": True, + "if_state_change": "{{ not not if_state_change }}", + "neighbor_restart_helper_status_change": "{{ not not neighbor_restart_helper_status_change }}", + "neighbor_state_change": "{{ not not neighbor_state_change }}", + "nssa_translator_status_change": "{{ not not nssa_translator_status_change }}", + "restart_status_change": "{{ not not restart_status_change }}", + "virtif_state_change": "{{ not not virtif_state_change }}", + "virtneighbor_state_change": "{{ not not virtneighbor_state_change }}", + }, + }, + }, + } + }, + { + "name": "traps.pim", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\spim + (\s(?Pneighbor-change))? + (\s(?Prp-mapping-change))? + (\s(?Pinvalid-pim-message))? + """, re.VERBOSE, + ), + "setval": "{{ 'snmp-server enable traps pim' if traps.pim.enable is defined else '' }}" + "{{ ' neighbor-change' if traps.pim.neighbor_change|d(False) else ''}}" + "{{ ' rp-mapping-change' if traps.pim.rp_mapping_change|d(False) else ''}}" + "{{ ' invalid-pim-message' if traps.pim.invalid_pim_message|d(False) else ''}}", + "result": { + "traps": { + "pim": { + "enable": True, + "neighbor_change": "{{ not not neighbor_change }}", + "rp_mapping_change": "{{ not not rp_mapping_change }}", + "invalid_pim_message": "{{ not not invalid_pim_message }}", + }, + }, + }, + }, + { + "name": "traps.pki", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\spki + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps pki", + "result": { + "traps": { + "pki": True, + }, + }, + }, + { + "name": "traps.port_security", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\sport-security + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps port-security", + "result": { + "traps": { + "port_security": True, + }, + }, + }, + { + "name": "traps.power_ethernet", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\spower-ethernet + (\s(?Ppolice))?$ + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps power-ethernet" + "{{ ' police' if traps.power_ethernet.police|d(False) else '' }}", + "result": { + "traps": { + "power_ethernet": { + "enable": True, + "police": "{{ not not police }}", + }, + }, + }, + }, + { + "name": "traps.power_ethernet.group", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\spower-ethernet\sgroup + (\s(?P[0-9]+))? + (\sthreshold\s(?P[0-9]+))? + """, re.VERBOSE, + ), + "remval": "snmp-server enable traps power-ethernet", + "setval": "snmp-server enable traps power-ethernet" + "{% if slot_id and threshold %}" + "{{ ' group ' + slot_id + ' threshold ' + threshold }}" + "{% endif %}", + "result": { + "traps": { + "power_ethernet": { + "enable": True, + "group": [ + { + "slot_id": "{{ slot_id if slot_id|int >= 1 and slot_id|int <= 9 }}", + "threshold": "{{ threshold if threshold|int >= 1 and threshold|int <= 99 }}", + }, + ], + }, + }, + }, + }, + { + "name": "traps.pw_vc", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\spw\svc$ + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps pw vc", + "result": { + "traps": { + "pw_vc": True, + }, + }, + }, + { + "name": "traps.rep", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\srep + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps rep", + "result": { + "traps": { + "rep": True, + }, + }, + }, + { + "name": "traps.rsvp", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\srsvp + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps rsvp", + "result": { + "traps": { + "rsvp": True, + }, + }, + }, + { + "name": "traps.rf", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\srf + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps rf", + "result": { + "traps": { + "rf": True, + }, + }, + }, + { + "name": "traps.smart_license", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\ssmart-license + (\s(?Pentitlement))? + (\s(?Pglobal))? + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps smart-license" + "{{ ' entitlement' if traps.smart_license.entitlement|d(False) else '' }}" + "{{ ' global' if traps.smart_license.global|d(False) else '' }}", + "result": { + "traps": { + "smart_license": { + "enable": True, + "entitlement": "{{ not not entitlement }}", + "global": "{{ not not global }}", + }, + }, + }, + }, + { + "name": "traps.snmp", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\ssnmp + (\s(?Pauthentication))? + (\s(?Plinkdown))? + (\s(?Plinkup))? + (\s(?Pcoldstart))? + (\s(?Pwarmstart))? + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps snmp" + "{{ ' authentication' if traps.snmp.authentication is defined else '' }}" + "{{ ' linkdown' if traps.snmp.linkdown|d(False) else ''}}" + "{{ ' linkup' if traps.snmp.linkup|d(False) else ''}}" + "{{ ' coldstart' if traps.snmp.coldstart|d(False) else ''}}" + "{{ ' warmstart' if traps.snmp.warmstart|d(False) else ''}}", + "result": { + "traps": { + "snmp": { + "authentication": "{{ not not authentication }}", + "linkdown": "{{ not not linkdown }}", + "linkup": "{{ not not linkup }}", + "coldstart": "{{ not not coldstart }}", + "warmstart": "{{ not not warmstart }}", + }, + }, + }, + }, + { + "name": "traps.stackwise", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\sstackwise + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps stackwise", + "result": { + "traps": { + "stackwise": True, + }, + }, + }, + { + "name": "traps.stpx", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\sstpx + (\s(?Pinconsistency))? + (\s(?Proot-inconsistency))? + (\s(?Ploop-inconsistency))? + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps stpx" + "{{ ' inconsistency' if traps.stpx.inconsistency|d(False) else '' }}" + "{{ ' root-inconsistency' if traps.stpx.root_inconsistency|d(False) else '' }}" + "{{ ' loop-inconsistency' if traps.stpx.loop_inconsistency|d(False) else '' }}", + "result": { + "traps": { + "stpx": { + "enable": True, + "inconsistency": "{{ not not inconsistency }}", + "loop_inconsistency": "{{ not not loop_inconsistency }}", + "root_inconsistency": "{{ not not root_inconsistency }}", + }, + }, + }, + }, + { + "name": "traps.syslog", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\ssyslog + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps syslog", + "result": { + "traps": { + "syslog": True, + }, + }, + }, + { + "name": "traps.transceiver_all", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\stransceiver\sall + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps transceiver all", + "result": { + "traps": { + "transceiver_all": True, + }, + }, + }, + { + "name": "traps.trustsec", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\strustsec + (?!\S) + (\s(?Pauthz-file-error))? + (\s(?Pcache-file-error))? + (\s(?Pkeystore-file-error))? + (\s(?Pkeystore-sync-fail))? + (\s(?Prandom-number-fail))? + (\s(?Psrc-entropy-fail))? + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps trustsec" + "{{ ' authz-file-error' if traps.trustsec.authz_file_error|d(False) else '' }}" + "{{ ' cache-file-error' if traps.trustsec.cache_file_error|d(False) else '' }}" + "{{ ' keystore-file-error' if traps.trustsec.keystore_file_error|d(False) else '' }}" + "{{ ' keystore-sync-fail' if traps.trustsec.keystore_sync_fail|d(False) else '' }}" + "{{ ' random-number-fail' if traps.trustsec.random_number_fail|d(False) else '' }}" + "{{ ' src-entropy-fail' if traps.trustsec.src_entropy_fail|d(False) else '' }}", + "result": { + "traps": { + "trustsec": { + "enable": True, + "authz_file_error": "{{ not not authz_file_error }}", + "cache_file_error": "{{ not not cache_file_error }}", + "keystore_file_error": "{{ not not keystore_file_error }}", + "keystore_sync_fail": "{{ not not keystore_sync_fail }}", + "random_number_fail": "{{ not not random_number_fail }}", + "src_entropy_fail": "{{ not not src_entropy_fail }}", + }, + } + }, + }, + { + "name": "traps.trustsec_interface", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\strustsec-interface + (\s(?Punauthorized))? + (\s(?Psap-fail))? + (\s(?Pauthc-fail))? + (\s(?Psupplicant-fail))? + (\s(?Pauthz-fail))? + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps trustsec-interface" + "{{ ' unauthorized' if traps.trustsec_interface.unauthorized|d(False) else '' }}" + "{{ ' sap-fail' if traps.trustsec_interface.sap_fail|d(False) else '' }}" + "{{ ' authc-fail' if traps.trustsec_interface.authc_fail|d(False) else '' }}" + "{{ ' supplicant-fail' if traps.trustsec_interface.supplicant_fail|d(False) else '' }}" + "{{ ' authz-fail' if traps.trustsec_interface.authz_fail|d(False) else '' }}", + "result": { + "traps": { + "trustsec_interface": { + "enable": True, + "unauthorized": "{{ not not unauthorized }}", + "sap_fail": "{{ not not sap_fail }}", + "authc_fail": "{{ not not authc_fail }}", + "supplicant_fail": "{{ not not supplicant_fail }}", + "authz_fail": "{{ not not authz_fail }}", + }, + } + }, + }, + { + "name": "traps.trustsec_policy", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\strustsec-policy + (\s(?Ppeer-policy-updated))? + (\s(?Pauthz-sgacl-fail))? + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps trustsec-policy" + "{{ ' peer-policy-updated' if traps.trustsec_policy.peer_policy_updated|d(False) else '' }}" + "{{ ' authz-sgacl-fail' if traps.trustsec_policy.authz_sgacl_fail|d(False) else '' }}", + "result": { + "traps": { + "trustsec_policy": { + "enable": True, + "peer_policy_updated": "{{ not not peer_policy_updated }}", + "authz_sgacl_fail": "{{ not not authz_sgacl_fail }}", + }, + } + }, + }, + { + "name": "traps.trustsec_server", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\strustsec-server + (\s(?Pradius-server))? + (\s(?Pprovision-secret))? + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps trustsec-server" + "{{ ' radius-server' if traps.trustsec_server.radius_server|d(False) else '' }}" + "{{ ' provision-secret' if traps.trustsec_server.provision_secret|d(False) else '' }}", + "result": { + "traps": { + "trustsec_server": { + "enable": True, + "radius_server": "{{ not not radius_server }}", + "provision_secret": "{{ not not provision_secret }}", + }, + } + }, + }, + { + "name": "traps.trustsec_sxp", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\strustsec-sxp + (\s(?Pconn-srcaddr-err))? + (\s(?Pmsg-parse-err))? + (\s(?Pconn-config-err))? + (\s(?Pbinding-err))? + (\s(?Pconn-up))? + (\s(?Pconn-down))? + (\s(?Pbinding-expn-fail))? + (\s(?Poper-nodeid-change))? + (\s(?Pbinding-conflict))? + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps trustsec-sxp" + "{{ ' conn-srcaddr-err' if traps.trustsec_sxp.conn_srcaddr_err|d(False) else '' }}" + "{{ ' msg-parse-err' if traps.trustsec_sxp.msg_parse_err|d(False) else '' }}" + "{{ ' conn-config-err' if traps.trustsec_sxp.conn_config_err|d(False) else '' }}" + "{{ ' binding-err' if traps.trustsec_sxp.binding_err|d(False) else '' }}" + "{{ ' conn-up' if traps.trustsec_sxp.conn_up|d(False) else '' }}" + "{{ ' conn-down' if traps.trustsec_sxp.conn_down|d(False) else '' }}" + "{{ ' binding-expn-fail' if traps.trustsec_sxp.binding_expn_fail|d(False) else '' }}" + "{{ ' oper-nodeid-change' if traps.trustsec_sxp.oper_nodeid_change|d(False) else '' }}" + "{{ ' binding-conflict' if traps.trustsec_sxp.binding_conflict|d(False) else '' }}", + "result": { + "traps": { + "trustsec_sxp": { + "enable": True, + "conn_srcaddr_err": "{{ not not conn_srcaddr_err }}", + "msg_parse_err": "{{ not not msg_parse_err }}", + "conn_config_err": "{{ not not conn_config_err }}", + "binding_err": "{{ not not binding_err }}", + "conn_up": "{{ not not conn_up }}", + "conn_down": "{{ not not conn_down }}", + "binding_expn_fail": "{{ not not binding_expn_fail }}", + "oper_nodeid_change": "{{ not not oper_nodeid_change }}", + "binding_conflict": "{{ not not binding_conflict }}", + }, + } + }, + }, + { + "name": "traps.tty", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\stty + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps tty", + "result": { + "traps": { + "tty": True, + }, + }, + }, + { + "name": "traps.udld", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\sudld + (\s(?Plink-fail-rpt))? + (\s(?Pstatus-change))? + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps udld" + "{{ ' link-fail-rpt' if traps.udld.link_fail_rpt|d(False) else '' }}" + "{{ ' status-change' if traps.udld.status_change|d(False) else '' }}", + "result": { + "traps": { + "udld": { + "enable": True, + "link_fail_rpt": "{{ not not link_fail_rpt }}", + "status_change": "{{ not not status_change }}", + }, + }, + }, + }, + { + "name": "traps.vlan_membership", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\svlan-membership + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps vlan-membership", + "result": { + "traps": { + "vlan_membership": True, + }, + }, + }, + { + "name": "traps.vlancreate", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\svlancreate + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps vlancreate", + "result": { + "traps": { + "vlancreate": True, + }, + }, + }, + { + "name": "traps.vlandelete", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\svlandelete + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps vlandelete", + "result": { + "traps": { + "vlandelete": True, + }, + }, + }, + { + "name": "traps.vrfmib", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\svrfmib + (\s(?Pvrf-up))? + (\s(?Pvrf-down))? + (\s(?Pvnet-trunk-up))? + (\s(?Pvnet-trunk-down))? + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps vrfmib" + "{{ ' vrf-up' if traps.vrfmib.vrf_up|d(False) else ''}}" + "{{ ' vrf-down' if traps.vrfmib.vrf_down|d(False) else ''}}" + "{{ ' vnet-trunk-up' if traps.vrfmib.vnet_trunk_up|d(False) else ''}}" + "{{ ' vnet-trunk-down' if traps.vrfmib.vnet_trunk_down|d(False) else ''}}", + "result": { + "traps": { + "vrfmib": { + "vrf_up": "{{ not not vrf_up }}", + "vrf_down": "{{ not not vrf_down }}", + "vnet_trunk_up": "{{ not not vnet_trunk_up }}", + "vnet_trunk_down": "{{ not not vnet_trunk_down }}", + }, + }, + }, + }, + { + "name": "traps.vrrp", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\svrrp + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps vrrp", + "result": { + "traps": { + "vrrp": True, + }, + }, + }, + { + "name": "traps.vswitch", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\svswitch + (\s(?Pdual-active))? + (\s(?Pvsl))? + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps vswitch" + "{{ ' dual-active' if traps.vswitch.dual_active|d(False) else '' }}" + "{{ ' vsl' if traps.vswitch.vsl|d(False) else '' }}", + "result": { + "traps": { + "vswitch": { + "enable": True, + "dual_active": "{{ not not dual_active }}", + "vsl": "{{ not not vsl }}", + }, + }, + }, + }, + { + "name": "traps.vtp", + "getval": re.compile( + r""" + ^snmp-server\senable\straps\svtp + """, re.VERBOSE, + ), + "setval": "snmp-server enable traps vtp", + "result": { + "traps": { + "vtp": True, + }, + }, + }, { "name": "system_shutdown", "getval": re.compile( diff --git a/plugins/modules/ios_snmp_server.py b/plugins/modules/ios_snmp_server.py index f1fe6a2115..64b985131c 100644 --- a/plugins/modules/ios_snmp_server.py +++ b/plugins/modules/ios_snmp_server.py @@ -1,6 +1,6 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright 2022 Red Hat +# Copyright 2023 Red Hat # GNU General Public License v3.0+ # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) @@ -10,7 +10,6 @@ from __future__ import absolute_import, division, print_function - __metaclass__ = type DOCUMENTATION = """ @@ -21,7 +20,7 @@ - This module provides declarative management of SNMP server on Cisco IOS devices. module: ios_snmp_server notes: - - Tested against Cisco IOSXE Version 17.3 on CML. + - Tested against Cisco IOSv Version and IOS-XE v. - This module works with connection C(network_cli). options: config: @@ -122,6 +121,12 @@ context: description: Specify a context to associate with the group type: str + match: + choices: + - exact + - prefix + description: Specify a context name match criteria + type: str version_option: choices: - auth @@ -275,6 +280,9 @@ traps: description: Enable SNMP Traps suboptions: + aaa_server: + description: Enable SNMP AAA Server traps + type: bool auth_framework: description: Enable SNMP CISCO-AUTH-FRAMEWORK-MIB traps suboptions: @@ -344,6 +352,32 @@ description: Enable SNMP STP Bridge MIB topologychange traps type: bool type: dict + bulkstat: + description: Allow Data-Collection-MIB Collection notifications + suboptions: + enable: + description: Enable Data-Collection-MIB Collection and Transfert notifications + type: bool + collection: + description: Enable Data-Collection-MIB Collection notifications + type: bool + transfer: + description: Enable Data-Collection-MIB Transfer notifications + type: bool + type: dict + call_home: + description: SNMP CISCO-CALLHOME-MIB traps + suboptions: + enable: + description: Enable SNMP CISCO-CALLHOME-MIB traps + type: bool + message_send_fail: + description: Enable SNMP ccmSmtpMsgSendFailNotif notification + type: bool + server_fail: + description: Enable SNMP ccmSmtpServerFailNotif notification + type: bool + type: dict casa: description: Enable SNMP config casa traps type: bool @@ -410,31 +444,50 @@ entity: description: Enable SNMP entity traps type: bool + entity_diag: + description: Allow SNMP CISCO-ENTITY-DIAG-MIB traps + suboptions: + boot_up_fail: + description: Enable SNMP ceDiagBootUpFailedNotif traps + type: bool + enable: + description: Enable SNMP CISCO-ENTITY-DIAG-MIB traps + type: bool + hm_test_recover: + description: Enable SNMP ceDiagHMTestRecoverNotif traps + type: bool + hm_thresh_reached: + description: Enable SNMP ceDiagHMThresholdReachedNotif traps + type: bool + scheduled_test_fail: + description: Enable SNMP ceDiagScheduledTestFailedNotif traps + type: bool + type: dict + entity_perf: + description: Allow SNMP CISCO-ENTITY-PERFORMANCE-MIB traps + suboptions: + enable: + description: Enable SNMP CISCO-ENTITY-PERFORMANCE-MIB traps + type: bool + throughput_notif: + description: Enable ENTITY PERFORMANCE MIB throughput traps + type: bool + type: dict + entity_state: + description: Enable SNMP ENTITY-STATE-MIB traps + type: bool energywise: description: Enable SNMP energywise traps type: bool envmon: - description: Allow envmon related traps + description: Enable SNMP environmental monitor traps suboptions: + enable: + description: Enable/disable envmon traps + type: bool fan: description: Enable SNMP envmon fan traps - suboptions: - shutdown: - description: Enable SNMP environmental monitor shutdown traps - type: bool - enable: - description: Enable/disable fan traps - type: bool - status: - description: Enable SNMP environmental status change traps - type: bool - supply: - description: Enable SNMP environmental monitor supply traps - type: bool - temperature: - description: Enable SNMP environmental monitor temperature traps - type: bool - type: dict + type: bool shutdown: description: Enable SNMP environmental monitor shutdown traps type: bool @@ -448,6 +501,9 @@ description: Enable SNMP environmental monitor temperature traps type: bool type: dict + errdisable: + description: Enable SNMP errdisable notifications + type: bool ethernet: description: Allow ethernet traps suboptions: @@ -456,7 +512,7 @@ suboptions: alarm: description: Enable SNMP Ethernet CFM fault alarm trap - type: bool + type: bool cc: description: Enable SNMP Ethernet CC trap type: dict @@ -503,13 +559,39 @@ description: Enable SNMP Ethernet EVC status traps type: bool type: dict - type: dict + type: dict + ether_oam: + description: Enable SNMP ethernet oam traps + type: bool event_manager: description: Enable SNMP event-manager traps type: bool - flowmon: - description: Enable SNMP flowmon traps - type: bool + flash: + description: SNMP FLASH notifications + suboptions: + enable: + description: Enable SNMP FLASH notifications + type: bool + insertion: + description: Enable SNMP Flash Insertion notifications + type: bool + lowspace: + description: Enable SNMP Flash Low Space notifications + type: bool + removal: + description: Enable SNMP Flash Removal notifications + type: bool + type: dict + flex_links: + description: SNMP FLEX Links traps + suboptions: + enable: + description: Enable SNMP FLEX Links traps + type: bool + status: + description: Enable SNMP FLEX Links status change traps + type: bool + type: dict firewall: description: Enable SNMP firewall traps suboptions: @@ -520,6 +602,9 @@ description: Enable firewall server status change trap type: bool type: dict + flowmon: + description: Enable SNMP flowmon traps + type: bool frame_relay: description: Allow frame-relay traps suboptions: @@ -609,6 +694,22 @@ ipsla: description: Enable SNMP ipsla traps type: bool + isis: + description: Enable SNMP isis traps + type: bool + l2tc: + description: Allow SNMP L2 Tunnel Config traps + suboptions: + enable: + description: Enable SNMP L2 Tunnel Config traps + type: bool + sys_threshold: + description: Enable SNMP L2TC System threshold traps + type: bool + threshold: + description: Enable SNMP L2 Tunnel Config threshold traps + type: bool + type: dict l2tun: description: Allow SNMP l2tun traps suboptions: @@ -619,15 +720,236 @@ description: Enable BFD session traps type: bool type: dict + license: + description: Enable license traps + type: bool + lisp: + description: Enable SNMP LISP MIB traps + type: bool + local_auth: + description: Enable SNMP local auth traps + type: bool + mac_notification: + description: Allow SNMP MAC Notification traps + suboptions: + enable: + description: Enable SNMP MAC Notification traps + type: bool + change: + description: Enable SNMP MAC Change traps + type: bool + move: + description: Enable SNMP MAC Move traps + type: bool + threshold: + description: Enable SNMP MAC Threshold traps + type: bool + type: dict + memory: + description: Allow MEMORY traps + suboptions: + enable: + description: Enable MEMORY traps + type: bool + bufferpeak: + description: Enable SNMP Memory Bufferpeak traps + type: bool + type: dict + mpls: + description: Enable SNMP mpls traps + suboptions: + fast_reroute: + description: Allow SNMP MPLS fast reroute traps + suboptions: + enable: + description: Enable SNMP MPLS fast reroute traps + type: bool + protected: + description: Enable MPLS fast reroute protection traps + type: bool + type: dict + ldp: + description: Allow SNMP MPLS label distribution protocol traps + suboptions: + enable: + description: Enable SNMP MPLS label distribution protocol traps + type: bool + pv_limit: + description: Enable MPLS LDP path vector limit mismatch traps + type: bool + session_down: + description: Enable MPLS LDP session down traps + type: bool + session_up: + description: Enable MPLS LDP session up traps + type: bool + threshold: + description: Enable MPLS LDP threshold exceeded traps + type: bool + type: dict + rfc: + description: Enable SNMP MPLS RFC traps + suboptions: + ldp: + description: Allow SNMP MPLS label distribution protocol RFC traps + suboptions: + enable: + description: Enable SNMP MPLS label distribution protocol RFC traps + type: bool + pv_limit: + description: Enable MPLS LDP path vector limit mismatch RFC traps + type: bool + session_down: + description: Enable MPLS LDP session down RFC traps + type: bool + session_up: + description: Enable MPLS LDP session up RFC traps + type: bool + threshold: + description: Enable MPLS LDP threshold exceeded RFC traps + type: bool + type: dict + traffic_eng: + description: Allow SNMP MPLS traffic engineering RFC traps + suboptions: + enable: + description: Enable SNMP MPLS traffic engineering RFC traps + type: bool + down: + description: Enable MPLS TE tunnel down RFC traps + type: bool + reoptimized: + description: Enable MPLS TE tunnel reoptimized RFC traps + type: bool + reroute: + description: Enable MPLS TE tunnel reroute RFC traps + type: bool + up: + description: Enable MPLS TE tunnel up RFC traps + type: bool + type: dict + vpn: + description: Allow SNMP MPLS Virtual Private Network RFC traps + suboptions: + enable: + description: Enable SNMP MPLS Virtual Private Network RFC traps + type: bool + illegal_label: + description: Enable MPLS VPN illegal label threshold exceeded RFC traps + type: bool + max_thresh_cleared: + description: Enable MPLS VPN maximum threshold cleared RFC traps + type: bool + max_threshold: + description: Enable MPLS VPN maximum threshold exceeded RFC traps + type: bool + mid_threshold: + description: Enable MPLS VPN middle threshold exceeded RFC traps + type: bool + vrf_down: + description: Enable MPLS VPN vrf down RFC traps + type: bool + vrf_up: + description: Enable MPLS VPN vrf up RFC traps + type: bool + type: dict + traffic_eng: + description: Allow SNMP MPLS traffic engineering traps + suboptions: + enable: + description: Enable SNMP MPLS traffic engineering traps + type: bool + down: + description: Enable MPLS TE tunnel down traps + type: bool + reroute: + description: Enable MPLS TE tunnel reroute traps + type: bool + up: + description: Enable MPLS TE tunnel up traps + type: bool + type: dict + vpn: + description: Allow SNMP MPLS Virtual Private Network traps + suboptions: + enable: + description: Enable SNMP MPLS Virtual Private Network traps + type: bool + illegal_label: + description: Enable MPLS VPN illegal label threshold exceeded traps + type: bool + max_thresh_cleared: + description: Enable MPLS VPN maximum threshold cleared traps + type: bool + max_threshold: + description: Enable MPLS VPN maximum threshold exceeded traps + type: bool + mid_threshold: + description: Enable MPLS VPN middle threshold exceeded traps + type: bool + vrf_down: + description: Enable MPLS VPN vrf down traps + type: bool + vrf_up: + description: Enable MPLS VPN vrf up traps + type: bool + type: dict + type: dict msdp: description: Enable SNMP msdp traps type: bool mvpn: description: Enable SNMP mvpn traps type: bool - mpls_vpn: - description: Enable SNMP mpls traps - type: bool + nhrp: + description: Allow SNMP NHRP traps + suboptions: + enable: + description: Enable SNMP NHRP traps + type: bool + nhc: + description: Allow Next Hop Client traps + suboptions: + enable: + description: Enable Next Hop Client traps + type: bool + down: + description: Enable Next Hop Client down trap + type: bool + up: + description: Enable Next Hop Client up trap + type: bool + type: dict + nhp: + description: Allow Next Hop Peer traps + suboptions: + enable: + description: Enable Next Hop Peer traps + type: bool + down: + description: Enable Next Hop Peer down trap + type: bool + up: + description: Enable Next Hop Peer up trap + type: bool + type: dict + nhs: + description: Allow Next Hop Server traps + suboptions: + enable: + description: Enable Next Hop Server traps + type: bool + down: + description: Enable Next Hop Server down trap + type: bool + up: + description: Enable Next Hop Server up trap + type: bool + type: dict + quota_exceeded: + description: Enable quota-exceeded trap + type: bool + type: dict ospf: description: Allow ospf related traps suboptions: @@ -674,6 +996,65 @@ description: Enable/disable state change traps type: bool type: dict + ospfv3: + description: Allow OSPFv3 related traps + suboptions: + errors: + description: Error traps + suboptions: + enable: + description: Enable Error traps + type: bool + bad_packet: + description: Packet parse failure on non-virtual interfaces + type: bool + config_error: + description: Config mismatch errors on non-virtual interfaces + type: bool + virt_bad_packet: + description: Packet parse failure on virtual interfaces + type: bool + virt_config_error: + description: Config mismatch errors on virtual interfaces + type: bool + type: dict + rate_limit: + description: + - Trap rate limit values + - Rate limit window size in seconds (between 2 and 60) + type: int + state_change: + description: State change traps + suboptions: + enable: + description: Enable State change traps + type: bool + if_state_change: + description: Non_virtual interface state changes + type: bool + neighbor_restart_helper_status_change: + description: Neighbor graceful restart helper status changes + type: bool + neighbor_state_change: + description: Non_virtual neighbor state changes + type: bool + nssa_translator_status_change: + description: NSSA translator status changes + type: bool + restart_status_change: + description: Graceful restart status changes + type: bool + virtif_state_change: + description: Virtual interface state changes + type: bool + virtneighbor_restart_helper_status_change: + description: Virtual neighbor graceful restart helper status changes + type: bool + virtneighbor_state_change: + description: Virtual neighbor state changes + type: bool + type: dict + type: dict pim: description: Allow PIM traps suboptions: @@ -690,34 +1071,58 @@ description: Enable/disable PIM traps type: bool type: dict - vrfmib: - description: Allow vrfmib traps + pki: + description: Enable SNMP pki traps + type: bool + port_security: + description: Enable SNMP port security traps + type: bool + power_ethernet: + description: Allow SNMP power ethernet traps suboptions: - vrf_up: - description: Enable vrf-up trap - type: bool - vrf_down: - description: Enable vrf-down trap - type: bool - vnet_trunk_up: - description: Enable vnet-trunk-up trap + enable: + description: Enable SNMP power ethernet traps type: bool - vnet_trunk_down: - description: Enable vnet-trunk-down traps + group: + description: Enable SNMP inline power group based traps. + suboptions: + slot_id: + description: An integer between 1 and 20 (physical slot number) + type: int + threshold: + description: Threshold level for this slot + type: int + elements: dict + type: list + police: + description: Enable Policing Trap type: bool type: dict - pki: - description: Enable SNMP pki traps + pw_vc: + description: Enable SNMP pw vc traps + type: bool + rep: + description: Enable SNMP Resilient Ethernet Protocol Traps type: bool rsvp: description: Enable SNMP RSVP traps type: bool - isis: - description: Enable SNMP isis traps - type: bool - pw_vc: - description: Enable SNMP pw vc traps + rf: + description: Enable all SNMP traps defined in CISCO-RF-MIB type: bool + smart_license: + description: Allow smart license traps + suboptions: + enable: + description: Enable smart license traps + type: bool + entitlement: + description: Enable Entitlement Notification trap + type: bool + global: + description: Enable Global Notification traps + type: bool + type: dict snmp: description: Enable SNMP traps suboptions: @@ -737,18 +1142,198 @@ description: Enable warmStart trap type: bool type: dict + stackwise: + description: Enable SNMP stackwise traps + type: bool + stpx: + description: Allow SNMP STPX MIB traps + suboptions: + enable: + description: Enable SNMP STPX MIB traps + type: bool + inconsistency: + description: Enable SNMP STPX MIB InconsistencyUpdate traps + type: bool + loop_inconsistency: + description: Enable SNMP STPX MIB LoopInconsistencyUpdate traps + type: bool + root_inconsistency: + description: Enable SNMP STPX MIB RootInconsistencyUpdate traps + type: bool + type: dict syslog: description: Enable SNMP syslog traps type: bool transceiver_all: description: Enable SNMP transceiver traps type: bool + trustsec: + description: Allow SNMP CISCO-TRUSTSEC-MIB traps + suboptions: + authz_file_error: + description: Enable ctsAuthzCacheFileErrNotif notifications + type: bool + cache_file_error: + description: Enable ctsCacheFileAccessErrNotif notifications + type: bool + enable: + description: Enable SNMP CISCO-TRUSTSEC-MIB traps + type: bool + keystore_file_error: + description: Enable ctsSwKeystoreFileErrNotif notifications + type: bool + keystore_sync_fail: + description: Enable ctsSwKeystoreSyncFailNotif notifications + type: bool + random_number_fail: + description: Enable ctsSapRandonNumberFailNotif notifications + type: bool + src_entropy_fail: + description: Enable ctsSrcEntropyFailNotif notifications + type: bool + type: dict + trustsec_interface: + description: Allow SNMP CISCO-TRUSTSEC-INTERFACE-MIB traps + suboptions: + enable: + description: Enable SNMP CISCO-TRUSTSEC-INTERFACE-MIB traps + type: bool + authc_fail: + description: Enable ctsiIfAuthenticationFailNotif trap + type: bool + authz_fail: + description: Enable ctsiAuthorizationFailNotif trap + type: bool + sap_fail: + description: Enable ctsiIfSapNegotiationFailNotif trap + type: bool + supplicant_fail: + description: Enable ctsiIfAddSupplicantFailNotif trap + type: bool + unauthorized: + description: Enable ctsiIfUnauthorizedNotifEnable trap + type: bool + type: dict + trustsec_policy: + description: Allow SNMP CISCO-TRUSTSEC-POLICY-MIB traps + suboptions: + enable: + description: Enable SNMP CISCO-TRUSTSEC-POLICY-MIB traps + type: bool + authz_sgacl_fail: + description: Enable ctspAuthorizationSgaclFailNotif notifications + type: bool + peer_policy_updated: + description: Enable ctspPeerPolicyUpdatedNotif notifications + type: bool + type: dict + trustsec_server: + description: Allow SNMP CISCO-TRUSTSEC-SERVER-MIB traps + suboptions: + enable: + description: Enable SNMP CISCO-TRUSTSEC-SERVER-MIB traps + type: bool + provision_secret: + description: Enable ctsvNoProvisionSecretNotif notification + type: bool + radius_server: + description: Enable ctsvNoRadiusServerNotif notification + type: bool + type: dict + trustsec_sxp: + description: Allow SNMP CISCO-TRUSTSEC-SXP-MIB traps + suboptions: + enable: + description: Enable SNMP CISCO-TRUSTSEC-SXP-MIB traps + type: bool + binding_conflict: + description: Enable ctsxSxpBindingConflictNotif notifications + type: bool + binding_err: + description: Enable ctsxSxpBindingErrNotif notifications + type: bool + binding_expn_fail: + description: Enable ctsxSxpBindingExpnFailNotif notifications + type: bool + conn_config_err: + description: Enable ctsxSxpConnConfigErrNotif notifications + type: bool + conn_down: + description: Enable ctsxSxpConnDownNotif notifications + type: bool + conn_srcaddr_err: + description: Enable ctsxSxpConnSourceAddrErrNotif notifications + type: bool + conn_up: + description: Enable ctsxSxpConnUpNotif notifications + type: bool + msg_parse_err: + description: Enable ctsxSxpMsgParseErrNotif notifications + type: bool + oper_nodeid_change: + description: Enable ctsxSxpOperNodeIdChangeNotif notifications + type: bool + type: dict tty: description: Enable SNMP tty TCP connection traps type: bool + udld: + description: Allow SNMP CISCO-UDLDP-MIB traps + suboptions: + enable: + description: Enable SNMP CISCO-UDLDP-MIB traps + type: bool + link_fail_rpt: + description: Enable SNMP cudldpFastHelloLinkFailRptNotification traps + type: bool + status_change: + description: Enable SNMP cudldpFastHelloStatusChangeNotification traps + type: bool + type: dict + vlan_membership: + description: Enable SNMP VLAN membership traps + type: bool + vlancreate: + description: Enable SNMP VLAN created traps + type: bool + vlandelete: + description: Enable SNMP VLAN deleted traps + type: bool + vrfmib: + description: Allow vrfmib traps + suboptions: + vrf_up: + description: Enable vrf-up trap + type: bool + vrf_down: + description: Enable vrf-down trap + type: bool + vnet_trunk_up: + description: Enable vnet-trunk-up trap + type: bool + vnet_trunk_down: + description: Enable vnet-trunk-down traps + type: bool + type: dict vrrp: description: Enable SNMP vrrp traps type: bool + vswitch: + description: Allow SNMP Virtual Switch notifications + suboptions: + dual_active: + description: Enable SNMP Virtual Switch (Dual Active) notification + type: bool + enable: + description: Enable SNMP Virtual Switch notifications + ttype: bool + vsl: + description: Enable SNMP Virtual Switch Link (VSL) notification + type: bool + type: dict + vtp: + description: Enable SNMP VTP traps + type: bool type: dict users: description: Define a user who can access the SNMP engine @@ -765,6 +1350,7 @@ - Authentication parameters for the user. - Effects idempotency of module as configuration applied is not reflected in running-config. + no_log: False type: dict suboptions: algorithm: @@ -775,11 +1361,12 @@ description: - Authentication password for user. type: str - encryption: + encryption: description: - Encryption parameters for the user. - Effects idempotency of module as configuration applied is not reflected in running-config. + no_log: False type: dict suboptions: priv: @@ -864,7 +1451,7 @@ - The states I(replaced) and I(overridden) have identical behaviour for this module. type: str -short_description: Resource module to configure snmp server. +short_description: Resource module to configure snmp server version_added: 2.6.0 """ @@ -1964,17 +2551,17 @@ returned: when I(state) is C(merged), C(replaced), C(overridden), C(deleted) or C(purged) type: list sample: - - snmp-server host 172.16.2.99 informs version 2c check msdp stun - - snmp-server engineID remote 172.16.0.2 udp-port 23 AB0C5342FAAB - - snmp-server group grp1 v1 notify me access 2 + - sample command 1 + - sample command 2 + - sample command 3 rendered: description: The provided configuration in the task rendered in device-native format (offline). returned: when I(state) is C(rendered) type: list sample: - - snmp-server enable traps ipsec cryptomap attach - - snmp-server password-policy policy1 define max-len 24 upper-case 12 lower-case 12 special-char 32 digits 23 change 3 - - snmp-server cache interval 2 + - sample command 1 + - sample command 2 + - sample command 3 gathered: description: Facts about the network resource gathered from the remote device as structured data. returned: when I(state) is C(gathered) @@ -1992,7 +2579,6 @@ """ from ansible.module_utils.basic import AnsibleModule - from ansible_collections.cisco.ios.plugins.module_utils.network.ios.argspec.snmp_server.snmp_server import ( Snmp_serverArgs, ) diff --git a/tests/unit/modules/network/ios/test_ios_snmp_server.py b/tests/unit/modules/network/ios/test_ios_snmp_server.py index 2db2701e58..bd1f0307c7 100644 --- a/tests/unit/modules/network/ios/test_ios_snmp_server.py +++ b/tests/unit/modules/network/ios/test_ios_snmp_server.py @@ -319,7 +319,9 @@ def test_ios_snmp_server_merged_idempotent(self): "ipsla": True, "isis": True, "l2tun": {"pseudowire_status": True, "session": True}, - "mpls_vpn": True, + "mpls": { + "vpn": {"enable": True}, + }, "msdp": True, "mvpn": True, "ospf": { @@ -572,7 +574,9 @@ def test_ios_snmp_server_merged(self): "ipsla": True, "isis": True, "l2tun": {"pseudowire_status": True, "session": True}, - "mpls_vpn": True, + "mpls": { + "vpn": {"enable": True}, + }, "msdp": True, "mvpn": True, "ospf": { @@ -636,7 +640,8 @@ def test_ios_snmp_server_merged(self): "snmp-server trap-source GigabitEthernet0/0", "snmp-server system-shutdown", "snmp-server enable traps bfd", - "snmp-server enable traps bgp cbgp2 state-changes all backward-trans limited threshold prefix", + "snmp-server enable traps bgp cbgp2", + "snmp-server enable traps bgp state-changes all backward-trans limited threshold prefix", "snmp-server enable traps bridge newroot topologychange", "snmp-server enable traps eigrp", "snmp-server enable traps energywise", @@ -671,7 +676,7 @@ def test_ios_snmp_server_merged(self): "snmp-server enable traps l2tun pseudowire status", "snmp-server enable traps l2tun session", "snmp-server enable traps pim neighbor-change rp-mapping-change invalid-pim-message", - "snmp-server enable traps snmp authentication linkdown linkup warmstart coldstart", + "snmp-server enable traps snmp authentication linkdown linkup coldstart warmstart", "snmp-server enable traps frame-relay", "snmp-server enable traps cef resource-failure peer-state-change peer-fib-state-change inconsistency", "snmp-server enable traps dlsw", @@ -726,65 +731,110 @@ def test_ios_snmp_server_deleted(self): snmp-server contact this is contact string snmp-server chassis-id this is a chassis id string snmp-server system-shutdown - snmp-server enable traps snmp authentication linkdown linkup coldstart warmstart - snmp-server enable traps flowmon - snmp-server enable traps tty - snmp-server enable traps eigrp - snmp-server enable traps casa - snmp-server enable traps ospf state-change - snmp-server enable traps ospf errors - snmp-server enable traps ospf retransmit - snmp-server enable traps ospf lsa - snmp-server enable traps ospf cisco-specific state-change nssa-trans-change - snmp-server enable traps ospf cisco-specific state-change shamlink interface - snmp-server enable traps ospf cisco-specific state-change shamlink neighbor - snmp-server enable traps ospf cisco-specific errors - snmp-server enable traps ospf cisco-specific retransmit - snmp-server enable traps ospf cisco-specific lsa - snmp-server enable traps ethernet cfm cc mep-up mep-down cross-connect loop config - snmp-server enable traps ethernet cfm crosscheck mep-missing mep-unknown service-up + snmp-server enable traps aaa_server snmp-server enable traps auth-framework sec-violation + snmp-server enable traps bfd + snmp-server enable traps bgp + snmp-server enable traps bgp cbgp2 + snmp-server enable traps bridge newroot topologychange + snmp-server enable traps bulkstat collection transfer + snmp-server enable traps call-home message-send-fail server-fail + snmp-server enable traps cef resource-failure peer-state-change peer-fib-state-change inconsistency + snmp-server enable traps config + snmp-server enable traps config-copy + snmp-server enable traps config-ctid + snmp-server enable traps cpu threshold + snmp-server enable traps dhcp + snmp-server enable traps eigrp snmp-server enable traps energywise - snmp-server enable traps pw vc - snmp-server enable traps l2tun session - snmp-server enable traps l2tun pseudowire status + snmp-server enable traps entity + snmp-server enable traps entity-diag boot-up-fail hm-test-recover hm-thresh-reached scheduled-test-fail + snmp-server enable traps entity-perf throughput-notif + snmp-server enable traps entity-state + snmp-server enable traps envmon fan shutdown supply temperature status + snmp-server enable traps errdisable snmp-server enable traps ether-oam + snmp-server enable traps ethernet cfm alarm + snmp-server enable traps ethernet cfm cc mep-up mep-down cross-connect loop config + snmp-server enable traps ethernet cfm crosscheck mep-missing mep-unknown service-up snmp-server enable traps ethernet evc status create delete - snmp-server enable traps bridge newroot topologychange - snmp-server enable traps vtp + snmp-server enable traps event-manager + snmp-server enable traps flash insertion removal lowspace + snmp-server enable traps flex-links status + snmp-server enable traps flowmon + snmp-server enable traps fru-ctrl + snmp-server enable traps hsrp snmp-server enable traps ike policy add snmp-server enable traps ike policy delete snmp-server enable traps ike tunnel start snmp-server enable traps ike tunnel stop + snmp-server enable traps ipmulticast snmp-server enable traps ipsec cryptomap add - snmp-server enable traps ipsec cryptomap delete snmp-server enable traps ipsec cryptomap attach + snmp-server enable traps ipsec cryptomap delete snmp-server enable traps ipsec cryptomap detach + snmp-server enable traps ipsec too-many-sas snmp-server enable traps ipsec tunnel start snmp-server enable traps ipsec tunnel stop - snmp-server enable traps ipsec too-many-sas - snmp-server enable traps bfd - snmp-server enable traps bgp - snmp-server enable traps bgp cbgp2 - snmp-server enable traps cef resource-failure peer-state-change peer-fib-state-change inconsistency - snmp-server enable traps dlsw - snmp-server enable traps frame-relay - snmp-server enable traps frame-relay subif - snmp-server enable traps hsrp - snmp-server enable traps ipmulticast + snmp-server enable traps ipsla snmp-server enable traps isis + snmp-server enable traps license + snmp-server enable traps l2tc threshold sys-threshold + snmp-server enable traps lisp + snmp-server enable traps local-auth + snmp-server enable traps mac-notification change move threshold + snmp-server enable traps memory bufferpeak + snmp-server enable traps mpls fast-reroute protected + snmp-server enable traps memory + snmp-server enable traps mpls rfc ldp + snmp-server enable traps mpls rfc traffic-eng + snmp-server enable traps mpls rfc vpn + snmp-server enable traps mpls traffic-eng + snmp-server enable traps mpls vpn snmp-server enable traps msdp snmp-server enable traps mvpn + snmp-server enable traps nhrp nhc + snmp-server enable traps nhrp nhp + snmp-server enable traps nhrp nhs + snmp-server enable traps nhrp quota-exceeded + snmp-server enable traps ospf cisco-specific errors + snmp-server enable traps ospf cisco-specific lsa + snmp-server enable traps ospf cisco-specific retransmit + snmp-server enable traps ospf cisco-specific state-change nssa-trans-change + snmp-server enable traps ospf cisco-specific state-change shamlink interface + snmp-server enable traps ospf cisco-specific state-change shamlink neighbor + snmp-server enable traps ospf errors + snmp-server enable traps ospf lsa + snmp-server enable traps ospf retransmit + snmp-server enable traps ospf state-change + snmp-server enable traps ospfv3 errors + snmp-server enable traps ospfv3 state-change snmp-server enable traps pim neighbor-change rp-mapping-change invalid-pim-message - snmp-server enable traps rsvp - snmp-server enable traps ipsla - snmp-server enable traps slb real virtual csrp - snmp-server enable traps syslog - snmp-server enable traps event-manager snmp-server enable traps pki - snmp-server enable traps ethernet cfm alarm - snmp-server enable traps mpls vpn + snmp-server enable traps port-security + snmp-server enable traps power-ethernet police + snmp-server enable traps pw vc + snmp-server enable traps rep + snmp-server enable traps rf + snmp-server enable traps smart-license + snmp-server enable traps snmp authentication linkdown linkup coldstart warmstart + snmp-server enable traps stackwise + snmp-server enable traps stpx inconsistency root-inconsistency loop-inconsistency + snmp-server enable traps syslog + snmp-server enable traps transceiver all + snmp-server enable traps trustsec authz-file-error cache-file-error keystore-file-error keystore-sync-fail random-number-fail src-entropy-fail + snmp-server enable traps trustsec-interface unauthorized sap-fail authc-fail supplicant-fail authz-fail + snmp-server enable traps trustsec-policy peer-policy-updated authz-sgacl-fail + snmp-server enable traps trustsec-server radius-server provision-secret + snmp-server enable traps trustsec-sxp conn-srcaddr-err msg-parse-err conn-config-err binding-err conn-up conn-down binding-expn-fail oper-nodeid-change binding-conflict + snmp-server enable traps tty + snmp-server enable traps udld link-fail-rpt status-change + snmp-server enable traps vlan-membership + snmp-server enable traps vlancreate + snmp-server enable traps vlandelete snmp-server enable traps vrfmib vrf-up vrf-down vnet-trunk-up vnet-trunk-down + snmp-server enable traps vswitch dual-active vsl + snmp-server enable traps vtp snmp-server host 172.16.2.99 informs version 2c check msdp snmp-server host 172.16.2.99 check slb snmp-server host 172.16.2.99 checktrap isis @@ -817,60 +867,110 @@ def test_ios_snmp_server_deleted(self): "no snmp-server source-interface informs Loopback999", "no snmp-server trap-source GigabitEthernet0/0", "no snmp-server system-shutdown", - "no snmp-server enable traps auth-framework", + "no snmp-server enable traps aaa_server", + "no snmp-server enable traps auth-framework sec-violation", "no snmp-server enable traps bfd", "no snmp-server enable traps bgp", + "no snmp-server enable traps bgp cbgp2", "no snmp-server enable traps bridge newroot topologychange", - "no snmp-server enable traps casa", + "no snmp-server enable traps bulkstat collection transfer", + "no snmp-server enable traps call-home message-send-fail server-fail", + "no snmp-server enable traps cef resource-failure peer-state-change peer-fib-state-change inconsistency", + "no snmp-server enable traps config", + "no snmp-server enable traps config-copy", + "no snmp-server enable traps config-ctid", + "no snmp-server enable traps cpu threshold", + "no snmp-server enable traps dhcp", "no snmp-server enable traps eigrp", "no snmp-server enable traps energywise", + "no snmp-server enable traps entity", + "no snmp-server enable traps entity-diag boot-up-fail hm-test-recover hm-thresh-reached scheduled-test-fail", + "no snmp-server enable traps entity-perf throughput-notif", + "no snmp-server enable traps entity-state", + "no snmp-server enable traps envmon fan shutdown supply temperature status", + "no snmp-server enable traps errdisable", + "no snmp-server enable traps ether-oam", + "no snmp-server enable traps ethernet cfm alarm", + "no snmp-server enable traps ethernet cfm cc mep-up mep-down cross-connect loop config", + "no snmp-server enable traps ethernet cfm crosscheck mep-missing mep-unknown service-up", + "no snmp-server enable traps ethernet evc status create delete", "no snmp-server enable traps event-manager", + "no snmp-server enable traps flash insertion removal lowspace", + "no snmp-server enable traps flex-links status", "no snmp-server enable traps flowmon", + "no snmp-server enable traps fru-ctrl", "no snmp-server enable traps hsrp", - "no snmp-server enable traps ipsla", - "no snmp-server enable traps isis", - "no snmp-server enable traps msdp", - "no snmp-server enable traps mvpn", - "no snmp-server enable traps mpls vpn", - "no snmp-server enable traps pki", - "no snmp-server enable traps pw vc", - "no snmp-server enable traps rsvp", - "no snmp-server enable traps syslog", - "no snmp-server enable traps tty", - "no snmp-server enable traps vrfmib vrf-up vrf-down vnet-trunk-up vnet-trunk-down", - "no snmp-server enable traps ipmulticast", "no snmp-server enable traps ike policy add", "no snmp-server enable traps ike policy delete", "no snmp-server enable traps ike tunnel start", "no snmp-server enable traps ike tunnel stop", + "no snmp-server enable traps ipmulticast", "no snmp-server enable traps ipsec cryptomap add", - "no snmp-server enable traps ipsec cryptomap delete", "no snmp-server enable traps ipsec cryptomap attach", + "no snmp-server enable traps ipsec cryptomap delete", "no snmp-server enable traps ipsec cryptomap detach", + "no snmp-server enable traps ipsec too-many-sas", "no snmp-server enable traps ipsec tunnel start", "no snmp-server enable traps ipsec tunnel stop", - "no snmp-server enable traps ipsec too-many-sas", + "no snmp-server enable traps ipsla", + "no snmp-server enable traps isis", + "no snmp-server enable traps license", + "no snmp-server enable traps l2tc threshold sys-threshold", + "no snmp-server enable traps lisp", + "no snmp-server enable traps local-auth", + "no snmp-server enable traps mac-notification change move threshold", + "no snmp-server enable traps memory bufferpeak", + "no snmp-server enable traps mpls fast-reroute protected", + "no snmp-server enable traps memory", + "no snmp-server enable traps mpls rfc ldp", + "no snmp-server enable traps mpls rfc traffic-eng", + "no snmp-server enable traps mpls rfc vpn", + "no snmp-server enable traps mpls traffic-eng", + "no snmp-server enable traps mpls vpn", + "no snmp-server enable traps msdp", + "no snmp-server enable traps mvpn", + "no snmp-server enable traps nhrp nhc", + "no snmp-server enable traps nhrp nhp", + "no snmp-server enable traps nhrp nhs", + "no snmp-server enable traps nhrp quota-exceeded", "no snmp-server enable traps ospf cisco-specific errors", - "no snmp-server enable traps ospf cisco-specific retransmit", "no snmp-server enable traps ospf cisco-specific lsa", + "no snmp-server enable traps ospf cisco-specific retransmit", "no snmp-server enable traps ospf cisco-specific state-change nssa-trans-change", "no snmp-server enable traps ospf cisco-specific state-change shamlink interface", "no snmp-server enable traps ospf cisco-specific state-change shamlink neighbor", "no snmp-server enable traps ospf errors", - "no snmp-server enable traps ospf retransmit", "no snmp-server enable traps ospf lsa", + "no snmp-server enable traps ospf retransmit", "no snmp-server enable traps ospf state-change", - "no snmp-server enable traps l2tun pseudowire status", - "no snmp-server enable traps l2tun session", + "no snmp-server enable traps ospfv3 errors", + "no snmp-server enable traps ospfv3 state-change", "no snmp-server enable traps pim neighbor-change rp-mapping-change invalid-pim-message", - "no snmp-server enable traps snmp authentication linkdown linkup warmstart coldstart", - "no snmp-server enable traps frame-relay", - "no snmp-server enable traps cef resource-failure peer-state-change peer-fib-state-change inconsistency", - "no snmp-server enable traps dlsw", - "no snmp-server enable traps ethernet evc create delete status", - "no snmp-server enable traps ethernet cfm alarm", - "no snmp-server enable traps ethernet cfm cc mep-up mep-down cross-connect loop config", - "no snmp-server enable traps ethernet cfm crosscheck mep-missing mep-unknown service-up", + "no snmp-server enable traps pki", + "no snmp-server enable traps port-security", + "no snmp-server enable traps power-ethernet police", + "no snmp-server enable traps pw vc", + "no snmp-server enable traps rep", + "no snmp-server enable traps rf", + "no snmp-server enable traps smart-license", + "no snmp-server enable traps snmp authentication linkdown linkup coldstart warmstart", + "no snmp-server enable traps stackwise", + "no snmp-server enable traps stpx inconsistency root-inconsistency loop-inconsistency", + "no snmp-server enable traps syslog", + "no snmp-server enable traps transceiver all", + "no snmp-server enable traps trustsec authz-file-error cache-file-error keystore-file-error keystore-sync-fail random-number-fail src-entropy-fail", + "no snmp-server enable traps trustsec-interface unauthorized sap-fail authc-fail supplicant-fail authz-fail", + "no snmp-server enable traps trustsec-policy peer-policy-updated authz-sgacl-fail", + "no snmp-server enable traps trustsec-server radius-server provision-secret", + "no snmp-server enable traps trustsec-sxp conn-srcaddr-err msg-parse-err conn-config-err binding-err conn-up conn-down binding-expn-fail oper-nodeid-change binding-conflict", + "no snmp-server enable traps tty", + "no snmp-server enable traps udld link-fail-rpt status-change", + "no snmp-server enable traps vlan-membership", + "no snmp-server enable traps vlancreate", + "no snmp-server enable traps vlandelete", + "no snmp-server enable traps vrfmib vrf-up vrf-down vnet-trunk-up vnet-trunk-down", + "no snmp-server enable traps vswitch dual-active vsl", + "no snmp-server enable traps vtp", "no snmp-server host 172.16.1.1 version 3 auth group0 tty", "no snmp-server host 172.16.2.1 version 3 priv newtera rsrb", "no snmp-server host 172.16.2.1 version 3 noauth replaceUser slb", @@ -1075,7 +1175,7 @@ def test_ios_snmp_server_overridden(self): "trap_source": "GigabitEthernet0/0", "trap_timeout": 2, "traps": { - "auth_framework": {"enable": True}, + "auth_framework": {"enable": True, "sec_violation": True}, "bfd": {"enable": True}, "bgp": {"cbgp2": True, "enable": True}, "bridge": {"enable": True, "newroot": True, "topologychange": True}, @@ -1125,7 +1225,9 @@ def test_ios_snmp_server_overridden(self): "ipsla": True, "isis": True, "l2tun": {"pseudowire_status": True, "session": True}, - "mpls_vpn": True, + "mpls": { + "vpn": {"enable": True}, + }, "msdp": True, "mvpn": True, "ospf": { @@ -1215,6 +1317,7 @@ def test_ios_snmp_server_overridden(self): "snmp-server password-policy policy2 define min-len 12 upper-case 12 special-char 22 change 9", "snmp-server user paul familypaul v3 access ipv6", "snmp-server view newView TestFamilyName included", + "no snmp-server enable traps vtp", "no snmp-server view test-view! test-test included", ] playbook["state"] = "overridden" @@ -1323,10 +1426,11 @@ def test_ios_snmp_server_parsed(self): }, }, "envmon": { + "enable": True, "status": True, "supply": True, "temperature": True, - "fan": {"supply": True, "temperature": True}, + "fan": True, }, "ethernet": { "cfm": {