Skip to content

Commit

Permalink
get_bgp_config for Cisco when no BGP is configured (#1910)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktbyers committed May 1, 2023
1 parent 8e7d663 commit 4af4391
Show file tree
Hide file tree
Showing 3 changed files with 175 additions and 15 deletions.
39 changes: 24 additions & 15 deletions napalm/ios/ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -1463,6 +1463,11 @@ def build_prefix_limit(af_table, limit, prefix_percent, prefix_timeout):
bgp_config_list = napalm.base.helpers.netutils_parse_objects(
"router bgp", cfg["running"]
)

# No BGP configuration
if not bgp_config_list:
return {}

bgp_asn = napalm.base.helpers.regex_find_txt(
r"router bgp (\d+)", bgp_config_list, default=0
)
Expand Down Expand Up @@ -1569,21 +1574,25 @@ def build_prefix_limit(af_table, limit, prefix_percent, prefix_timeout):
"route_reflector_client": route_reflector_client,
}

bgp_config["_"] = {
"apply_groups": [],
"description": "",
"local_as": bgp_asn,
"type": "",
"import_policy": "",
"export_policy": "",
"local_address": "",
"multipath": False,
"multihop_ttl": 0,
"remote_as": 0,
"remove_private_as": False,
"prefix_limit": {},
"neighbors": bgp_group_neighbors.get("_", {}),
}
# Do not include the no-group ("_") if a group argument is passed in
# unless group argument is "_"
if not group or group == "_":
bgp_config["_"] = {
"apply_groups": [],
"description": "",
"local_as": bgp_asn,
"type": "",
"import_policy": "",
"export_policy": "",
"local_address": "",
"multipath": False,
"multihop_ttl": 0,
"remote_as": 0,
"remove_private_as": False,
"prefix_limit": {},
"neighbors": bgp_group_neighbors.get("_", {}),
}

# Get the peer-group level config for each group
for group_name in bgp_group_neighbors.keys():
# If a group is passed in params, only continue on that group
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,150 @@
!
! Last configuration change at 18:41:02 UTC Thu Nov 24 2016
!
version 15.5
service timestamps debug datetime msec
service timestamps log datetime msec
no platform punt-keepalive disable-kernel-core
platform console auto
!
hostname CSR1
!
boot-start-marker
boot-end-marker
!
!
enable password cisco
!
aaa new-model
!
!
aaa authentication login default local
aaa authorization exec default local
!
!
!
!
!
aaa session-id common
!
ip vrf MGMT
!
!
!
!
!
!
!
!
!


ip domain name example.local

!
!
!
!
!
!
!
!
!
!
subscriber templating
!
multilink bundle-name authenticated
!
!
!
!
!
!
!
!
!
!
!
!
!
license udi pid CSR1000V sn 9OSEGKJXRHE
spanning-tree extend system-id
!
username cisco privilege 15 password 0 cisco
!
redundancy
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
interface Loopback0
ip address 1.1.1.1 255.255.255.255
!
interface GigabitEthernet1
ip vrf forwarding MGMT
ip address 192.168.35.121 255.255.255.0
negotiation auto
!
interface GigabitEthernet2
ip address 10.1.1.1 255.255.255.0
negotiation auto
!
interface GigabitEthernet3
no ip address
shutdown
negotiation auto
!
router ospf 1
redistribute connected subnets
network 10.1.1.0 0.0.0.255 area 0
!
!
!
!
virtual-service csr_mgmt
!
ip forward-protocol nd
!
no ip http server
no ip http secure-server
!
!
!
!
!
!
control-plane
!
!
!
!
!
!
!
!
!
!
line con 0
line vty 0 4
!
!
end

0 comments on commit 4af4391

Please sign in to comment.