From d180e0e05ff52d03aa6c758e35b4111a2cdd3ac9 Mon Sep 17 00:00:00 2001 From: Andre Keedy Date: Mon, 14 Mar 2016 16:26:52 -0400 Subject: [PATCH] Bug Fix -Corrected the format in case of multiple hosts Remove empty spaces --- contrib/inventory/rackhd.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/contrib/inventory/rackhd.py b/contrib/inventory/rackhd.py index e7db24d3204..92abc4d6a67 100755 --- a/contrib/inventory/rackhd.py +++ b/contrib/inventory/rackhd.py @@ -13,8 +13,10 @@ class RackhdInventory(object): self._inventory = {} for nodeid in nodeids: self._load_inventory_data(nodeid) + inventory = {} for nodeid,info in self._inventory.iteritems(): - print(json.dumps(self._format_output(nodeid, info))) + inventory[nodeid]= (self._format_output(nodeid, info)) + print(json.dumps(inventory)) def _load_inventory_data(self, nodeid): info = {} @@ -33,10 +35,10 @@ class RackhdInventory(object): ipaddress = '' if len(node_info) > 0: ipaddress = node_info[0]['ipAddress'] - output = {nodeid:{ 'hosts':[ipaddress],'vars':{}}} + output = { 'hosts':[ipaddress],'vars':{}} for key,result in info.iteritems(): - output[nodeid]['vars'][key] = json.loads(result) - output[nodeid]['vars']['ansible_ssh_user'] = 'monorail' + output['vars'][key] = json.loads(result) + output['vars']['ansible_ssh_user'] = 'monorail' except KeyError: pass return output