From 31cfeba9e172c7624085c0c73d1069fc40b4f1be Mon Sep 17 00:00:00 2001 From: roverflow Date: Tue, 27 Aug 2024 15:17:03 +0530 Subject: [PATCH] Handle Empty LLDP Neighbor Information in facts --- changelogs/fragments/lldp_facts.yaml | 3 +++ plugins/module_utils/network/nxos/facts/legacy/base.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/lldp_facts.yaml diff --git a/changelogs/fragments/lldp_facts.yaml b/changelogs/fragments/lldp_facts.yaml new file mode 100644 index 000000000..89d940a0f --- /dev/null +++ b/changelogs/fragments/lldp_facts.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - facts - Fixes issue where the LLDP neighbor information returns an error when empty. diff --git a/plugins/module_utils/network/nxos/facts/legacy/base.py b/plugins/module_utils/network/nxos/facts/legacy/base.py index a3a453784..0abcbb867 100644 --- a/plugins/module_utils/network/nxos/facts/legacy/base.py +++ b/plugins/module_utils/network/nxos/facts/legacy/base.py @@ -270,7 +270,8 @@ def populate(self): self.populate_ipv6_interfaces(interfaces) data = self.run("show lldp neighbors", output="json") - if data: + neigh_count = data.get("neigh_count", '0') + if data and int(neigh_count) != 0: if isinstance(data, dict): self.facts["neighbors"].update( self.populate_structured_neighbors_lldp(data),