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])
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])
def test_order_preserver(self): example = {'first': 'first', 'second': 'second'} columns = ['second', 'first'] items = utils.get_item_properties(example, columns) self.assertEqual(columns, items)