Skip to content

Commit 136eb4d

Browse files
authored
Fix: include VRF BGP sessions in the BGP graph (ipspace#2596)
Also: refactor the 'parse format keywords' code in D2/GV BGP graphs
1 parent 0bb5d8e commit 136eb4d

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

netsim/outputs/_graph.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from ..data import get_box,get_empty_box
88
from ..data.types import must_be_list
9-
from ..utils import log
9+
from ..utils import log,routing as _routing
1010

1111
SHARED_GRAPH_ATTRIBUTES: Box # Graph attributes shared between all graph output modules
1212

@@ -169,7 +169,7 @@ def bgp_sessions(graph: Box, topology: Box, settings: Box, g_type: str, rr_sessi
169169
for n_name,n_data in topology.nodes.items():
170170
if 'bgp' not in n_data:
171171
continue
172-
for neighbor in n_data.bgp.get('neighbors',[]):
172+
for neighbor in _routing.neighbors(n_data,vrf=True):
173173
if neighbor.name < n_name:
174174
continue
175175

netsim/outputs/d2.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,10 @@ def graph_topology(topology: Box, fname: str, settings: Box,g_format: typing.Opt
173173

174174
def graph_bgp(topology: Box, fname: str, settings: Box, g_format: typing.Optional[list]) -> bool:
175175
rr_session = settings.get('rr_sessions',False)
176-
if g_format is not None and len(g_format) > 1:
177-
rr_session = g_format[1] == 'rr'
176+
g_format = g_format or []
177+
for kw in g_format[1:]:
178+
if kw == 'rr':
179+
rr_session = True
178180

179181
graph = bgp_graph(topology,settings,'d2',rr_sessions=rr_session)
180182
if graph is None:

netsim/outputs/graph.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,10 @@ def graph_topology(topology: Box, fname: str, settings: Box,g_format: typing.Opt
194194

195195
def graph_bgp(topology: Box, fname: str, settings: Box,g_format: typing.Optional[list]) -> bool:
196196
rr_session = settings.get('rr_sessions',False)
197-
if g_format is not None and len(g_format) > 1:
198-
rr_session = g_format[1] == 'rr'
197+
g_format = g_format or []
198+
for kw in g_format[1:]:
199+
if kw == 'rr':
200+
rr_session = True
199201

200202
graph = bgp_graph(topology,settings,'graph',rr_sessions=rr_session)
201203
if graph is None:

0 commit comments

Comments
 (0)