Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ios_snmp_server: Update the module #828

Merged
merged 25 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
eb6d003
ios_snmp_server: Update the module to take in count a lot of missing …
earendilfr May 25, 2023
2927787
Merge remote-tracking branch 'upstream/main' into update_snmp_traps
earendilfr Jul 31, 2023
708a082
Merge remote-tracking branch 'upstream/main' into update_snmp_traps
earendilfr Aug 8, 2023
16ea7d4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 8, 2023
d2c3ba2
Merge branch 'main' into update_snmp_traps
roverflow Aug 30, 2023
4343529
Resolve commented issues
earendilfr Sep 1, 2023
4618819
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 1, 2023
d3f2ada
Fixe comment in PR
earendilfr Sep 5, 2023
3cbc97a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 5, 2023
891fbcf
Merge branch 'main' into update_snmp_traps
roverflow Sep 5, 2023
b592689
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 5, 2023
f310f43
Merge branch 'main' into update_snmp_traps
KB-perByte Sep 7, 2023
fd42ed0
put the command to transform deprecated variable in a specific function
earendilfr Sep 7, 2023
767a808
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 7, 2023
5c9f16f
Merge branch 'main' into update_snmp_traps
roverflow Sep 7, 2023
c2e875c
Put the function handle_deprecates inside the class
earendilfr Sep 12, 2023
dd6cc80
Take in count that fan param is replaced by fan_enable
earendilfr Sep 14, 2023
18990f7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 14, 2023
d799f5f
Merge branch 'main' into update_snmp_traps
roverflow Sep 18, 2023
97c139f
Merge branch 'main' into update_snmp_traps
roverflow Oct 3, 2023
5e3fd6d
removed --- in doc
roverflow Oct 4, 2023
fa419da
Merge branch 'main' into update_snmp_traps
KB-perByte Oct 5, 2023
769955a
Merge branch 'main' into update_snmp_traps
roverflow Oct 6, 2023
4f91509
Merge branch 'main' into update_snmp_traps
KB-perByte Oct 6, 2023
a310544
Merge branch 'main' into update_snmp_traps
roverflow Oct 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
earendilfr marked this conversation as resolved.
Show resolved Hide resolved
"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
Loading