Skip to content

Commit

Permalink
[IOS] Raise exception if BGP neighbor info requested and BGP not runn…
Browse files Browse the repository at this point in the history
…ing (#970)
  • Loading branch information
ktbyers committed Apr 24, 2019
1 parent 495c3a2 commit ac8e9e2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions napalm/ios/ios.py
Expand Up @@ -1474,6 +1474,9 @@ def get_bgp_neighbors(self):
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")

# get neighbor output from device
neighbor_output = ""
for afi in supported_afi:
Expand Down Expand Up @@ -1817,6 +1820,10 @@ def get_bgp_neighbors_detail(self, neighbor_address=""):
bgp_detail = defaultdict(lambda: defaultdict(lambda: []))

raw_bgp_sum = self._send_command("show ip bgp all sum").strip()

if "Invalid input detected" in raw_bgp_sum:
raise CommandErrorException("BGP is not running on this device")

bgp_sum = napalm.base.helpers.textfsm_extractor(
self, "ip_bgp_all_sum", raw_bgp_sum
)
Expand Down

0 comments on commit ac8e9e2

Please sign in to comment.