Skip to content

Commit 59ed4cb

Browse files
committed
Merge pull request #3 from cchoate54/ideleon/show_cmd_isis_topology
[show/tests] Add support for "show isis topology"
2 parents 503bd9c + 0fdf927 commit 59ed4cb

File tree

4 files changed

+155
-11
lines changed

4 files changed

+155
-11
lines changed

show/isis_frr.py

+20-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def interface(interface, verbose, display):
104104

105105
if display:
106106
d = f"[INTERFACE] options: {INTERFACE_LIST}"
107-
click.echo(d)
107+
click.echo(d.rstrip('\n'))
108108

109109
command = 'show isis interface'
110110

@@ -118,6 +118,24 @@ def interface(interface, verbose, display):
118118

119119
click.echo(output.rstrip('\n'))
120120

121+
# 'topology' subcommand ("show isis topology")
122+
@isis.command()
123+
@click.option('--level-1', is_flag=True, help="Show IS-IS level-1 information")
124+
@click.option('--level-2', is_flag=True, help="Show IS-IS level-2 information")
125+
def topology(level_1, level_2):
126+
"""Show ISIS topology"""
127+
128+
command = 'show isis topology'
129+
130+
if level_1:
131+
command += ' level-1'
132+
elif level_2:
133+
command += ' level-2'
134+
135+
output = ""
136+
output += bgp_util.run_bgp_show_command(command)
137+
138+
click.echo(output.rstrip('\n'))
121139

122140
# 'summary' subcommand ("show isis summary")
123141
@isis.command()
@@ -129,4 +147,4 @@ def summary():
129147
output = ""
130148
output += bgp_util.run_bgp_show_command(command)
131149

132-
click.echo(output.rstrip('\n'))
150+
click.echo(output.rstrip('\n'))

tests/conftest.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
mock_show_isis_database,
2424
mock_show_isis_hostname,
2525
mock_show_isis_interface,
26-
mock_show_isis_summary
26+
mock_show_isis_topology,
27+
mock_show_isis_summary,
2728
mock_show_run_isis
2829
)
2930
from . import config_int_ip_common
@@ -401,7 +402,11 @@ def setup_single_isis_instance(request):
401402
elif request.param.startswith('isis_interface') or \
402403
request.param.startswith('isis_interface'):
403404
bgp_util.run_bgp_command = mock.MagicMock(
404-
return_value=mock_show_isis_interface(request))
405+
return_value=mock_show_isis_interface(request))
406+
elif request.param.startswith('isis_topology') or \
407+
request.param.startswith('isis_topology'):
408+
bgp_util.run_bgp_command = mock.MagicMock(
409+
return_value=mock_show_isis_topology(request))
405410
elif request.param.startswith('isis_summary'):
406411
bgp_util.run_bgp_command = mock.MagicMock(
407412
return_value=mock_show_isis_summary(request))

tests/isis_frr_input/isis_frr_test_vector.py

+96
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,17 @@ def mock_show_isis_hostname(request):
438438
'Ethernet116, Ethernet120, Ethernet124, PortChannel0001, PortChannel0002, ' \
439439
'PortChannel0003, PortChannel0004, PortChannel1001)\n'
440440

441+
isis_interface_display_output = \
442+
"[INTERFACE] options: " \
443+
"['Ethernet0', 'Ethernet4', 'Ethernet8', 'Ethernet12', 'Ethernet16', " \
444+
"'Ethernet20', 'Ethernet24', 'Ethernet28', 'Ethernet32', 'Ethernet36', 'Ethernet40', " \
445+
"'Ethernet44', 'Ethernet48', 'Ethernet52', 'Ethernet56', 'Ethernet60', 'Ethernet64', " \
446+
"'Ethernet68', 'Ethernet72', 'Ethernet76', 'Ethernet80', 'Ethernet84', 'Ethernet88', " \
447+
"'Ethernet92', 'Ethernet96', 'Ethernet100', 'Ethernet104', 'Ethernet108', 'Ethernet112', " \
448+
"'Ethernet116', 'Ethernet120', 'Ethernet124', 'PortChannel0001', 'PortChannel0002', " \
449+
"'PortChannel0003', 'PortChannel0004', 'PortChannel1001']\n\n"
450+
451+
441452
def mock_show_isis_interface(request):
442453
if request.param == 'isis_interface_output':
443454
return isis_interface_output
@@ -449,9 +460,35 @@ def mock_show_isis_interface(request):
449460
return isis_interface_ifname_output
450461
elif request.param == 'isis_interface_unknown_ifname_output':
451462
return isis_interface_unknown_ifname_output
463+
elif request.param == 'isis_interface_display_output':
464+
return ""
452465
else:
453466
return ""
454467

