From cc7d0f7670a35b27e862bfdcb2eeabfc28ef2a45 Mon Sep 17 00:00:00 2001 From: elreydetoda Date: Thu, 26 Nov 2020 01:08:15 -0500 Subject: [PATCH] adding fix for packet_net.py (#891) * adding fix for packet_net.py * adding changelog fragment * squashing to fix cascading notifications Apply suggestions from code review thanks felixfontein for working with me! Co-authored-by: Felix Fontein adding suggestions from code review (accessing dict in a better way) modified packet_net fragment to accurate description Co-authored-by: Felix Fontein Co-authored-by: Felix Fontein --- .../fragments/891-packet_net-fix-not-subscriptable.yaml | 2 ++ scripts/inventory/packet_net.py | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/891-packet_net-fix-not-subscriptable.yaml diff --git a/changelogs/fragments/891-packet_net-fix-not-subscriptable.yaml b/changelogs/fragments/891-packet_net-fix-not-subscriptable.yaml new file mode 100644 index 0000000000..844a16eef0 --- /dev/null +++ b/changelogs/fragments/891-packet_net-fix-not-subscriptable.yaml @@ -0,0 +1,2 @@ +bugfixes: +- packet_net.py inventory script - fixed failure w.r.t. operating system retrieval by changing array subscription back to attribute access (https://github.com/ansible-collections/community.general/pull/891). diff --git a/scripts/inventory/packet_net.py b/scripts/inventory/packet_net.py index 9466017140..196e26869d 100644 --- a/scripts/inventory/packet_net.py +++ b/scripts/inventory/packet_net.py @@ -346,9 +346,9 @@ class PacketInventory(object): # Inventory: Group by OS if self.group_by_operating_system: - self.push(self.inventory, device.operating_system['slug'], dest) + self.push(self.inventory, device.operating_system.slug, dest) if self.nested_groups: - self.push_group(self.inventory, 'operating_systems', device.operating_system['slug']) + self.push_group(self.inventory, 'operating_systems', device.operating_system.slug) # Inventory: Group by plan type if self.group_by_plan_type: @@ -395,7 +395,7 @@ class PacketInventory(object): elif key == 'packet_facility': device_vars[key] = value['code'] elif key == 'packet_operating_system': - device_vars[key] = value['slug'] + device_vars[key] = value.slug elif key == 'packet_plan': device_vars[key] = value['slug'] elif key == 'packet_tags':