mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
Convert nxos_vlan to DI module (#31866)
* Convert nxos_vlan to DI * fix conflict * push fix for qalthos's comment Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
This commit is contained in:
parent
8b15b93d01
commit
60f3649ebd
6 changed files with 483 additions and 243 deletions
|
@ -1,20 +0,0 @@
|
|||
{
|
||||
"TABLE_vlanbriefid": {
|
||||
"ROW_vlanbriefid": {
|
||||
"vlanshowbr-vlanid": 16777216,
|
||||
"vlanshowbr-vlanid-utf": 1,
|
||||
"vlanshowbr-vlanname": "default",
|
||||
"vlanshowbr-vlanstate": "active",
|
||||
"vlanshowbr-shutstate": "noshutdown"
|
||||
}
|
||||
},
|
||||
"TABLE_mtuinfoid": {
|
||||
"ROW_mtuinfoid": {
|
||||
"vlanshowinfo-vlanid": 1,
|
||||
"vlanshowinfo-media-type": "enet",
|
||||
"vlanshowinfo-vlanmode": "ce-vlan"
|
||||
}
|
||||
},
|
||||
"vlanshowrspan-vlantype": "notrspan",
|
||||
"is-vtp-manageable": "enabled"
|
||||
}
|
|
@ -42,10 +42,16 @@ class TestNxosVlanModule(TestNxosModule):
|
|||
self.mock_get_config = patch('ansible.modules.network.nxos.nxos_vlan.get_config')
|
||||
self.get_config = self.mock_get_config.start()
|
||||
|
||||
self.mock_get_capabilities = patch('ansible.modules.network.nxos.nxos_vlan.get_capabilities')
|
||||
self.get_capabilities = self.mock_get_capabilities.start()
|
||||
self.get_capabilities.return_value = {'network_api': 'cliconf'}
|
||||
|
||||
def tearDown(self):
|
||||
super(TestNxosVlanModule, self).tearDown()
|
||||
self.mock_run_commands.stop()
|
||||
self.mock_load_config.stop()
|
||||
self.mock_get_config.stop()
|
||||
self.mock_get_capabilities.stop()
|
||||
|
||||
def load_fixtures(self, commands=None, device=''):
|
||||
def load_from_file(*args, **kwargs):
|
||||
|
@ -64,11 +70,11 @@ class TestNxosVlanModule(TestNxosModule):
|
|||
|
||||
self.run_commands.side_effect = load_from_file
|
||||
self.load_config.return_value = None
|
||||
self.get_config.return_value = load_fixture('nxos_vlan', 'config.cfg')
|
||||
|
||||
def test_nxos_vlan_range(self):
|
||||
set_module_args(dict(vlan_range='6-10'))
|
||||
result = self.execute_module(changed=True)
|
||||
self.assertEqual(result['commands'], ['vlan 6', 'vlan 7', 'vlan 8', 'vlan 9', 'vlan 10'])
|
||||
self.execute_module(changed=True, commands=['vlan 6', 'vlan 7', 'vlan 8', 'vlan 9', 'vlan 10'])
|
||||
|
||||
def test_nxos_vlan_range_absent(self):
|
||||
set_module_args(dict(vlan_range='1-5', state='absent'))
|
||||
|
@ -78,7 +84,7 @@ class TestNxosVlanModule(TestNxosModule):
|
|||
def test_nxos_vlan_id(self):
|
||||
set_module_args(dict(vlan_id='15', state='present'))
|
||||
result = self.execute_module(changed=True)
|
||||
self.assertEqual(result['commands'], ['vlan 15', 'exit'])
|
||||
self.assertEqual(result['commands'], ['vlan 15', 'state active', 'no shutdown', 'exit'])
|
||||
|
||||
def test_nxos_vlan_id_absent(self):
|
||||
set_module_args(dict(vlan_id='1', state='absent'))
|
||||
|
@ -88,7 +94,7 @@ class TestNxosVlanModule(TestNxosModule):
|
|||
def test_nxos_vlan_named_vlan(self):
|
||||
set_module_args(dict(vlan_id='15', name='WEB'))
|
||||
result = self.execute_module(changed=True)
|
||||
self.assertEqual(result['commands'], ['vlan 15', 'name WEB', 'exit'])
|
||||
self.assertEqual(result['commands'], ['vlan 15', 'name WEB', 'state active', 'no shutdown', 'exit'])
|
||||
|
||||
def test_nxos_vlan_shut_down(self):
|
||||
set_module_args(dict(vlan_id='1', admin_state='down'))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue