Skip to content

Commit

Permalink
Added Multi-ASIC support for show ip(v6) route
Browse files Browse the repository at this point in the history
  • Loading branch information
gechiang committed Nov 4, 2020
1 parent 061f428 commit e86309d
Show file tree
Hide file tree
Showing 7 changed files with 5,012 additions and 23 deletions.
406 changes: 406 additions & 0 deletions show/bgp_common.py

Large diffs are not rendered by default.

27 changes: 9 additions & 18 deletions show/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#! /usr/bin/python -u

import bgp_common
import json
import netaddr
import os
Expand Down Expand Up @@ -786,17 +787,12 @@ def get_bgp_peer():

@ip.command()
@click.argument('args', metavar='[IPADDRESS] [vrf <vrf_name>] [...]', nargs=-1, required=False)
@multi_asic_util.multi_asic_click_options
@click.option('--verbose', is_flag=True, help="Enable verbose output")
def route(args, verbose):
def route(args, namespace, display, verbose):
"""Show IP (IPv4) routing table"""
cmd = 'sudo vtysh -c "show ip route'

for arg in args:
cmd += " " + str(arg)

cmd += '"'

run_command(cmd, display_cmd=verbose)
# Call common handler to handle the show ip route cmd
bgp_common.show_routes(args, namespace, display, verbose, "ip")

#
# 'prefix-list' subcommand ("show ip prefix-list")
Expand Down Expand Up @@ -909,17 +905,12 @@ def interfaces():

@ipv6.command()
@click.argument('args', metavar='[IPADDRESS] [vrf <vrf_name>] [...]', nargs=-1, required=False)
@multi_asic_util.multi_asic_click_options
@click.option('--verbose', is_flag=True, help="Enable verbose output")
def route(args, verbose):
def route(args, namespace, display, verbose):
"""Show IPv6 routing table"""
cmd = 'sudo vtysh -c "show ipv6 route'

for arg in args:
cmd += " " + str(arg)

cmd += '"'

run_command(cmd, display_cmd=verbose)
# Call common handler to handle the show ipv6 route cmd
bgp_common.show_routes(args, namespace, display, verbose, "ipv6")


# 'protocol' command
Expand Down
26 changes: 21 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,27 @@ def setup_single_bgp_instance(request):
import utilities_common.bgp_util as bgp_util

if request.param == 'v4':
bgp_summary_json = os.path.join(
bgp_mocked_json = os.path.join(
test_path, 'mock_tables', 'ipv4_bgp_summary.json')
elif request.param == 'v6':
bgp_summary_json = os.path.join(
bgp_mocked_json = os.path.join(
test_path, 'mock_tables', 'ipv6_bgp_summary.json')
elif request.param == 'ip_route':
bgp_mocked_json = os.path.join(
test_path, 'mock_tables', 'ip_route.json')
elif request.param == 'ip_specific_route':
bgp_mocked_json = os.path.join(
test_path, 'mock_tables', 'ip_specific_route.json')
elif request.param == 'ipv6_route':
bgp_mocked_json = os.path.join(
test_path, 'mock_tables', 'ipv6_route.json')
else:
bgp_summary_json = os.path.join(
bgp_mocked_json = os.path.join(
test_path, 'mock_tables', 'dummy.json')

def mock_run_bgp_command(vtysh_cmd, bgp_namespace):
if os.path.isfile(bgp_summary_json):
with open(bgp_summary_json) as json_data:
if os.path.isfile(bgp_mocked_json):
with open(bgp_mocked_json) as json_data:
mock_frr_data = json_data.read()
return mock_frr_data
return ""
Expand All @@ -110,3 +119,10 @@ def setup_bgp_commands():
show.ip.add_command(bgpv4)
show.ipv6.add_command(bgpv6)
return show


@pytest.fixture
def setup_ip_route_commands():
import show.main as show

return show
302 changes: 302 additions & 0 deletions tests/ip_show_routes_test.py

Large diffs are not rendered by default.

Loading

0 comments on commit e86309d

Please sign in to comment.