From 035aa99beacb67582c5dd9f513a4c275a30e19c9 Mon Sep 17 00:00:00 2001
From: Adrian Celebanski <135693994+acelebanski@users.noreply.github.com>
Date: Mon, 15 Apr 2024 11:15:00 +0200
Subject: [PATCH] fix: Failing snapshots of FWs with no BGP peers (#167)
---
panos_upgrade_assurance/firewall_proxy.py | 4 ++++
tests/test_firewall_proxy.py | 11 +++++++++++
2 files changed, 15 insertions(+)
diff --git a/panos_upgrade_assurance/firewall_proxy.py b/panos_upgrade_assurance/firewall_proxy.py
index 24fea21..483cd57 100644
--- a/panos_upgrade_assurance/firewall_proxy.py
+++ b/panos_upgrade_assurance/firewall_proxy.py
@@ -698,6 +698,10 @@ def get_bgp_peers(self) -> dict:
response = self.op_parser(cmd="show routing protocol bgp peer")
result = {}
+
+ if response is None:
+ return result
+
if "entry" in response:
bgp_peers = response["entry"]
for peer in bgp_peers if isinstance(bgp_peers, list) else [bgp_peers]:
diff --git a/tests/test_firewall_proxy.py b/tests/test_firewall_proxy.py
index 4b5c4aa..0bd51a4 100644
--- a/tests/test_firewall_proxy.py
+++ b/tests/test_firewall_proxy.py
@@ -700,6 +700,17 @@ def test_get_bgp_peers(self, fw_proxy_mock):
}
}
+ def test_get_bgp_peers_no_peers(self, fw_proxy_mock):
+ xml_text = """
+
+
+
+ """
+ raw_response = ET.fromstring(xml_text)
+ fw_proxy_mock.op.return_value = raw_response
+
+ assert fw_proxy_mock.get_bgp_peers() == {}
+
def test_get_arp_table(self, fw_proxy_mock):
xml_text = """