Пример #1
0
 def test_check_dhcp_with_vlans(self, make_listeners, send_discover):
     config_sample = {
         'eth0': (100, 101),
         'eth1': (100, 102)
     }
     api.check_dhcp_with_vlans(config_sample, timeout=1)
     make_listeners.assert_called_once_with(('eth1', 'eth0'))
     self.assertEqual(send_discover.call_count, 6)
Пример #2
0
 def test_check_dhcp_with_vlans(self, make_listeners, send_discover):
     config_sample = {
         'eth0': (100, 101),
         'eth1': (100, 102)
     }
     api.check_dhcp_with_vlans(config_sample, timeout=1)
     make_listeners.assert_called_once_with(('eth1', 'eth0'))
     self.assertEqual(send_discover.call_count, 2)
Пример #3
0
 def test_check_dhcp_with_vlans_repeat_2(self, make_listeners,
                                         send_discover, sleep_mock):
     config_sample = {
         'eth0': (),
     }
     api.check_dhcp_with_vlans(config_sample, timeout=1, repeat=3)
     self.assertEqual(sleep_mock.call_count, 3)
     make_listeners.assert_called_once_with(('eth0',))
     self.assertEqual(send_discover.call_count, 3)
Пример #4
0
 def test_check_dhcp_with_vlans(self, check_dhcp):
     config_sample = {
         'eth0': (100, 101),
         'eth1': (100, 102)
     }
     api.check_dhcp_with_vlans(config_sample)
     check_dhcp.assert_called_once_with(
         ['eth1', 'eth1.100', 'eth1.102', 'eth0', 'eth0.100', 'eth0.101'],
         repeat=2, timeout=5)
Пример #5
0
 def test_check_dhcp_with_vlans_repeat_2(self, make_listeners,
                                         send_discover, sleep_mock):
     config_sample = {
         'eth0': (),
     }
     api.check_dhcp_with_vlans(config_sample, timeout=1, repeat=3)
     self.assertEqual(sleep_mock.call_count, 3)
     make_listeners.assert_called_once_with(('eth0', ))
     self.assertEqual(send_discover.call_count, 3)
Пример #6
0
 def take_action(self, parsed_args):
     res = api.check_dhcp_with_vlans(json.loads(parsed_args.config),
                                     timeout=parsed_args.timeout,
                                     repeat=parsed_args.repeat)
     first = res.next()
     columns = first.keys()
     return columns, [first.values()] + [item.values() for item in res]
Пример #7
0
 def take_action(self, parsed_args):
     res = api.check_dhcp_with_vlans(json.loads(parsed_args.config),
                                     timeout=parsed_args.timeout,
                                     repeat=parsed_args.repeat)
     first = res.next()
     columns = first.keys()
     return columns, [first.values()] + [item.values() for item in res]
Пример #8
0
 def test_with_vlans(self):
     config = {
         'eth0': (100, 101),
         'eth1': (103, 105),
         'eth2': range(106, 120)
     }
     result = api.check_dhcp_with_vlans(config)
     self.assertEqual(len(list(result)), 3)
Пример #9
0
 def take_action(self, parsed_args):
     res = list(api.check_dhcp_with_vlans(json.loads(parsed_args.config),
                                          timeout=parsed_args.timeout,
                                          repeat=parsed_args.repeat,
                                          w_vlans=parsed_args.with_vlans))
     if not res:
         res = [{}]
     return (utils.DHCP_OFFER_COLUMNS,
             [utils.get_item_properties(item, utils.DHCP_OFFER_COLUMNS)
              for item in res])
Пример #10
0
 def test_with_vlans(self):
     config = {'eth0': (100, 101), 'eth1': (103, 105),
               'eth2': range(106, 120)}
     result = api.check_dhcp_with_vlans(config)
     self.assertEqual(len(list(result)), 3)
Пример #11
0
 def test_check_dhcp_wo_vlans(self, make_listeners, send_discover, *_):
     api.check_dhcp_with_vlans(self.config_sample, timeout=1, repeat=1, w_vlans=False)
     make_listeners.assert_called_once_with(("eth1", "eth0"))
     self.assertEqual(send_discover.call_count, 2)