Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOS: Return empty dictionary if BGP not running #1019

Merged
merged 2 commits into from
Oct 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion napalm/base/test/getters.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ def test_get_environment(self, test_case):
def test_get_bgp_neighbors(self, test_case):
"""Test get_bgp_neighbors."""
get_bgp_neighbors = self.device.get_bgp_neighbors()
assert "global" in get_bgp_neighbors.keys()
if len(get_bgp_neighbors) > 0:
assert "global" in get_bgp_neighbors.keys()

for vrf, vrf_data in get_bgp_neighbors.items():
assert isinstance(vrf_data["router_id"], str)
Expand Down
6 changes: 3 additions & 3 deletions napalm/ios/ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -1497,9 +1497,9 @@ def get_bgp_neighbors(self):
# get summary output from device
cmd_bgp_all_sum = "show bgp all summary"
summary_output = self._send_command(cmd_bgp_all_sum).strip()

if "Invalid input detected" in summary_output:
raise CommandErrorException("BGP is not running on this device")
bgp_not_running = ["Invalid input", "BGP not active"]
if any((s in summary_output for s in bgp_not_running)):
return {}

# get neighbor output from device
neighbor_output = ""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
% BGP not active