mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
Add new module mlnxos_mlag_ipl for managing IPL (inter-peer link) (#34326)
Signed-off-by: Samer Deeb <samerd@mellanox.com>
This commit is contained in:
parent
18e41ca4d9
commit
52bea8dab6
3 changed files with 325 additions and 0 deletions
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"Reload-delay": "30 sec",
|
||||
"Upgrade-timeout": "60 min",
|
||||
"System-mac": "00:00:5E:00:01:4E [Mismatched]",
|
||||
"Admin status": "Disabled",
|
||||
"MLAG Ports Status Summary": {
|
||||
"Active-partial": "0",
|
||||
"Inactive": "0",
|
||||
"Active-full": "0"
|
||||
},
|
||||
"MLAG IPLs Summary": {
|
||||
"1": [
|
||||
{
|
||||
"Local IP address": "10.2.2.3",
|
||||
"Peer IP address": "10.2.2.2",
|
||||
"Operational State": "Down",
|
||||
"Vlan Interface": "1002",
|
||||
"Group Port-Channel": "Po1"
|
||||
}
|
||||
]
|
||||
},
|
||||
"Keepalive-interval": "1 sec",
|
||||
"MLAG Ports Configuration Summary": {
|
||||
"Disabled": "0",
|
||||
"Configured": "0",
|
||||
"Enabled": "0"
|
||||
},
|
||||
"Operational status": "Down"
|
||||
}
|
86
test/units/modules/network/mlnxos/test_mlnxos_mlag_ipl.py
Normal file
86
test/units/modules/network/mlnxos/test_mlnxos_mlag_ipl.py
Normal file
|
@ -0,0 +1,86 @@
|
|||
#
|
||||
# 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_mlag_ipl
|
||||
from units.modules.utils import set_module_args
|
||||
from .mlnxos_module import TestMlnxosModule, load_fixture
|
||||
|
||||
|
||||
class TestMlnxosMlagIplModule(TestMlnxosModule):
|
||||
|
||||
module = mlnxos_mlag_ipl
|
||||
|
||||
def setUp(self):
|
||||
super(TestMlnxosMlagIplModule, self).setUp()
|
||||
self._mlag_enabled = True
|
||||
self.mock_get_config = patch.object(
|
||||
mlnxos_mlag_ipl.MlnxosMlagIplModule,
|
||||
"_show_mlag_data")
|
||||
self.get_config = self.mock_get_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(TestMlnxosMlagIplModule, self).tearDown()
|
||||
self.mock_get_config.stop()
|
||||
self.mock_load_config.stop()
|
||||
|
||||
def load_fixtures(self, commands=None, transport='cli'):
|
||||
if self._mlag_enabled:
|
||||
config_file = 'mlnxos_mlag_ipl_show.cfg'
|
||||
self.get_config.return_value = load_fixture(config_file)
|
||||
else:
|
||||
self.get_config.return_value = None
|
||||
self.load_config.return_value = None
|
||||
|
||||
def test_no_ipl_no_change(self):
|
||||
self._mlag_enabled = False
|
||||
set_module_args(dict(name="Po1", state='absent'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_ipl_no_change(self):
|
||||
self._mlag_enabled = True
|
||||
set_module_args(dict(name="Po1", state='present',
|
||||
vlan_interface='Vlan 1002',
|
||||
peer_address='10.2.2.2'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_ipl_add(self):
|
||||
self._mlag_enabled = False
|
||||
set_module_args(dict(name="Po1", state='present',
|
||||
vlan_interface='Vlan 1002',
|
||||
peer_address='10.2.2.2'))
|
||||
commands = ['interface port-channel 1 ipl 1',
|
||||
'interface vlan 1002 ipl 1 peer-address 10.2.2.2']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_ipl_add_peer(self):
|
||||
self._mlag_enabled = True
|
||||
set_module_args(dict(name="Po1", state='present',
|
||||
vlan_interface='Vlan 1002',
|
||||
peer_address='10.2.2.4'))
|
||||
commands = ['interface vlan 1002 ipl 1 peer-address 10.2.2.4']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_ipl_remove(self):
|
||||
self._mlag_enabled = True
|
||||
set_module_args(dict(name="Po1", state='absent'))
|
||||
commands = ['interface port-channel 1 no ipl 1']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_ipl_change_vlan(self):
|
||||
self._mlag_enabled = True
|
||||
set_module_args(dict(name="Po1", state='present',
|
||||
vlan_interface='Vlan 1003',
|
||||
peer_address='10.2.2.4'))
|
||||
commands = ['interface vlan 1002 no ipl 1',
|
||||
'interface vlan 1003 ipl 1 peer-address 10.2.2.4']
|
||||
self.execute_module(changed=True, commands=commands)
|
Loading…
Add table
Add a link
Reference in a new issue