diff --git a/isisd/isis_cli.c b/isisd/isis_cli.c index 41632b0a75..bb403650bc 100644 --- a/isisd/isis_cli.c +++ b/isisd/isis_cli.c @@ -322,6 +322,67 @@ void cli_show_isis_area_address(struct vty *vty, struct lyd_node *dnode, vty_out(vty, " net %s\n", yang_dnode_get_string(dnode, NULL)); } +/* + * XPath: /frr-isisd:isis/instance/is-type + */ +DEFPY(is_type, is_type_cmd, "is-type $level", + "IS Level for this routing process (OSI only)\n" + "Act as a station router only\n" + "Act as both a station router and an area router\n" + "Act as an area router only\n") +{ + nb_cli_enqueue_change(vty, "./is-type", NB_OP_MODIFY, + strmatch(level, "level-2-only") ? "level-2" + : level); + + return nb_cli_apply_changes(vty, NULL); +} + +DEFPY(no_is_type, no_is_type_cmd, + "no is-type []", + NO_STR + "IS Level for this routing process (OSI only)\n" + "Act as a station router only\n" + "Act as both a station router and an area router\n" + "Act as an area router only\n") +{ + const char *value = NULL; + const struct lyd_node *dnode = + yang_dnode_get(running_config->dnode, VTY_CURR_XPATH); + struct isis_area *area = yang_dnode_get_entry(dnode, false); + + /* + * Put the is-type back to defaults: + * - level-1-2 on first area + * - level-1 for the rest + */ + if (area && listgetdata(listhead(isis->area_list)) == area) + value = "level-1-2"; + else + value = NULL; + nb_cli_enqueue_change(vty, "./is-type", NB_OP_MODIFY, value); + + return nb_cli_apply_changes(vty, NULL); +} + +void cli_show_isis_is_type(struct vty *vty, struct lyd_node *dnode, + bool show_defaults) +{ + int is_type = yang_dnode_get_enum(dnode, NULL); + + switch (is_type) { + case IS_LEVEL_1: + vty_out(vty, " is-type level-1\n"); + break; + case IS_LEVEL_2: + vty_out(vty, " is-type level-2-only\n"); + break; + case IS_LEVEL_1_AND_2: + vty_out(vty, " is-type level-1-2\n"); + break; + } +} + void isis_cli_init(void) { install_element(CONFIG_NODE, &router_isis_cmd); @@ -332,6 +393,9 @@ void isis_cli_init(void) install_element(INTERFACE_NODE, &no_ip_router_isis_cmd); install_element(ISIS_NODE, &net_cmd); + + install_element(ISIS_NODE, &is_type_cmd); + install_element(ISIS_NODE, &no_is_type_cmd); } #endif /* ifndef FABRICD */ diff --git a/isisd/isis_cli.h b/isisd/isis_cli.h index b052f75c27..ebec8f3a61 100644 --- a/isisd/isis_cli.h +++ b/isisd/isis_cli.h @@ -29,5 +29,7 @@ void cli_show_ip_isis_ipv6(struct vty *vty, struct lyd_node *dnode, bool show_defaults); void cli_show_isis_area_address(struct vty *vty, struct lyd_node *dnode, bool show_defaults); +void cli_show_isis_is_type(struct vty *vty, struct lyd_node *dnode, + bool show_defaults); #endif /* ISISD_ISIS_CLI_H_ */ diff --git a/isisd/isis_northbound.c b/isisd/isis_northbound.c index 10f8f1e75c..3c115b4354 100644 --- a/isisd/isis_northbound.c +++ b/isisd/isis_northbound.c @@ -1708,6 +1708,7 @@ const struct frr_yang_module_info frr_isisd_info = { { .xpath = "/frr-isisd:isis/instance/is-type", .cbs.modify = isis_instance_is_type_modify, + .cbs.cli_show = cli_show_isis_is_type, }, { .xpath = "/frr-isisd:isis/instance/area-address", diff --git a/isisd/isis_vty_isisd.c b/isisd/isis_vty_isisd.c index 95aaeae816..b28d2c1708 100644 --- a/isisd/isis_vty_isisd.c +++ b/isisd/isis_vty_isisd.c @@ -605,56 +605,6 @@ DEFUN (no_dynamic_hostname, return CMD_SUCCESS; } -DEFUN (is_type, - is_type_cmd, - "is-type ", - "IS Level for this routing process (OSI only)\n" - "Act as a station router only\n" - "Act as both a station router and an area router\n" - "Act as an area router only\n") -{ - int idx_level = 1; - VTY_DECLVAR_CONTEXT(isis_area, area); - int type; - - type = string2circuit_t(argv[idx_level]->arg); - if (!type) { - vty_out(vty, "Unknown IS level \n"); - return CMD_SUCCESS; - } - - isis_area_is_type_set(area, type); - - return CMD_SUCCESS; -} - -DEFUN (no_is_type, - no_is_type_cmd, - "no is-type ", - NO_STR - "IS Level for this routing process (OSI only)\n" - "Act as a station router only\n" - "Act as both a station router and an area router\n" - "Act as an area router only\n") -{ - VTY_DECLVAR_CONTEXT(isis_area, area); - int type; - - /* - * Put the is-type back to defaults: - * - level-1-2 on first area - * - level-1 for the rest - */ - if (listgetdata(listhead(isis->area_list)) == area) - type = IS_LEVEL_1_AND_2; - else - type = IS_LEVEL_1; - - isis_area_is_type_set(area, type); - - return CMD_SUCCESS; -} - DEFUN (lsp_gen_interval_level, lsp_gen_interval_level_cmd, "lsp-gen-interval (1-120)", @@ -838,9 +788,6 @@ void isis_vty_daemon_init(void) install_element(ROUTER_NODE, &dynamic_hostname_cmd); install_element(ROUTER_NODE, &no_dynamic_hostname_cmd); - install_element(ROUTER_NODE, &is_type_cmd); - install_element(ROUTER_NODE, &no_is_type_cmd); - install_element(ROUTER_NODE, &lsp_gen_interval_level_cmd); install_element(ROUTER_NODE, &no_lsp_gen_interval_level_cmd);