Skip to content

Commit

Permalink
Add IS-IS "show" commands
Browse files Browse the repository at this point in the history
Signed-off-by: Renato Westphal <[email protected]>
  • Loading branch information
rwestphal committed Sep 24, 2024
1 parent c4de375 commit a85aaad
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
71 changes: 71 additions & 0 deletions src/internal_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,77 @@ pub(crate) fn cmd_show_yang_modules(
Ok(false)
}

// ===== IS-IS "show" commands =====

const PROTOCOL_ISIS: &str = "ietf-isis:isis";
const XPATH_ISIS_INTERFACE: &str = "ietf-isis:isis/interfaces/interface";
const XPATH_ISIS_ADJACENCY: &str = "adjacencies/adjacency";
const XPATH_ISIS_DATABASE: &str = "ietf-isis:isis/database/levels";
const XPATH_ISIS_LSP: &str = "lsp";

pub(crate) fn cmd_show_isis_interface(
_commands: &Commands,
session: &mut Session,
mut args: ParsedArgs,
) -> Result<bool, String> {
YangTableBuilder::new(session, DataType::All)
.xpath(XPATH_PROTOCOL)
.filter_list_key("type", Some(PROTOCOL_ISIS))
.column_leaf("Instance", "name")
.xpath(XPATH_ISIS_INTERFACE)
.filter_list_key("name", get_opt_arg(&mut args, "name"))
.column_leaf("Name", "name")
.column_leaf("Circuit ID", "circuit-id")
.column_leaf("State", "state")
.show()?;

Ok(false)
}

pub(crate) fn cmd_show_isis_adjacency(
_commands: &Commands,
session: &mut Session,
mut args: ParsedArgs,
) -> Result<bool, String> {
YangTableBuilder::new(session, DataType::All)
.xpath(XPATH_PROTOCOL)
.filter_list_key("type", Some(PROTOCOL_ISIS))
.column_leaf("Instance", "name")
.xpath(XPATH_ISIS_INTERFACE)
.filter_list_key("name", get_opt_arg(&mut args, "name"))
.column_leaf("Interface", "name")
.xpath(XPATH_ISIS_ADJACENCY)
.column_leaf("System ID", "neighbor-sysid")
.column_leaf("SNPA", "neighbor-snpa")
.column_leaf("Level", "usage")
.column_leaf("State", "state")
.column_leaf("Holdtime", "hold-timer")
.show()?;

Ok(false)
}

pub(crate) fn cmd_show_isis_database(
_commands: &Commands,
session: &mut Session,
_args: ParsedArgs,
) -> Result<bool, String> {
YangTableBuilder::new(session, DataType::All)
.xpath(XPATH_PROTOCOL)
.filter_list_key("type", Some(PROTOCOL_ISIS))
.column_leaf("Instance", "name")
.xpath(XPATH_ISIS_DATABASE)
.column_leaf("Level", "level")
.xpath(XPATH_ISIS_LSP)
.column_leaf("LSP ID", "lsp-id")
.column_leaf("Sequence", "sequence")
.column_leaf("Checksum", "checksum")
.column_leaf("Lifetime", "remaining-lifetime")
.show()?;

Ok(false)
}

// ===== OSPF "show" commands =====

const PROTOCOL_OSPFV2: &str = "ietf-ospf:ospfv2";
Expand Down
8 changes: 8 additions & 0 deletions src/internal_commands.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@
<token name="yang" help="YANG information.">
<token name="modules" help="Show loaded YANG modules." cmd="cmd_show_yang_modules"/>
</token>
<!-- IS-IS show commands -->
<token name="isis" argument="protocol" help="IS-IS information">
<token name="interface" help="Interface information" cmd="cmd_show_isis_interface">
<token name="NAME" help="Interface name" argument="name" kind="string" cmd="cmd_show_isis_interface"/>
</token>
<token name="database" help="Link state database" cmd="cmd_show_isis_database"/>
<token name="adjacency" help="Adjacency information" cmd="cmd_show_isis_adjacency"/>
</token>
<!-- OSPF show commands -->
<token name="ospfv2" argument="protocol" help="OSPFv2 information">
<token name="interface" help="Interface information" cmd="cmd_show_ospf_interface">
Expand Down
3 changes: 3 additions & 0 deletions src/token_xml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ fn parse_tag_token(
"cmd_show_config_changes" => internal_commands::cmd_show_config_changes,
"cmd_show_state" => internal_commands::cmd_show_state,
"cmd_show_yang_modules" => internal_commands::cmd_show_yang_modules,
"cmd_show_isis_interface" => internal_commands::cmd_show_isis_interface,
"cmd_show_isis_adjacency" => internal_commands::cmd_show_isis_adjacency,
"cmd_show_isis_database" => internal_commands::cmd_show_isis_database,
"cmd_show_ospf_interface" => internal_commands::cmd_show_ospf_interface,
"cmd_show_ospf_interface_detail" => {
internal_commands::cmd_show_ospf_interface_detail
Expand Down

0 comments on commit a85aaad

Please sign in to comment.