Skip to content

Commit

Permalink
fix port-security-bug in nxos (#906)
Browse files Browse the repository at this point in the history
* fix port-security-bug

* added unit tests for port-security

* chore: auto fixes from pre-commit.com hooks

* added changelog

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
AAYUSH2091 and pre-commit-ci[bot] authored Nov 19, 2024
1 parent bb24db3 commit 3dd130a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/nxos_feature.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- Fixed the invalid feature name error for port-security by updating the feature mapping from `eth_port_sec` to `eth-port-sec`.
4 changes: 2 additions & 2 deletions plugins/modules/nxos_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def validate_feature(module, mode="show"):
"tacacs+": "tacacs",
"telnet": "telnetServer",
"ethernet-link-oam": "elo",
"port-security": "eth_port_sec",
"port-security": "eth-port-sec",
},
"config": {
"nve": "nv overlay",
Expand All @@ -249,7 +249,7 @@ def validate_feature(module, mode="show"):
"tacacs": "tacacs+",
"telnetServer": "telnet",
"elo": "ethernet-link-oam",
"eth_port_sec": "port-security",
"eth-port-sec": "port-security",
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ Feature Name Instance State
-------------------- -------- -----
nve 1 disabled
ospf 1 enabled
eth-port-sec 1 enabled
10 changes: 10 additions & 0 deletions tests/unit/modules/network/nxos/test_nxos_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ def test_nxos_feature_disable(self):
result = self.execute_module(changed=True)
self.assertEqual(result["commands"], ["terminal dont-ask", "no feature ospf"])

def test_nxos_feature_port_security_disable(self):
set_module_args(dict(feature="port-security", state="disabled"))
result = self.execute_module(changed=True)
self.assertEqual(result["commands"], ["terminal dont-ask", "no feature port-security"])


class TestNxosFeatureModuleMDS(TestNxosModule):
module = nxos_feature
Expand Down Expand Up @@ -171,3 +176,8 @@ def test_nxos_feature_disable_already_disabled(self):
set_module_args(dict(feature="sftp-server", state="disabled"))
result = self.execute_module(changed=False)
self.assertEqual(result["commands"], [])

def test_nxos_feature_port_security_enable(self):
set_module_args(dict(feature="port-security", state="enabled"))
result = self.execute_module(changed=True)
self.assertEqual(result["commands"], ["terminal dont-ask", "feature port-security"])

0 comments on commit 3dd130a

Please sign in to comment.