468+
isis_topology_output = \
469+
"""Area 1:
470+
IS-IS paths to level-2 routers that speak IP
471+
Vertex Type Metric Next-Hop Interface Parent
472+
vlab-01
473+
10.0.0.56/31 IP internal 0 vlab-01(4)
474+
10.1.0.32/32 IP internal 0 vlab-01(4)
475+
ARISTA01T1 TE-IS 10 ARISTA01T1 PortChannel101 vlab-01(4)
476+
10.0.0.56/31 IP TE 16777225 ARISTA01T1 PortChannel101 ARISTA01T1(4)
477+
478+
IS-IS paths to level-2 routers that speak IPv6
479+
Vertex Type Metric Next-Hop Interface Parent
480+
vlab-01
481+
fc00::70/126 IP6 internal 0 vlab-01(4)
482+
fc00:1::32/128 IP6 internal 0 vlab-01(4)
483+
"""
484+
485+
isis_topology_invalid_help_output = \
486+
"""Usage: topology [OPTIONS]
487+
Try "topology --help" for help.
488+
489+
Error: Got unexpected extra argument (?)
490+
"""
491+
455492
show_run_isis_output = \
456493
"""Building configuration...
457494
@@ -492,6 +529,39 @@ def mock_show_isis_interface(request):
492529
Error: Got unexpected extra argument (?)
493530
"""
494531

