Exemplo n.º 1
0
 def test_eos_banner_remove_with_eapi_transport(self):
     set_module_args(dict(banner='login', state='absent', provider=EAPI))
     commands = ['no banner login']
     self.execute_module(changed=True, commands=commands, transport='eapi')
 def test_eos_l3_interfaces_replaced(self):
     set_module_args(
         dict(config=dict(system=dict(priority=20)), state="replaced"))
     commands = ['lacp system-priority 20']
     self.execute_module(changed=True, commands=commands)
 def test_eos_l3_interfaces_deleted(self):
     set_module_args(dict(state="deleted"))
     commands = ['no lacp system-priority']
     self.execute_module(changed=True, commands=commands)
Exemplo n.º 4
0
 def test_eos_interfaces_merged(self):
     set_module_args(
         dict(config=[dict(name="Ethernet3", description="Ethernet_3")],
              state="merged"))
     commands = ['interface Ethernet3', 'description Ethernet_3']
     self.execute_module(changed=True, commands=commands)
 def test_eos_lacp_default_idempotent(self):
     set_module_args(dict(config=dict(system=dict(priority=10))))
     self.execute_module(changed=False, commands=[])
 def test_eos_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_eos_command_match_all(self):
     wait_for = ['result[0] contains "Arista"',
                 'result[0] contains "Software image"']
     set_module_args(dict(commands=['show version'], wait_for=wait_for, match='all'))
     self.execute_module()
 def test_eos_hostname_deleted(self):
     set_module_args(dict(state="deleted"))
     self.execute_module(changed=True, commands=["no hostname eos_test"])
 def test_eos_hostname_gathered(self):
     set_module_args(dict(state="gathered"))
     result = self.execute_module(changed=False,
                                  filename="eos_hostname_config.cfg")
     gathered_list = {"hostname": "eos_test"}
     self.assertEqual(sorted(gathered_list), sorted(result["gathered"]))
 def test_eos_hostname_replaced(self):
     set_module_args(dict(config=dict(hostname="eos"), state="replaced"))
     self.execute_module(changed=True, commands=["hostname eos"])
 def test_eos_hostname_overridden(self):
     set_module_args(dict(config=dict(hostname="eos"), state="overridden"))
 def test_eos_hostname_overridden_idempotent(self):
     set_module_args(
         dict(config=dict(hostname="eos_test"), state="overridden"))
     self.execute_module(changed=False, commands=[])
 def test_eos_hostname_merged_idempotent(self):
     set_module_args(dict(config=dict(hostname="eos_test")))
     self.execute_module(changed=False, commands=[])
Exemplo n.º 14
0
 def test_eos_banner_nochange_with_eapi_transport(self):
     banner_text = load_fixture('eos_banner_show_banner.txt').strip()
     set_module_args(dict(banner='login', text=banner_text, provider=EAPI))
     self.execute_module(transport='eapi')
 def test_eos_command_match_all_failure(self):
     wait_for = ['result[0] contains "Arista"',
                 'result[0] contains "test string"']
     commands = ['show version', 'show version']
     set_module_args(dict(commands=commands, wait_for=wait_for, match='all'))
     self.execute_module(failed=True)
 def test_eos_hostname_parsed(self):
     parsed_str = "hostname eos_test"
     set_module_args(dict(running_config=parsed_str, state="parsed"))
     result = self.execute_module(changed=False)
     parsed_list = {"hostname": "eos_test"}
     self.assertEqual(sorted(parsed_list), sorted(result["parsed"]))
 def test_eos_command_wait_for(self):
     wait_for = 'result[0] contains "Arista vEOS"'
     set_module_args(dict(commands=['show version'], wait_for=wait_for))
     self.execute_module()
Exemplo n.º 18
0
 def test_eos_config_src_and_lines_fails(self):
     args = dict(src='foo', lines='foo')
     set_module_args(args)
     self.execute_module(failed=True)
 def test_eos_command_match_any(self):
     wait_for = ['result[0] contains "Arista"',
                 'result[0] contains "test string"']
     set_module_args(dict(commands=['show version'], wait_for=wait_for, match='any'))
     self.execute_module()
Exemplo n.º 20
0
 def test_eos_config_match_strict_requires_lines(self):
     args = dict(match='strict')
     set_module_args(args)
     self.execute_module(failed=True)
Exemplo n.º 21
0
 def test_eos_interfaces_delete(self):
     set_module_args(
         dict(config=[dict(name="Ethernet1", )], state="deleted"))
     commands = ['interface Ethernet1', 'no description', 'no shutdown']
     self.execute_module(changed=True, commands=commands)
Exemplo n.º 22
0
 def test_eos_config_replace_block_requires_lines(self):
     args = dict(replace='block')
     set_module_args(args)
     self.execute_module(failed=True)
Exemplo n.º 23
0
 def test_eos_interfaces_merged_idempotent(self):
     set_module_args(
         dict(config=[dict(name="Ethernet1", description="Interface 1")],
              state="merged"))
     self.execute_module(changed=False, commands=[])
Exemplo n.º 24
0
 def test_eos_config_replace_config_requires_src(self):
     args = dict(replace='config')
     set_module_args(args)
     self.execute_module(failed=True)
 def test_eos_lacp_merged(self):
     set_module_args(
         dict(config=dict(system=dict(priority=50)), state="merged"))
     commands = ['lacp system-priority 50']
     self.execute_module(changed=True, commands=commands)
Exemplo n.º 26
0
 def test_eos_config_backup_returns__backup__(self):
     args = dict(backup=True)
     set_module_args(args)
     result = self.execute_module()
     self.assertIn('__backup__', result)
 def test_eos_l3_interfaces_replaced_idempotent(self):
     set_module_args(
         dict(config=dict(system=dict(priority=10)), state="replaced"))
     self.execute_module(changed=False, commands=[])
Exemplo n.º 28
0
 def test_eos_config_save_changed_false(self):
     set_module_args(dict(save_when='changed'))
     self.execute_module(changed=False)
     self.assertEqual(self.run_commands.call_count, 0)
     self.assertEqual(self.get_config.call_count, 0)
     self.assertEqual(self.load_config.call_count, 0)
Exemplo n.º 29
0
 def test_eos_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('Arista'))
Exemplo n.º 30
0
 def test_eos_banner_create_with_cli_transport(self):
     set_module_args(
         dict(banner='login', text='test\nbanner\nstring', provider=CLI))
     commands = ['banner login', 'test', 'banner', 'string', 'EOF']
     self.execute_module(changed=True, commands=commands)