Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Multi-ASIC support for show ip(v6) route #1216

Merged
merged 9 commits into from
Nov 24, 2020
394 changes: 394 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