Skip to content

Commit 2da799a

Browse files
committed
sonic-utilities: Create SONiC ISIS show commands
* Update show/main.py Include "isis" as a cli group option for show commands * Create show/isis_frr.py Add "isis" as a cli group option for show commands and add support for "show isis neighbors" Signed-off-by: [email protected]
1 parent 784a15c commit 2da799a

File tree

2 files changed

+103
-0
lines changed

2 files changed

+103
-0
lines changed

show/isis_frr.py

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import click
2+
3+
import utilities_common.bgp_util as bgp_util
4+
import utilities_common.cli as clicommon
5+
6+
###############################################################################
7+
#
8+
# 'show isis' cli stanza
9+
#
10+
############################################################################### 
11+
12+
13+
@click.group(cls=clicommon.AliasedGroup, name="isis")
14+
def isis():
15+
"""Show ISIS (Intermediate System to Intermediate System) information"""
16+
pass
17+
18+
19+
# 'neighbors' subcommand ("show isis neighbors")
20+
@isis.command()
21+
@click.argument('system_id', required=False)
22+
@click.argument('info_type',
23+
metavar='[detail]',
24+
type=click.Choice(
25+
['detail']),
26+
required=False)
27+
@click.option('--verbose', is_flag=True, help="Enable verbose output")
28+
def neighbors(system_id, info_type, verbose):
29+
"""Show ISIS neighbors"""
30+
31+
command = 'show isis neighbor'
32+
if system_id is not None:
33+
command += ' {0}'.format(system_id)
34+
elif info_type or verbose:
35+
command += ' detail'
36+
37+
output = ""
38+
output += bgp_util.run_bgp_show_command(command)
39+
40+
click.echo(output.rstrip('\n'))
41+
42+
# 'database' subcommand ("show isis database")
43+
@isis.command()
44+
@click.argument('lsp_id', required=False)
45+
@click.argument('info_type',
46+
metavar='[detail]',
47+
type=click.Choice(
48+
['detail']),
49+
required=False)
50+
@click.option('--verbose', is_flag=True, help="Enable verbose output")
51+
def database(lsp_id, info_type, verbose):
52+
"""Show ISIS database"""
53+
54+
command = 'show isis database'
55+
if lsp_id is not None:
56+
command += ' {0}'.format(lsp_id)
57+
elif info_type or verbose:
58+
command += ' detail'
59+
60+
output = ""
61+
output += bgp_util.run_bgp_show_command(command)
62+
63+
click.echo(output.rstrip('\n'))
64+
65+
# 'hostname' subcommand ("show isis hostname")
66+
@isis.command()
67+
def hostname():
68+
"""Show ISIS hostname"""
69+
70+
command = 'show isis hostname'
71+
72+
output = ""
73+
output += bgp_util.run_bgp_show_command(command)
74+
75+
click.echo(output.rstrip('\n'))
76+
77+
# 'interface' subcommand ("show isis interface")
78+
@isis.command()
79+
@click.argument('interface', required=False)
80+
@click.argument('info_type',
81+
metavar='[detail]',
82+
type=click.Choice(
83+
['detail']),
84+
required=False)
85+
@click.option('--verbose', is_flag=True, help="Enable verbose output")
86+
def interface(interface, info_type, verbose):
87+
"""Show ISIS interface"""
88+
89+
command = 'show isis interface'
90+
if interface is not None and clicommon.get_interface_naming_mode() == "alias":
91+
interface = clicommon.iface_alias_converter.alias_to_name(interface)
92+
93+
if interface is not None:
94+
command += ' {0}'.format(interface)
95+
elif info_type or verbose:
96+
command += ' detail'
97+
98+
output = ""
99+
output += bgp_util.run_bgp_show_command(command)
100+
101+
click.echo(output.rstrip('\n'))

show/main.py

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
from . import flow_counters
4949
from . import gearbox
5050
from . import interfaces
51+
from . import isis_frr
5152
from . import kdump
5253
from . import kube
5354
from . import muxcable
@@ -276,6 +277,7 @@ def cli(ctx):
276277
cli.add_command(flow_counters.flowcnt_trap)
277278
cli.add_command(kdump.kdump)
278279
cli.add_command(interfaces.interfaces)
280+
cli.add_command(isis_frr.isis)
279281
cli.add_command(kdump.kdump)
280282
cli.add_command(kube.kubernetes)
281283
cli.add_command(muxcable.muxcable)

0 commit comments

Comments
 (0)