Lenovo cli bugfixes (#45278)

* To change all CLIs present in the code to latest CNOS CLI. One bug of executing with Lenovo Jakku switch is also getting fixed.

* To change the file names as the commands have changed from display to show

* To change to new CLI in test_cnos_comand.py as well
This commit is contained in:
Anil Kumar Muraleedharan
2018-09-12 20:01:45 +05:30
committed by Nathaniel Case
parent cbf2c2a000
commit ac58c36ad0
16 changed files with 51 additions and 43 deletions

View File

@@ -2,14 +2,11 @@
vlan {{item.vlanid1}}
name anil
exit
#config d
interface ethernet {{item.slot_chassis_number1}}
#aggregation-group {{item.portchannel_interface_number1}} mode {{item.portchannel_mode1}}
description anil
mtu 600
exit
#config d
interface port-aggregation {{item.portchannel_interface_number1}}
interface port-channel {{item.portchannel_interface_number1}}
shut
lacp suspend-individual
no shut

View File

@@ -1,4 +1,4 @@
vlan 33
name panil
name sunil
flood ipv4
state active

View File

@@ -2,14 +2,11 @@
vlan {{item.vlanid1}}
name anil
exit
#config d
interface ethernet {{item.slot_chassis_number1}}
#aggregation-group {{item.portchannel_interface_number1}} mode {{item.portchannel_mode1}}
description anil
mtu 600
exit
#config d
interface port-aggregation {{item.portchannel_interface_number1}}
interface port-channel {{item.portchannel_interface_number1}}
shut
lacp suspend-individual
no shut

View File

@@ -50,7 +50,7 @@ class TestCnosCommandModule(TestCnosModule):
try:
command = item
except ValueError:
command = 'display version'
command = 'show version'
filename = str(command).replace(' ', '_')
output.append(load_fixture(filename))
return output
@@ -58,49 +58,49 @@ class TestCnosCommandModule(TestCnosModule):
self.run_commands.side_effect = load_from_file
def test_cnos_command_simple(self):
set_module_args(dict(commands=['display version']))
set_module_args(dict(commands=['show version']))
result = self.execute_module()
self.assertEqual(len(result['stdout']), 1)
self.assertTrue(result['stdout'][0].startswith('Lenovo Networking Operating System (NOS) Software'))
def test_cnos_command_multiple(self):
set_module_args(dict(commands=['display version', 'display running-config']))
set_module_args(dict(commands=['show version', 'show running-config']))
result = self.execute_module()
self.assertEqual(len(result['stdout']), 2)
self.assertTrue(result['stdout'][0].startswith('Lenovo Networking Operating System (NOS) Software'))
def test_cnos_command_wait_for(self):
wait_for = 'result[0] contains "Lenovo Networking Operating System (NOS) Software"'
set_module_args(dict(commands=['display version'], wait_for=wait_for))
set_module_args(dict(commands=['show version'], wait_for=wait_for))
self.execute_module()
def test_cnos_command_wait_for_fails(self):
wait_for = 'result[0] contains "test string"'
set_module_args(dict(commands=['display version'], wait_for=wait_for))
set_module_args(dict(commands=['show version'], wait_for=wait_for))
self.execute_module(failed=True)
self.assertEqual(self.run_commands.call_count, 10)
def test_cnos_command_retries(self):
wait_for = 'result[0] contains "test string"'
set_module_args(dict(commands=['display version'], wait_for=wait_for, retries=2))
set_module_args(dict(commands=['show version'], wait_for=wait_for, retries=2))
self.execute_module(failed=True)
self.assertEqual(self.run_commands.call_count, 2)
def test_cnos_command_match_any(self):
wait_for = ['result[0] contains "Lenovo Networking Operating System (NOS) Software"',
'result[0] contains "test string"']
set_module_args(dict(commands=['display version'], wait_for=wait_for, match='any'))
set_module_args(dict(commands=['show version'], wait_for=wait_for, match='any'))
self.execute_module()
def test_cnos_command_match_all(self):
wait_for = ['result[0] contains "Lenovo Networking Operating System (NOS) Software"',
'result[0] contains "Lenovo"']
set_module_args(dict(commands=['display version'], wait_for=wait_for, match='all'))
set_module_args(dict(commands=['show version'], wait_for=wait_for, match='all'))
self.execute_module()
def test_cnos_command_match_all_failure(self):
wait_for = ['result[0] contains "Lenovo ENOS"',
'result[0] contains "test string"']
commands = ['display version', 'display run']
commands = ['show version', 'show run']
set_module_args(dict(commands=commands, wait_for=wait_for, match='all'))
self.execute_module(failed=True)