Skip to content

Commit 52e05a1

Browse files
authored
Add --afi filter option to report bgp command (#2133)
AI-assisted: Claude Code Signed-off-by: Christian Berendt <berendt@osism.tech>
1 parent 7e3e4c7 commit 52e05a1

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

osism/commands/report.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,23 @@ def get_parser(self, prog_name):
314314
type=str,
315315
help="Limit selected hosts to an additional pattern",
316316
)
317+
parser.add_argument(
318+
"--afi",
319+
type=str,
320+
nargs="+",
321+
choices=[
322+
"ipv4Unicast",
323+
"ipv4Multicast",
324+
"ipv4Vpn",
325+
"ipv4Flowspec",
326+
"ipv6Unicast",
327+
"ipv6Multicast",
328+
"ipv6Vpn",
329+
"ipv6Flowspec",
330+
"l2VpnEvpn",
331+
],
332+
help="Filter by address family (e.g. ipv4Unicast ipv6Unicast)",
333+
)
317334
return parser
318335

319336
def take_action(self, parsed_args):
@@ -395,7 +412,13 @@ def take_action(self, parsed_args):
395412

396413
bgp_data = json.loads(bgp_result.stdout)
397414

415+
afi_filter = None
416+
if parsed_args.afi:
417+
afi_filter = {a.lower() for a in parsed_args.afi}
418+
398419
for afi, afi_data in bgp_data.items():
420+
if afi_filter is not None and afi.lower() not in afi_filter:
421+
continue
399422
peers = afi_data.get("peers", {})
400423
for peer_name, peer_data in peers.items():
401424
table.append(

0 commit comments

Comments
 (0)