]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib, pbrd, sharpd, vtysh: Add autocompletion for 'nexthop-group'
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 5 Jun 2019 10:33:00 +0000 (06:33 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 5 Jun 2019 10:33:00 +0000 (06:33 -0400)
Add some auto-completion for the nexthop-group command

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
lib/nexthop_group.c
pbrd/pbr_vty.c
sharpd/sharp_vty.c
vtysh/vtysh.c

index ed22f64494b40a4e158072b7418a1a6e2362d3b6..10f610db377dd30ff6561e48a142615cb58c38ec 100644 (file)
@@ -308,7 +308,7 @@ static void nhgc_delete(struct nexthop_group_cmd *nhgc)
 
 DEFINE_QOBJ_TYPE(nexthop_group_cmd)
 
-DEFUN_NOSH(nexthop_group, nexthop_group_cmd, "nexthop-group NAME",
+DEFUN_NOSH(nexthop_group, nexthop_group_cmd, "nexthop-group NHGNAME",
           "Enter into the nexthop-group submode\n"
           "Specify the NAME of the nexthop-group\n")
 {
@@ -321,7 +321,7 @@ DEFUN_NOSH(nexthop_group, nexthop_group_cmd, "nexthop-group NAME",
        return CMD_SUCCESS;
 }
 
-DEFUN_NOSH(no_nexthop_group, no_nexthop_group_cmd, "no nexthop-group NAME",
+DEFUN_NOSH(no_nexthop_group, no_nexthop_group_cmd, "no nexthop-group NHGNAME",
           NO_STR
           "Delete the nexthop-group\n"
           "Specify the NAME of the nexthop-group\n")
@@ -714,6 +714,19 @@ void nexthop_group_interface_state_change(struct interface *ifp,
        }
 }
 
+static void nhg_name_autocomplete(vector comps, struct cmd_token *token)
+{
+       struct nexthop_group_cmd *nhgc;
+
+       RB_FOREACH (nhgc, nhgc_entry_head, &nhgc_entries) {
+               vector_set(comps, XSTRDUP(MTYPE_COMPLETION, nhgc->name));
+       }
+}
+
+static const struct cmd_variable_handler nhg_name_handlers[] = {
+       {.tokenname = "NHGNAME", .completions = nhg_name_autocomplete},
+       {.completions = NULL}};
+
 void nexthop_group_init(void (*new)(const char *name),
                        void (*add_nexthop)(const struct nexthop_group_cmd *nhg,
                                            const struct nexthop *nhop),
@@ -723,6 +736,8 @@ void nexthop_group_init(void (*new)(const char *name),
 {
        RB_INIT(nhgc_entry_head, &nhgc_entries);
 
+       cmd_variable_handler_register(nhg_name_handlers);
+
        install_node(&nexthop_group_node, nexthop_group_write);
        install_element(CONFIG_NODE, &nexthop_group_cmd);
        install_element(CONFIG_NODE, &no_nexthop_group_cmd);
index 067d5c01fdfac621cebd1a0bf8fdc70dc88d8888..8e1683565c4f1b192d144cd084a856076d2dcef1 100644 (file)
@@ -172,7 +172,7 @@ DEFPY(pbr_map_match_dst, pbr_map_match_dst_cmd,
 }
 
 DEFPY(pbr_map_nexthop_group, pbr_map_nexthop_group_cmd,
-       "[no] set nexthop-group NAME$name",
+       "[no] set nexthop-group NHGNAME$name",
        NO_STR
        "Set for the PBR-MAP\n"
        "nexthop-group to use\n"
index fbcbbe3fdca7119f940b168a69e12b4c4cc4111f..31608dcdb81d02e8f30aa91826acee46fc8b7c6c 100644 (file)
@@ -157,7 +157,7 @@ DEFPY (install_routes_data_dump,
 
 DEFPY (install_routes,
        install_routes_cmd,
-       "sharp install routes [vrf NAME$name] <A.B.C.D$start4|X:X::X:X$start6> <nexthop <A.B.C.D$nexthop4|X:X::X:X$nexthop6>|nexthop-group NAME$nexthop_group> (1-1000000)$routes [instance (0-255)$instance] [repeat (2-1000)$rpt]",
+       "sharp install routes [vrf NAME$name] <A.B.C.D$start4|X:X::X:X$start6> <nexthop <A.B.C.D$nexthop4|X:X::X:X$nexthop6>|nexthop-group NHGNAME$nexthop_group> (1-1000000)$routes [instance (0-255)$instance] [repeat (2-1000)$rpt]",
        "Sharp routing Protocol\n"
        "install some routes\n"
        "Routes to install\n"
index baf77d1cb79606b2fe267e6ea85743ccc0369bb8..05ffeecf1857a4e6c43a25ff93cc65febbcc00cf 100644 (file)
@@ -2114,7 +2114,7 @@ DEFSH(VTYSH_ZEBRA, vtysh_no_logicalrouter_cmd,
       "The file name in " NS_RUN_DIR ", or a full pathname\n")
 
 DEFUNSH(VTYSH_PBRD | VTYSH_SHARPD, vtysh_nexthop_group, vtysh_nexthop_group_cmd,
-       "nexthop-group NAME",
+       "nexthop-group NHGNAME",
        "Nexthop Group configuration\n"
        "Name of the Nexthop Group\n")
 {
@@ -2123,7 +2123,7 @@ DEFUNSH(VTYSH_PBRD | VTYSH_SHARPD, vtysh_nexthop_group, vtysh_nexthop_group_cmd,
 }
 
 DEFSH(VTYSH_PBRD | VTYSH_SHARPD, vtysh_no_nexthop_group_cmd,
-      "no nexthop-group NAME",
+      "no nexthop-group NHGNAME",
       NO_STR
       "Nexthop Group Configuration\n"
       "Name of the Nexthop Group\n")