Skip to content

Commit

Permalink
Merge branch 'main' into acl_order_remark
Browse files Browse the repository at this point in the history
  • Loading branch information
KB-perByte authored Oct 25, 2023
2 parents 5d84af2 + bbfdcbd commit b751f38
Show file tree
Hide file tree
Showing 11 changed files with 7,349 additions and 1,116 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/error_parser_bug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- "Fix invalid password length not being recognized by the error parser."
7 changes: 7 additions & 0 deletions changelogs/fragments/ios_snmp_server_changes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
minor_changes:
- ios_snmp_server - Update the module to manage correctly a lot of traps not take in count
- ios_snmp_server - Fix an issue with cbgp2 to take in count correctly the bgp traps
deprecated_features:
- ios_snmp_server - deprecate traps.mpls_vpn with traps.mpls
- ios_snmp_server - deprecate traps.envmon.fan with traps.envmon.fan_enable
5,026 changes: 4,556 additions & 470 deletions docs/cisco.ios.ios_snmp_server_module.rst

Large diffs are not rendered by default.

440 changes: 411 additions & 29 deletions plugins/module_utils/network/ios/argspec/snmp_server/snmp_server.py

Large diffs are not rendered by default.

136 changes: 104 additions & 32 deletions plugins/module_utils/network/ios/config/snmp_server/snmp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,72 +77,121 @@ def __init__(self, module):
"views",
]
self.complex_parsers = [
"traps.aaa_server",
"traps.auth_framework",
"traps.bfd",
"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):
Expand All @@ -163,6 +212,8 @@ def generate_commands(self):
wantd = self._snmp_list_to_dict(self.want)
haved = self._snmp_list_to_dict(self.have)

wantd = self._handle_deprecates(want=wantd)

# if state is merged, merge want onto have and then compare
if self.state == "merged":
wantd = dict_merge(haved, wantd)
Expand Down Expand Up @@ -265,7 +316,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] = {
Expand All @@ -274,3 +326,23 @@ def _snmp_list_to_dict(self, data):
else:
tmp_data[k] = {str(i[p_key.get(k)]): i for i in tmp_data[k]}
return tmp_data

def _handle_deprecates(self, want):
"""Remove deprecated attributes and set the replacment"""

# Take in count the traps config mpls_vpn which is DEPRECATED and replaced by mpls.vpn
if "traps" in want:
if "mpls_vpn" in want["traps"]:
want["traps"] = dict_merge(
want["traps"],
{"mpls": {"vpn": {"enable": want["traps"]["mpls_vpn"]}}},
)
want["traps"].pop("mpls_vpn")
if "envmon" in want["traps"] and "fan" in want["traps"]["envmon"]:
want["traps"]["envmon"]["fan_enable"] = want["traps"]["envmon"]["fan"].get(
"enable",
False,
)
want["traps"]["envmon"].pop("fan")

return want
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, module, subspec="config", options="options"):
self.argument_spec = Snmp_serverArgs.argument_spec

def get_snmp_data(self, connection):
_get_snmp_data = connection.get("show running-config | section ^snmp-server")
_get_snmp_data = connection.get("show running-config | section ^snmp")
return _get_snmp_data

def get_snmpv3_user_data(self, connection):
Expand Down
Loading

0 comments on commit b751f38

Please sign in to comment.