From 54bab2c47e034223b7e26bfdb7755b5d225c1d25 Mon Sep 17 00:00:00 2001 From: dmccue Date: Thu, 23 Jul 2015 15:45:26 +0100 Subject: [PATCH] fixed issues with output format and order key --- contrib/inventory/cobbler.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/contrib/inventory/cobbler.py b/contrib/inventory/cobbler.py index 9c5be5feef2..433f9bab293 100755 --- a/contrib/inventory/cobbler.py +++ b/contrib/inventory/cobbler.py @@ -76,6 +76,8 @@ except ImportError: # server, so it does not attempt to login with a username and password. # this will be addressed in a future version of this script. +orderby_keyname = 'owners' # alternatively 'mgmt_classes' + class CobblerInventory(object): @@ -104,13 +106,12 @@ class CobblerInventory(object): # Data to print if self.args.host: - data_to_print = self.get_host_info() + data_to_print += self.get_host_info() else: self.inventory['_meta'] = { 'hostvars': {} } for hostname in self.cache: self.inventory['_meta']['hostvars'][hostname] = {'cobbler': self.cache[hostname] } - - data_to_print += self.json_format_dict(self.inventory, True) + data_to_print += self.json_format_dict(self.inventory, True) print data_to_print @@ -180,7 +181,7 @@ class CobblerInventory(object): status = host['status'] profile = host['profile'] - classes = host['owners'] #host['mgmt_classes'] + classes = host[orderby_keyname] #host['mgmt_classes'] if status not in self.inventory: self.inventory[status] = []