예제 #1
0
 def test_ironware_command_match_all(self):
     wait_for = [
         'result[0] contains "IronWare"', 'result[0] contains "uptime is"'
     ]
     set_module_args(
         dict(commands=['show version'], wait_for=wait_for, match='all'))
     self.execute_module()
 def test_ironware_config_save_always(self):
     self.run_commands.return_value = "hostname foobar"
     set_module_args(dict(save_when='always'))
     self.execute_module(changed=True)
     self.assertEqual(self.run_commands.call_count, 1)
     self.assertEqual(self.get_config.call_count, 1)
     self.assertEqual(self.load_config.call_count, 0)
예제 #3
0
 def test_ironware_facts_gather_subset_config(self):
     set_module_args({'gather_subset': 'config'})
     result = self.execute_module()
     ansible_facts = result['ansible_facts']
     self.assertIn('default', ansible_facts['ansible_net_gather_subset'])
     self.assertIn('config', ansible_facts['ansible_net_gather_subset'])
     self.assertIn('ansible_net_config', ansible_facts)
예제 #4
0
 def test_ironware_command_match_all_failure(self):
     wait_for = [
         'result[0] contains "IronWare"', '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_ironware_config_match_exact(self):
     lines = [
         'ip address 1.2.3.4 255.255.255.0', 'port-name test string',
         'disable'
     ]
     parents = ['interface ethernet 1/1']
     set_module_args(dict(lines=lines, parents=parents, match='exact'))
     updates = parents + lines
     self.execute_module(changed=True, updates=updates, sort=False)
예제 #6
0
 def test_ironware_facts_gather_subset_mpls(self):
     set_module_args({'gather_subset': 'mpls'})
     result = self.execute_module()
     ansible_facts = result['ansible_facts']
     self.assertIn('default', ansible_facts['ansible_net_gather_subset'])
     self.assertIn('mpls', ansible_facts['ansible_net_gather_subset'])
     self.assertIn('ansible_net_mpls_lsps', ansible_facts)
     self.assertIn('ansible_net_mpls_vll', ansible_facts)
     self.assertIn('ansible_net_mpls_vll_local', ansible_facts)
     self.assertIn('ansible_net_mpls_vpls', ansible_facts)
     self.assertIn('LSP1', ansible_facts['ansible_net_mpls_lsps'].keys())
     self.assertIn('TEST-VLL', ansible_facts['ansible_net_mpls_vll'].keys())
     self.assertIn('TEST-LOCAL',
                   ansible_facts['ansible_net_mpls_vll_local'].keys())
     self.assertIn('TEST-VPLS',
                   ansible_facts['ansible_net_mpls_vpls'].keys())
예제 #7
0
 def test_ironware_facts_gather_subset_default(self):
     set_module_args(dict())
     result = self.execute_module()
     ansible_facts = result['ansible_facts']
     self.assertIn('hardware', ansible_facts['ansible_net_gather_subset'])
     self.assertIn('default', ansible_facts['ansible_net_gather_subset'])
     self.assertIn('interfaces', ansible_facts['ansible_net_gather_subset'])
     self.assertEqual(['/flash/'], ansible_facts['ansible_net_filesystems'])
     self.assertIn('1/1', ansible_facts['ansible_net_interfaces'].keys())
     self.assertIn('10.69.1.6',
                   ansible_facts['ansible_net_all_ipv4_addresses'])
     self.assertIn('2001:db8::1',
                   ansible_facts['ansible_net_all_ipv6_addresses'])
     self.assertIn('ansible_net_neighbors', ansible_facts)
     self.assertIn('1/2', ansible_facts['ansible_net_neighbors'].keys())
     self.assertEqual(4096, ansible_facts['ansible_net_memtotal_mb'])
     self.assertEqual(3630, ansible_facts['ansible_net_memfree_mb'])
     self.assertEqual('5.8.0fT163', ansible_facts['ansible_net_version'])
     self.assertEqual('MLXe 4-slot Chassis',
                      ansible_facts['ansible_net_model'])
     self.assertEqual('BGD2503J01F', ansible_facts['ansible_net_serialnum'])
예제 #8
0
 def test_ironware_command_wait_for(self):
     wait_for = 'result[0] contains "IronWare"'
     set_module_args(dict(commands=['show version'], wait_for=wait_for))
     self.execute_module()
예제 #9
0
 def test_ironware_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('System Mode: MLX'))
 def test_ironware_config_after(self):
     set_module_args(dict(lines=['hostname foo'], after=['test1', 'test2']))
     updates = ['hostname foo', 'test1', 'test2']
     self.execute_module(changed=True, updates=updates, sort=False)
 def test_ironware_config_lines_wo_parents(self):
     set_module_args(dict(lines=['hostname foobar']))
     updates = ['hostname foobar']
     self.execute_module(changed=True, updates=updates)
 def test_ironware_config_unchanged(self):
     src = load_fixture('ironware_config_config.cfg')
     set_module_args(dict(src=src))
     self.execute_module()
 def test_ironware_config_match_none(self):
     lines = ['hostname router']
     set_module_args(dict(lines=lines, match='none'))
     self.execute_module(changed=True, updates=lines)
 def test_ironware_config_replace_block(self):
     lines = ['port-name test string', 'test string']
     parents = ['interface ethernet 1/1']
     set_module_args(dict(lines=lines, replace='block', parents=parents))
     updates = parents + lines
     self.execute_module(changed=True, updates=updates)
 def test_ironware_config_config(self):
     config = 'hostname localhost'
     set_module_args(dict(lines=['hostname router'], config=config))
     updates = ['hostname router']
     self.execute_module(changed=True, updates=updates)
 def test_ironware_config_before_after_no_change(self):
     set_module_args(
         dict(lines=['hostname router'],
              before=['test1', 'test2'],
              after=['test3', 'test4']))
     self.execute_module()
예제 #17
0
 def test_ironware_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_ironware_config_backup(self):
     set_module_args(dict(backup=True))
     result = self.execute_module()
     self.assertIn('__backup__', result)
 def test_ironware_config_src(self):
     src = load_fixture('ironware_config_src.cfg')
     set_module_args(dict(src=src))
     updates = ['hostname foo', 'interface ethernet 1/1', 'no ip address']
     self.execute_module(changed=True, updates=updates)
 def test_ironware_config_lines_w_parents(self):
     set_module_args(
         dict(lines=['disable'], parents=['interface ethernet 1/1']))
     updates = ['interface ethernet 1/1', 'disable']
     self.execute_module(changed=True, updates=updates)