]> git.puffer.fish Git - mirror/frr.git/commitdiff
pbrd: Allow autocompletion for pbr-map PBRMAP 4484/head
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 5 Jun 2019 10:51:08 +0000 (06:51 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 5 Jun 2019 10:51:08 +0000 (06:51 -0400)
Allow the end user to auto-complete the pbr-map name.

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

index 8e1683565c4f1b192d144cd084a856076d2dcef1..a71c712ea71e9b28584721e2c40dfa362d979241 100644 (file)
@@ -38,7 +38,7 @@
 #include "pbrd/pbr_vty_clippy.c"
 #endif
 
-DEFUN_NOSH(pbr_map, pbr_map_cmd, "pbr-map WORD seq (1-700)",
+DEFUN_NOSH(pbr_map, pbr_map_cmd, "pbr-map PBRMAP seq (1-700)",
           "Create pbr-map or enter pbr-map command mode\n"
           "The name of the PBR MAP\n"
           "Sequence to insert in existing pbr-map entry\n"
@@ -54,7 +54,7 @@ DEFUN_NOSH(pbr_map, pbr_map_cmd, "pbr-map WORD seq (1-700)",
        return CMD_SUCCESS;
 }
 
-DEFUN_NOSH(no_pbr_map, no_pbr_map_cmd, "no pbr-map WORD [seq (1-700)]",
+DEFUN_NOSH(no_pbr_map, no_pbr_map_cmd, "no pbr-map PBRMAP [seq (1-700)]",
           NO_STR
           "Delete pbr-map\n"
           "The name of the PBR MAP\n"
@@ -348,7 +348,7 @@ DEFPY(pbr_map_nexthop, pbr_map_nexthop_cmd,
 
 DEFPY (pbr_policy,
        pbr_policy_cmd,
-       "[no] pbr-policy NAME$mapname",
+       "[no] pbr-policy PBRMAP$mapname",
        NO_STR
        "Policy to use\n"
        "Name of the pbr-map to apply\n")
@@ -661,8 +661,27 @@ static int pbr_vty_map_config_write(struct vty *vty)
        return 1;
 }
 
+static void pbr_map_completer(vector comps, struct cmd_token *token)
+{
+       struct pbr_map *pbrm;
+
+       RB_FOREACH (pbrm, pbr_map_entry_head, &pbr_maps)
+               vector_set(comps, XSTRDUP(MTYPE_COMPLETION, pbrm->name));
+}
+
+static const struct cmd_variable_handler pbr_map_name[] = {
+       {
+               .tokenname = "PBRMAP", .completions = pbr_map_completer,
+       },
+       {
+               .completions = NULL
+       }
+};
+
 void pbr_vty_init(void)
 {
+       cmd_variable_handler_register(pbr_map_name);
+
        install_node(&interface_node,
                     pbr_interface_config_write);
        if_cmd_init();
index 05ffeecf1857a4e6c43a25ff93cc65febbcc00cf..c3aeb27eb950018a66214a7e6080ae02b38747aa 100644 (file)
@@ -1678,7 +1678,7 @@ DEFUNSH(VTYSH_RMAP, vtysh_route_map, vtysh_route_map_cmd,
 }
 
 DEFUNSH(VTYSH_PBRD, vtysh_pbr_map, vtysh_pbr_map_cmd,
-       "pbr-map NAME seq (1-700)",
+       "pbr-map PBRMAP seq (1-700)",
        "Create pbr-map or enter pbr-map command mode\n"
        "The name of the PBR MAP\n"
        "Sequence to insert to/delete from existing pbr-map entry\n"
@@ -1714,7 +1714,7 @@ DEFUNSH(VTYSH_BFDD, bfd_peer_enter, bfd_peer_enter_cmd,
 }
 #endif /* HAVE_BFDD */
 
-DEFSH(VTYSH_PBRD, vtysh_no_pbr_map_cmd, "no pbr-map WORD [seq (1-700)]",
+DEFSH(VTYSH_PBRD, vtysh_no_pbr_map_cmd, "no pbr-map PBRMAP [seq (1-700)]",
        NO_STR
        "Delete pbr-map\n"
        "The name of  the PBR MAP\n"