532+
isis_topology_level_1_output = \
533+
"""Area 1:
534+
"""
535+
536+
isis_topology_level_2_output = \
537+
"""Area 1:
538+
IS-IS paths to level-2 routers that speak IP
539+
Vertex Type Metric Next-Hop Interface Parent
540+
vlab-01
541+
10.0.0.56/31 IP internal 0 vlab-01(4)
542+
10.1.0.32/32 IP internal 0 vlab-01(4)
543+
ARISTA01T1 TE-IS 10 ARISTA01T1 PortChannel101 vlab-01(4)
544+
10.0.0.56/31 IP TE 16777225 ARISTA01T1 PortChannel101 ARISTA01T1(4)
545+
546+
IS-IS paths to level-2 routers that speak IPv6
547+
Vertex Type Metric Next-Hop Interface Parent
548+
vlab-01
549+
fc00::70/126 IP6 internal 0 vlab-01(4)
550+
fc00:1::32/128 IP6 internal 0 vlab-01(4)
551+
"""
552+
553+
def mock_show_isis_topology(request):
554+
if request.param == 'isis_topology_output':
555+
return isis_topology_output
556+
elif request.param == 'isis_topology_invalid_help_output':
557+
return isis_topology_invalid_help_output
558+
elif request.param == 'isis_topology_level_1_output':
559+
return isis_topology_level_1_output
560+
elif request.param == 'isis_topology_level_2_output':
561+
return isis_topology_level_2_output
562+
else:
563+
return ""
564+
495565
def mock_show_run_isis(request):
496566
if request.param == 'show_run_isis_output':
497567
return show_run_isis_output
@@ -666,6 +736,31 @@ def mock_show_isis_summary(request):
666736
'rc': 2,
667737
'rc_output': isis_interface_unknown_ifname_output
668738
},
739+
'isis_interface_display': {
740+
'args': ['--display'],
741+
'rc': 0,
742+
'rc_output': isis_interface_display_output
743+
},
744+
'isis_topology': {
745+
'args': [],
746+
'rc': 0,
747+
'rc_output': isis_topology_output
748+
},
749+
'isis_topology_invalid_help': {
750+
'args': ['?'],
751+
'rc': 2,
752+
'rc_output': isis_topology_invalid_help_output
753+
},
754+
'isis_topology_level_1': {
755+
'args': ['--level-1'],
756+
'rc': 0,
757+
'rc_output': isis_topology_level_1_output
758+
},
759+
'isis_topology_level_2': {
760+
'args': ['--level-2'],
761+
'rc': 0,
762+
'rc_output': isis_topology_level_2_output
763+
},
669764
'isis_summary': {
670765
'args': [],
671766
'rc': 0,
@@ -675,6 +770,7 @@ def mock_show_isis_summary(request):
675770
'args': ['?'],
676771
'rc': 2,
677772
'rc_output': isis_summary_invalid_help_output
773+
},
678774
'show_run_isis': {
679775
'args': [],
680776
'rc': 0,

tests/isis_frr_test.py

+32-7
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ def setup_class(cls):
4949
],
5050
indirect=['setup_single_isis_instance'])
5151
def test_isis_neighbors(self,
52-
setup_isis_commands,
53-
setup_single_isis_instance,
54-
test_vector):
52+
setup_isis_commands,
53+
setup_single_isis_instance,
54+
test_vector):
5555
show = setup_isis_commands
5656
exec_cmd = show.cli.commands["isis"].commands["neighbors"]
5757
executor(test_vector, show, exec_cmd)
@@ -116,14 +116,39 @@ def setup_class(cls):
116116
('isis_interface_verbose_output', 'isis_interface_verbose'),
117117
('isis_interface_ifname_verbose_output', 'isis_interface_ifname_verbose'),
118118
('isis_interface_unknown_ifname_output', 'isis_interface_unknown_ifname'),
119+
('isis_interface_unknown_ifname_output', 'isis_interface_unknown_ifname'),
120+
('isis_interface_display_output', 'isis_interface_display')
119121
],
120122
indirect=['setup_single_isis_instance'])
121123
def test_isis_interface(self,
124+
setup_isis_commands,
125+
setup_single_isis_instance,
126+
test_vector):
127+
show = setup_isis_commands
128+
exec_cmd = show.cli.commands["isis"].commands["interface"]
129+
executor(test_vector, show, exec_cmd)
130+
131+
132+
class TestIsisTopology(object):
133+
134+
@classmethod
135+
def setup_class(cls):
136+
print("SETUP")
137+
138+
@pytest.mark.parametrize('setup_single_isis_instance, test_vector',
139+
[
140+
('isis_topology_output', 'isis_topology'),
141+
('isis_topology_invalid_help_output', 'isis_topology_invalid_help'),
142+
('isis_topology_level_1_output', 'isis_topology_level_1'),
143+
('isis_topology_level_2_output', 'isis_topology_level_2')
144+
],
145+
indirect=['setup_single_isis_instance'])
146+
def test_isis_topology(self,
122147
setup_isis_commands,
123148
setup_single_isis_instance,
124149
test_vector):
125150
show = setup_isis_commands
126-
exec_cmd = show.cli.commands["isis"].commands["interface"]
151+
exec_cmd = show.cli.commands["isis"].commands["topology"]
127152
executor(test_vector, show, exec_cmd)
128153

129154

@@ -146,7 +171,7 @@ def test_isis_summary(self,
146171
show = setup_isis_commands
147172
exec_cmd = show.cli.commands["isis"].commands["summary"]
148173
executor(test_vector, show, exec_cmd)
149-
174+
150175

151176
class TestShowRunIsis(object):
152177

@@ -156,8 +181,8 @@ def setup_class(cls):
156181

157182
@pytest.mark.parametrize('setup_single_isis_instance, test_vector',
158183
[
159-
('show_run_isis_output', 'show_run_isis'),
160-
('show_run_isis_invalid_help_output', 'show_run_isis_invalid_help')
184+
('show_run_isis_output', 'show_run_isis'),
185+
('show_run_isis_invalid_help_output', 'show_run_isis_invalid_help')
161186
],
162187
indirect=['setup_single_isis_instance'])
163188
def test_show_run_isis(self,

0 commit comments

Comments
 (0)