isisd: retrofit the 'is-type' command

Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
This commit is contained in:
Emanuele Di Pascale 2018-11-13 17:46:30 +01:00
parent f084ea5523
commit e6bdae69de
4 changed files with 67 additions and 53 deletions

View File

@ -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-1|level-1-2|level-2-only>$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 [<level-1|level-1-2|level-2-only>]",
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 */

View File

@ -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_ */

View File

@ -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",

View File

@ -605,56 +605,6 @@ DEFUN (no_dynamic_hostname,
return CMD_SUCCESS;
}
DEFUN (is_type,
is_type_cmd,
"is-type <level-1|level-1-2|level-2-only>",
"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 <level-1|level-1-2|level-2-only>",
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 <level-1|level-2> (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);