mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 04:40:22 -07:00
Add new module mlnxos_protocol for enabling disabling protocols on MLNX-OS Mellanox network devices (#34286)
* Add new module mlnxos_protocol for enabling disabling protocols on MLNX-OS Mellanox network devices Signed-off-by: Samer Deeb <samerd@mellanox.com> * Fix Test Class name * Fix IP routing protocol support Signed-off-by: Samer Deeb <samerd@mellanox.com> * Add missing support for check_mode, and Fix documentation Signed-off-by: Samer Deeb <samerd@mellanox.com>
This commit is contained in:
parent
943107b1b9
commit
ad73bda323
3 changed files with 345 additions and 0 deletions
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"pim": "disabled",
|
||||
"dhcp-relay": "disabled",
|
||||
"igmp-snooping": "disabled",
|
||||
"lacp": "disabled",
|
||||
"ptp": "disabled",
|
||||
"lldp": "disabled",
|
||||
"isolation-group": "disabled",
|
||||
"bfd": "disabled",
|
||||
"openflow": "disabled",
|
||||
"telemetry": "disabled",
|
||||
"vrrp": "disabled",
|
||||
"spanning-tree": "rst",
|
||||
"mlag": "disabled",
|
||||
"magp": "disabled",
|
||||
"nve": "disabled",
|
||||
"Ethernet": "enabled",
|
||||
"IP L3": "enabled",
|
||||
"ets": "enabled",
|
||||
"sflow": "disabled",
|
||||
"dhcp-relay(v6)": "disabled",
|
||||
"dot1x": "disabled",
|
||||
"bgp": "disabled",
|
||||
"priority-flow-control": "disabled",
|
||||
"ospf": "disabled"
|
||||
}
|
134
test/units/modules/network/mlnxos/test_mlnxos_protocols.py
Normal file
134
test/units/modules/network/mlnxos/test_mlnxos_protocols.py
Normal file
|
@ -0,0 +1,134 @@
|
|||
#
|
||||
# Copyright: Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
# Make coding more python3-ish
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.compat.tests.mock import patch
|
||||
from ansible.modules.network.mlnxos import mlnxos_protocol
|
||||
from units.modules.utils import set_module_args
|
||||
from .mlnxos_module import TestMlnxosModule, load_fixture
|
||||
|
||||
|
||||
class TestMlnxosProtocolModule(TestMlnxosModule):
|
||||
|
||||
module = mlnxos_protocol
|
||||
|
||||
def setUp(self):
|
||||
super(TestMlnxosProtocolModule, self).setUp()
|
||||
self.mock_get_config = patch.object(
|
||||
mlnxos_protocol.MlnxosProtocolModule,
|
||||
"_get_protocols")
|
||||
self.get_config = self.mock_get_config.start()
|
||||
|
||||
self.mock_get_ip_config = patch.object(
|
||||
mlnxos_protocol.MlnxosProtocolModule,
|
||||
"_get_ip_routing")
|
||||
self.get_ip_config = self.mock_get_ip_config.start()
|
||||
|
||||
self.mock_load_config = patch(
|
||||
'ansible.module_utils.network.mlnxos.mlnxos.load_config')
|
||||
self.load_config = self.mock_load_config.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestMlnxosProtocolModule, self).tearDown()
|
||||
self.mock_get_config.stop()
|
||||
self.mock_load_config.stop()
|
||||
|
||||
def load_fixtures(self, commands=None, transport='cli'):
|
||||
config_file = 'mlnxos_protocols_show.cfg'
|
||||
self.get_config.return_value = load_fixture(config_file)
|
||||
self.load_config.return_value = None
|
||||
self.get_ip_config.return_value = "IP routing: enabled"
|
||||
|
||||
def test_mlag_enable(self):
|
||||
set_module_args(dict(mlag='enabled'))
|
||||
commands = ['protocol mlag']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_mlag_disable(self):
|
||||
set_module_args(dict(mlag='disabled'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_magp_enable(self):
|
||||
set_module_args(dict(magp='enabled'))
|
||||
commands = ['protocol magp']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_magp_disable(self):
|
||||
set_module_args(dict(magp='disabled'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_spanning_tree_enable(self):
|
||||
set_module_args(dict(spanning_tree='enabled'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_spanning_tree_disable(self):
|
||||
set_module_args(dict(spanning_tree='disabled'))
|
||||
commands = ['no spanning-tree']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_dcb_pfc_enable(self):
|
||||
set_module_args(dict(dcb_pfc='enabled'))
|
||||
commands = ['dcb priority-flow-control enable force']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_dcb_pfc_disable(self):
|
||||
set_module_args(dict(dcb_pfc='disabled'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_igmp_snooping_enable(self):
|
||||
set_module_args(dict(igmp_snooping='enabled'))
|
||||
commands = ['ip igmp snooping']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_igmp_snooping_disable(self):
|
||||
set_module_args(dict(igmp_snooping='disabled'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_lacp_enable(self):
|
||||
set_module_args(dict(lacp='enabled'))
|
||||
commands = ['lacp']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_lacp_disable(self):
|
||||
set_module_args(dict(lacp='disabled'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_ip_routing_enable(self):
|
||||
set_module_args(dict(ip_routing='enabled'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_ip_routing_disable(self):
|
||||
set_module_args(dict(ip_routing='disabled'))
|
||||
commands = ['no ip routing']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_lldp_enable(self):
|
||||
set_module_args(dict(lldp='enabled'))
|
||||
commands = ['lldp']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_lldp_disable(self):
|
||||
set_module_args(dict(lldp='disabled'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_bgp_enable(self):
|
||||
set_module_args(dict(bgp='enabled'))
|
||||
commands = ['protocol bgp']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_bgp_disable(self):
|
||||
set_module_args(dict(bgp='disabled'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_ospf_enable(self):
|
||||
set_module_args(dict(ospf='enabled'))
|
||||
commands = ['protocol ospf']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_ospf_disable(self):
|
||||
set_module_args(dict(ospf='disabled'))
|
||||
self.execute_module(changed=False)
|
Loading…
Add table
Add a link
Reference in a new issue