def test_aireos_config_backup(self): set_module_args(dict(backup=True)) result = self.execute_module() self.assertIn('__backup__', result)
def test_ospf_enable(self): set_module_args(dict(ospf='enabled')) commands = ['protocol ospf'] self.execute_module(changed=True, commands=commands)
def test_nve_enable(self): set_module_args(dict(nve='enabled')) commands = ['protocol nve'] self.execute_module(changed=True, commands=commands)
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_bgp_enable(self): set_module_args(dict(bgp='enabled')) commands = ['protocol bgp'] self.execute_module(changed=True, commands=commands)
def test_vni_vlan_list_with_change(self): set_module_args(dict(nve_id=1, loopback_id=1, bgp=True, mlag_tunnel_ip='192.10.10.1', vni_vlan_list=[dict(vlan_id=11, vni_id=10011), dict(vlan_id=7, vni_id=10061)], arp_suppression=False)) commands = ["interface nve 1 nve vni 10011 vlan 11", "interface nve 1 nve vni 10061 vlan 7"] self.execute_module(changed=True, commands=commands)
def test_exos_command_wait_for(self): wait_for = 'result[0] contains "Switch :"' set_module_args(dict(commands=['show version'], wait_for=wait_for)) self.execute_module()
def test_enos_command_wait_for(self): wait_for = 'result[0] contains "System Information"' set_module_args(dict(commands=['show version'], wait_for=wait_for)) self.execute_module()
def test_vlan_no_change(self): set_module_args(dict(vlan_id=20)) self.execute_module(changed=False)
def test_openvswitch_port_absent_idempotent(self): set_module_args(dict(state='absent', bridge='test-br', port='eth2')) self.execute_module( test_name='test_openvswitch_port_absent_idempotent')
def test_enos_command_simple(self): set_module_args(dict(commands=['show version'])) result = self.execute_module() self.assertEqual(len(result['stdout']), 1) self.assertTrue(result['stdout'][0].startswith('System Information'))
def test_without_required_parameters(self): """Failure must occurs when all parameters are missing.""" with self.assertRaises(AnsibleFailJson): set_module_args({}) self.module.main()
def test_aireos_config_after(self): set_module_args(dict(lines=['sysname foo'], after=['test1', 'test2'])) commands = ['sysname foo', 'test1', 'test2'] self.execute_module(changed=True, commands=commands, sort=False)
def test_aireos_config_save(self): set_module_args(dict(save=True)) self.execute_module() self.assertEqual(self.save_config.call_count, 1) self.assertEqual(self.get_config.call_count, 0) self.assertEqual(self.load_config.call_count, 0)
def test_configure_vxlan_no_change(self): set_module_args(dict(nve_id=1, loopback_id=1, bgp=True, mlag_tunnel_ip='192.10.10.1', vni_vlan_list=[dict(vlan_id=10, vni_id=10010), dict(vlan_id=6, vni_id=10060)], arp_suppression=True)) self.execute_module(changed=False)
def test_vlan_remove_name(self): set_module_args(dict(vlan_id=10, name='')) commands = ['vlan 10 no name'] self.execute_module(changed=True, commands=commands)
def test_mlag_tunnel_ip_with_change(self): set_module_args(dict(nve_id=1, loopback_id=1, bgp=True, mlag_tunnel_ip='192.10.10.10', vni_vlan_list=[dict(vlan_id=10, vni_id=10010), dict(vlan_id=6, vni_id=10060)], arp_suppression=True)) commands = ["interface nve 1 vxlan mlag-tunnel-ip 192.10.10.10"] self.execute_module(changed=True, commands=commands)
def test_vlan_change_name(self): set_module_args(dict(vlan_id=10, name='test-test')) commands = ['vlan 10 name test-test'] self.execute_module(changed=True, commands=commands)
def test_exos_command_multiple(self): set_module_args(dict(commands=['show version', 'show version'])) result = self.execute_module() self.assertEqual(len(result['stdout']), 2) self.assertTrue(result['stdout'][0].startswith('Switch :'))
def test_vlan_create(self): set_module_args(dict(vlan_id=30)) commands = ['vlan 30', 'exit'] self.execute_module(changed=True, commands=commands)
def test_exos_command_retries(self): wait_for = 'result[0] contains "test string"' 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_vlan_create_with_name(self): set_module_args(dict(vlan_id=30, name='test-test')) commands = ['vlan 30', 'exit', 'vlan 30 name test-test'] 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_vlan_remove(self): set_module_args(dict(vlan_id=20, state='absent')) commands = ['no vlan 20'] 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_vlan_remove_not_exist(self): set_module_args(dict(vlan_id=30, state='absent')) self.execute_module(changed=False)
def test_ospf_disable(self): set_module_args(dict(ospf='disabled')) self.execute_module(changed=False)
def _set_args(self, **kwargs): module_args = self.REQUIRED_PARAMS.copy() if kwargs is not None: module_args.update(kwargs) set_module_args(module_args)
def test_nve_disabled(self): set_module_args(dict(nve='disabled')) self.execute_module(changed=False)
def test_aireos_config_unchanged(self): src = load_fixture('aireos_config_config.cfg') set_module_args(dict(src=src)) self.execute_module()