Beispiel #1
0
    def test_check_dhcp_with_multiple_ifaces(self, make_listeners, send_discover, filtered_ifaces, *_):
        repeat = 1
        ifaces = ["eth1", "eth2"]

        filtered_ifaces.return_value = ifaces

        api.check_dhcp(ifaces, repeat=repeat)

        make_listeners.assert_called_once_with(("eth2", "eth1"))
        self.assertEqual(filtered_ifaces.call_count, repeat)
        self.assertEqual(send_discover.call_count, 2)
Beispiel #2
0
 def take_action(self, parsed_args):
     res = api.check_dhcp(parsed_args.ifaces,
                          timeout=parsed_args.timeout,
                          repeat=parsed_args.repeat)
     first = res.next()
     columns = first.keys()
     return columns, [first.values()] + [item.values() for item in res]
Beispiel #3
0
 def take_action(self, parsed_args):
     res = api.check_dhcp(parsed_args.ifaces,
                          timeout=parsed_args.timeout,
                          repeat=parsed_args.repeat)
     first = res.next()
     columns = first.keys()
     return columns, [first.values()] + [item.values() for item in res]
Beispiel #4
0
 def test_check_dhcp_with_multiple_ifaces(
         self, dhcp_on_eth_mock, utils_mock):
     dhcp_on_eth_mock.return_value = [expected_response]
     # issue with pickling mock
     dhcp_on_eth_mock.__class__ = mock.MagicMock
     utils_mock.filtered_ifaces.side_effect = lambda ifaces: ifaces
     response = api.check_dhcp(['eth1', 'eth2'])
     self.assertEqual(list(response), [expected_response])
Beispiel #5
0
 def take_action(self, parsed_args):
     LOG.info('Starting dhcp discover for {0}'.format(parsed_args.ifaces))
     res = api.check_dhcp(parsed_args.ifaces,
                          timeout=parsed_args.timeout,
                          repeat=parsed_args.repeat)
     first = res.next()
     columns = first.keys()
     return columns, [first.values()] + [item.values() for item in res]
Beispiel #6
0
 def take_action(self, parsed_args):
     LOG.info('Starting dhcp discover for {0}'.format(parsed_args.ifaces))
     res = api.check_dhcp(parsed_args.ifaces,
                          timeout=parsed_args.timeout,
                          repeat=parsed_args.repeat)
     first = res.next()
     columns = first.keys()
     return columns, [first.values()] + [item.values() for item in res]
Beispiel #7
0
 def take_action(self, parsed_args):
     LOG.info('Starting dhcp discover for {0}'.format(parsed_args.ifaces))
     res = list(api.check_dhcp(
         parsed_args.ifaces,
         timeout=parsed_args.timeout,
         repeat=parsed_args.repeat))
     #NOTE(dshulyak) unfortunately cliff doesnt allow to configure
     # PrettyTable output, see link:
     # https://github.com/dhellmann/cliff/blob/master/
     # cliff/formatters/table.py#L34
     # and in case i want always print empty table if nothing found
     # it is not possible by configuration
     if not res:
         res = [{}]
     return (utils.DHCP_OFFER_COLUMNS,
             [utils.get_item_properties(item, utils.DHCP_OFFER_COLUMNS)
              for item in res])
Beispiel #8
0
 def test_check_dhcp_with_multiple_ifaces(
         self, make_listeners, send_discover):
     api.check_dhcp(['eth1', 'eth2'], repeat=1)
     make_listeners.assert_called_once_with(('eth2', 'eth1'))
     self.assertEqual(send_discover.call_count, 2)
Beispiel #9
0
 def test_with_duplicated_with_repeat(self):
     ifaces = ['eth0', 'eth1', 'eth2']
     result = api.check_dhcp(ifaces, repeat=3)
     self.assertEqual(len(list(result)), 3)
Beispiel #10
0
 def test_with_no_ifaces(self):
     ifaces = None
     result = api.check_dhcp(ifaces, repeat=3)
     self.assertEqual(len(list(result)), 2)
Beispiel #11
0
 def test_with_duplicated_with_repeat(self):
     ifaces = ['eth1', 'eth2']
     result = api.check_dhcp(ifaces, repeat=3)
     self.assertEqual(len(list(result)), 2)
Beispiel #12
0
 def test_check_dhcp_with_multiple_ifaces(
         self, make_listeners, send_discover):
     api.check_dhcp(['eth1', 'eth2'])
     make_listeners.assert_called_once_with(('eth2', 'eth1'))
     self.assertEqual(send_discover.call_count, 2)
Beispiel #13
0
 def test_check_dhcp_with_no_ifaces(self, make_listeners, send_discover, interfaces, filtered_ifaces, *_):
     interfaces.return_value = ["eth1"]
     filtered_ifaces.return_value = ["eth1"]
     api.check_dhcp(None, timeout=1, repeat=2)
     make_listeners.assert_called_once_with(("eth1",))
     self.assertEqual(send_discover.call_count, 2)