|
| 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')) |
0 commit comments