Browse Source

Fix command output to not fail if there is no dhcp servers

Change-Id: I7ab57f0a7f64cbe324fbe780efd86a62a8a55749
Closes-Bug: #1585969
slava 2 years ago
parent
commit
c318b889d5
1 changed files with 8 additions and 6 deletions
  1. 8
    6
      dhcp_checker/commands.py

+ 8
- 6
dhcp_checker/commands.py View File

@@ -105,9 +105,11 @@ class DhcpWithVlansCheck(lister.Lister, BaseCommand):
105 105
         return parser
106 106
 
107 107
     def take_action(self, parsed_args):
108
-        res = api.check_dhcp_with_vlans(json.loads(parsed_args.config),
109
-                                        timeout=parsed_args.timeout,
110
-                                        repeat=parsed_args.repeat)
111
-        first = res.next()
112
-        columns = first.keys()
113
-        return columns, [first.values()] + [item.values() for item in res]
108
+        res = list(api.check_dhcp_with_vlans(json.loads(parsed_args.config),
109
+                                             timeout=parsed_args.timeout,
110
+                                             repeat=parsed_args.repeat))
111
+        if not res:
112
+            res = [{}]
113
+        return (utils.DHCP_OFFER_COLUMNS,
114
+                [utils.get_item_properties(item, utils.DHCP_OFFER_COLUMNS)
115
+                 for item in res])

Loading…
Cancel
Save