Skip to content

Commit

Permalink
sonic-utilities: Create SONiC ISIS show commands
Browse files Browse the repository at this point in the history
* 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", "show isis database", "show isis hostname", and "show isis interface"

Signed-off-by: cchoate54@gmail.com
  • Loading branch information
cchoate54 committed Feb 17, 2023
1 parent 784a15c commit b473dd5
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 0 deletions.
101 changes: 101 additions & 0 deletions show/isis_frr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import click

import utilities_common.bgp_util as bgp_util
import utilities_common.cli as clicommon

###############################################################################
#
# 'show isis' cli stanza
#
############################################################################### 


@click.group(cls=clicommon.AliasedGroup, name="isis")
def isis():
"""Show ISIS (Intermediate System to Intermediate System) information"""
pass


# 'neighbors' subcommand ("show isis neighbors")
@isis.command()
@click.argument('system_id', required=False)
@click.argument('info_type',
metavar='[detail]',
type=click.Choice(
['detail']),
required=False)
@click.option('--verbose', is_flag=True, help="Enable verbose output")
def neighbors(system_id, info_type, verbose):
"""Show ISIS neighbors"""

command = 'show isis neighbor'
if system_id is not None:
command += ' {0}'.format(system_id)
elif info_type or verbose:
command += ' detail'

output = ""
output += bgp_util.run_bgp_show_command(command)

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

# 'database' subcommand ("show isis database")
@isis.command()
@click.argument('lsp_id', required=False)
@click.argument('info_type',
metavar='[detail]',
type=click.Choice(
['detail']),
required=False)
@click.option('--verbose', is_flag=True, help="Enable verbose output")
def database(lsp_id, info_type, verbose):
"""Show ISIS database"""

command = 'show isis database'
if lsp_id is not None:
command += ' {0}'.format(lsp_id)
elif info_type or verbose:
command += ' detail'

output = ""
output += bgp_util.run_bgp_show_command(command)

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

# 'hostname' subcommand ("show isis hostname")
@isis.command()
def hostname():
"""Show ISIS hostname"""

command = 'show isis hostname'

output = ""
output += bgp_util.run_bgp_show_command(command)

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

# 'interface' subcommand ("show isis interface")
@isis.command()
@click.argument('interface', required=False)
@click.argument('info_type',
metavar='[detail]',
type=click.Choice(
['detail']),
required=False)
@click.option('--verbose', is_flag=True, help="Enable verbose output")
def interface(interface, info_type, verbose):
"""Show ISIS interface"""

command = 'show isis interface'
if interface is not None and clicommon.get_interface_naming_mode() == "alias":
interface = clicommon.iface_alias_converter.alias_to_name(interface)

if interface is not None:
command += ' {0}'.format(interface)
elif info_type or verbose:
command += ' detail'

output = ""
output += bgp_util.run_bgp_show_command(command)

click.echo(output.rstrip('\n'))
2 changes: 2 additions & 0 deletions show/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
from . import flow_counters
from . import gearbox
from . import interfaces
from . import isis_frr
from . import kdump
from . import kube
from . import muxcable
Expand Down Expand Up @@ -276,6 +277,7 @@ def cli(ctx):
cli.add_command(flow_counters.flowcnt_trap)
cli.add_command(kdump.kdump)
cli.add_command(interfaces.interfaces)
cli.add_command(isis_frr.isis)
cli.add_command(kdump.kdump)
cli.add_command(kube.kubernetes)
cli.add_command(muxcable.muxcable)
Expand Down

0 comments on commit b473dd5

Please sign in to comment.