From a5c41dcd49588447ab063b0d14ca1f7efac4b798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Kar=C3=A1sek?= Date: Tue, 18 Jul 2017 16:31:42 +0300 Subject: [PATCH] Add grouping by hostname for the Packet inventory (#21069) * Add grouping by hostname for the Packet inventory * remove space after eol --- contrib/inventory/packet_net.ini | 1 + contrib/inventory/packet_net.py | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/contrib/inventory/packet_net.ini b/contrib/inventory/packet_net.ini index a9598b0d4b0..6dcc027b15e 100644 --- a/contrib/inventory/packet_net.ini +++ b/contrib/inventory/packet_net.ini @@ -37,6 +37,7 @@ replace_dash_in_groups = True # The packet inventory output can become very large. To manage its size, # configure which groups should be created. group_by_device_id = True +group_by_hostname = True group_by_facility = True group_by_project = True group_by_operating_system = True diff --git a/contrib/inventory/packet_net.py b/contrib/inventory/packet_net.py index a5016d761ef..583ba04cf0d 100755 --- a/contrib/inventory/packet_net.py +++ b/contrib/inventory/packet_net.py @@ -175,6 +175,7 @@ class PacketInventory(object): # Configure which groups should be created. group_by_options = [ 'group_by_device_id', + 'group_by_hostname', 'group_by_facility', 'group_by_project', 'group_by_operating_system', @@ -327,6 +328,12 @@ class PacketInventory(object): if self.nested_groups: self.push_group(self.inventory, 'devices', device.id) + # Inventory: Group by device name (hopefully a group of 1) + if self.group_by_hostname: + self.push(self.inventory, device.hostname, dest) + if self.nested_groups: + self.push_group(self.inventory, 'hostnames', project.name) + # Inventory: Group by project if self.group_by_project: self.push(self.inventory, project.name, dest)