diff options
author | Donald Sharp <donaldsharp72@gmail.com> | 2022-10-13 19:47:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-13 19:47:04 +0200 |
commit | e3e3d729c42505910e0b396899bfd50e2d7b2404 (patch) | |
tree | fa49a9c2839a88ef7ec339b76e0fe99913c818c9 | |
parent | Merge pull request #12115 from donaldsharp/ospf_unnumbered_showdown (diff) | |
parent | python: use ujson if available (diff) | |
download | frr-e3e3d729c42505910e0b396899bfd50e2d7b2404.tar.xz frr-e3e3d729c42505910e0b396899bfd50e2d7b2404.zip |
Merge pull request #12066 from opensourcerouting/cleanup-cli-xref
*: clean up various CLI-related bits
-rw-r--r-- | bgpd/bgp_vty.c | 2 | ||||
-rw-r--r-- | ldpd/ldp_vty_cmds.c | 2 | ||||
-rw-r--r-- | lib/command.c | 20 | ||||
-rw-r--r-- | lib/command.h | 86 | ||||
-rw-r--r-- | lib/command_graph.c | 5 | ||||
-rw-r--r-- | lib/command_graph.h | 9 | ||||
-rw-r--r-- | lib/command_match.c | 3 | ||||
-rw-r--r-- | lib/command_py.c | 10 | ||||
-rw-r--r-- | lib/grammar_sandbox.c | 3 | ||||
-rw-r--r-- | lib/log_vty.c | 4 | ||||
-rw-r--r-- | pimd/pim6_mld.c | 4 | ||||
-rw-r--r-- | pimd/pim_cmd.c | 2 | ||||
-rw-r--r-- | python/clippy/__init__.py | 24 | ||||
-rw-r--r-- | python/makefile.py | 3 | ||||
-rw-r--r-- | python/xrelfo.py | 29 | ||||
-rw-r--r-- | tools/permutations.c | 3 | ||||
-rw-r--r-- | vrrpd/vrrp_vty.c | 8 | ||||
-rw-r--r-- | vtysh/vtysh.c | 4 | ||||
-rw-r--r-- | zebra/zebra_fpm.c | 28 |
19 files changed, 138 insertions, 111 deletions
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index b85f3707b..e574ae780 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -5816,7 +5816,7 @@ ALIAS_HIDDEN(neighbor_remove_private_as_all, "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Remove private ASNs in outbound updates\n" - "Apply to all AS numbers") + "Apply to all AS numbers\n") DEFUN (neighbor_remove_private_as_replace_as, neighbor_remove_private_as_replace_as_cmd, diff --git a/ldpd/ldp_vty_cmds.c b/ldpd/ldp_vty_cmds.c index 3795cdaf3..3d11d3137 100644 --- a/ldpd/ldp_vty_cmds.c +++ b/ldpd/ldp_vty_cmds.c @@ -246,7 +246,7 @@ DEFPY (ldp_allow_broken_lsps, "[no] install allow-broken-lsps", NO_STR "install lsps\n" - "if no remote-label install with imp-null") + "if no remote-label install with imp-null\n") { return (ldp_vty_allow_broken_lsp(vty, no)); } diff --git a/lib/command.c b/lib/command.c index 7e171cb30..1fae32a04 100644 --- a/lib/command.c +++ b/lib/command.c @@ -265,8 +265,7 @@ void install_node(struct cmd_node *node) node->cmdgraph = graph_new(); node->cmd_vector = vector_init(VECTOR_MIN_SIZE); // add start node - struct cmd_token *token = - cmd_token_new(START_TKN, CMD_ATTR_NORMAL, NULL, NULL); + struct cmd_token *token = cmd_token_new(START_TKN, 0, NULL, NULL); graph_new_node(node->cmdgraph, token, (void (*)(void *)) & cmd_token_del); @@ -326,7 +325,7 @@ void _install_element(enum node_type ntype, const struct cmd_element *cmd) if (cnode->graph_built || !defer_cli_tree) { struct graph *graph = graph_new(); struct cmd_token *token = - cmd_token_new(START_TKN, CMD_ATTR_NORMAL, NULL, NULL); + cmd_token_new(START_TKN, 0, NULL, NULL); graph_new_node(graph, token, (void (*)(void *)) & cmd_token_del); @@ -349,8 +348,7 @@ static void cmd_finalize_iter(struct hash_bucket *hb, void *arg) struct cmd_node *cnode = arg; const struct cmd_element *cmd = hb->data; struct graph *graph = graph_new(); - struct cmd_token *token = - cmd_token_new(START_TKN, CMD_ATTR_NORMAL, NULL, NULL); + struct cmd_token *token = cmd_token_new(START_TKN, 0, NULL, NULL); graph_new_node(graph, token, (void (*)(void *)) & cmd_token_del); @@ -405,7 +403,7 @@ void uninstall_element(enum node_type ntype, const struct cmd_element *cmd) if (cnode->graph_built) { struct graph *graph = graph_new(); struct cmd_token *token = - cmd_token_new(START_TKN, CMD_ATTR_NORMAL, NULL, NULL); + cmd_token_new(START_TKN, 0, NULL, NULL); graph_new_node(graph, token, (void (*)(void *)) & cmd_token_del); @@ -991,7 +989,7 @@ static int cmd_execute_command_real(vector vline, enum cmd_filter_type filter, * Perform pending commit (if any) before executing * non-YANG command. */ - if (matched_element->attr != CMD_ATTR_YANG) + if (!(matched_element->attr & CMD_ATTR_YANG)) (void)nb_cli_pending_commit_check(vty); } @@ -1472,8 +1470,7 @@ static void permute(struct graph_node *start, struct vty *vty) for (unsigned int i = 0; i < vector_active(start->to); i++) { struct graph_node *gn = vector_slot(start->to, i); struct cmd_token *tok = gn->data; - if (tok->attr == CMD_ATTR_HIDDEN - || tok->attr == CMD_ATTR_DEPRECATED) + if (tok->attr & CMD_ATTR_HIDDEN) continue; else if (tok->type == END_TKN || gn == start) { vty_out(vty, " "); @@ -1562,9 +1559,8 @@ int cmd_list_cmds(struct vty *vty, int do_permute) const struct cmd_element *element = NULL; for (unsigned int i = 0; i < vector_active(node->cmd_vector); i++) - if ((element = vector_slot(node->cmd_vector, i)) - && element->attr != CMD_ATTR_DEPRECATED - && element->attr != CMD_ATTR_HIDDEN) { + if ((element = vector_slot(node->cmd_vector, i)) && + !(element->attr & CMD_ATTR_HIDDEN)) { vty_out(vty, " "); print_cmd(vty, element->string); } diff --git a/lib/command.h b/lib/command.h index 42b440621..f4168dedd 100644 --- a/lib/command.h +++ b/lib/command.h @@ -280,17 +280,18 @@ struct cmd_node { int argc __attribute__((unused)), \ struct cmd_token *argv[] __attribute__((unused))) -#define DEFPY(funcname, cmdname, cmdstr, helpstr) \ - DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, 0) \ - funcdecl_##funcname - -#define DEFPY_NOSH(funcname, cmdname, cmdstr, helpstr) \ - DEFPY(funcname, cmdname, cmdstr, helpstr) +/* DEFPY variants */ #define DEFPY_ATTR(funcname, cmdname, cmdstr, helpstr, attr) \ DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attr, 0) \ funcdecl_##funcname +#define DEFPY(funcname, cmdname, cmdstr, helpstr) \ + DEFPY_ATTR(funcname, cmdname, cmdstr, helpstr, 0) + +#define DEFPY_NOSH(funcname, cmdname, cmdstr, helpstr) \ + DEFPY_ATTR(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_NOSH) + #define DEFPY_HIDDEN(funcname, cmdname, cmdstr, helpstr) \ DEFPY_ATTR(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_HIDDEN) @@ -298,18 +299,19 @@ struct cmd_node { DEFPY_ATTR(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_YANG) #define DEFPY_YANG_NOSH(funcname, cmdname, cmdstr, helpstr) \ - DEFPY_YANG(funcname, cmdname, cmdstr, helpstr) + DEFPY_ATTR(funcname, cmdname, cmdstr, helpstr, \ + CMD_ATTR_YANG | CMD_ATTR_NOSH) -#define DEFUN(funcname, cmdname, cmdstr, helpstr) \ - DEFUN_CMD_FUNC_DECL(funcname) \ - DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, 0) \ - DEFUN_CMD_FUNC_TEXT(funcname) +/* DEFUN variants */ #define DEFUN_ATTR(funcname, cmdname, cmdstr, helpstr, attr) \ DEFUN_CMD_FUNC_DECL(funcname) \ DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attr, 0) \ DEFUN_CMD_FUNC_TEXT(funcname) +#define DEFUN(funcname, cmdname, cmdstr, helpstr) \ + DEFUN_ATTR(funcname, cmdname, cmdstr, helpstr, 0) + #define DEFUN_HIDDEN(funcname, cmdname, cmdstr, helpstr) \ DEFUN_ATTR(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_HIDDEN) @@ -318,73 +320,55 @@ struct cmd_node { /* DEFUN_NOSH for commands that vtysh should ignore */ #define DEFUN_NOSH(funcname, cmdname, cmdstr, helpstr) \ - DEFUN(funcname, cmdname, cmdstr, helpstr) + DEFUN_ATTR(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_NOSH) #define DEFUN_YANG_NOSH(funcname, cmdname, cmdstr, helpstr) \ - DEFUN_YANG(funcname, cmdname, cmdstr, helpstr) + DEFUN_ATTR(funcname, cmdname, cmdstr, helpstr, \ + CMD_ATTR_YANG | CMD_ATTR_NOSH) /* DEFSH for vtysh. */ +#define DEFSH_ATTR(daemon, cmdname, cmdstr, helpstr, attr) \ + DEFUN_CMD_ELEMENT(NULL, cmdname, cmdstr, helpstr, attr, daemon) + #define DEFSH(daemon, cmdname, cmdstr, helpstr) \ - DEFUN_CMD_ELEMENT(NULL, cmdname, cmdstr, helpstr, 0, daemon) + DEFSH_ATTR(daemon, cmdname, cmdstr, helpstr, 0) #define DEFSH_HIDDEN(daemon, cmdname, cmdstr, helpstr) \ - DEFUN_CMD_ELEMENT(NULL, cmdname, cmdstr, helpstr, CMD_ATTR_HIDDEN, \ - daemon) - -#define DEFSH_YANG(daemon, cmdname, cmdstr, helpstr) \ - DEFUN_CMD_ELEMENT(NULL, cmdname, cmdstr, helpstr, CMD_ATTR_YANG, daemon) + DEFSH_ATTR(daemon, cmdname, cmdstr, helpstr, CMD_ATTR_HIDDEN) /* DEFUN + DEFSH */ -#define DEFUNSH(daemon, funcname, cmdname, cmdstr, helpstr) \ - DEFUN_CMD_FUNC_DECL(funcname) \ - DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, daemon) \ - DEFUN_CMD_FUNC_TEXT(funcname) - -/* DEFUN + DEFSH with attributes */ #define DEFUNSH_ATTR(daemon, funcname, cmdname, cmdstr, helpstr, attr) \ DEFUN_CMD_FUNC_DECL(funcname) \ DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attr, daemon) \ DEFUN_CMD_FUNC_TEXT(funcname) +#define DEFUNSH(daemon, funcname, cmdname, cmdstr, helpstr) \ + DEFUNSH_ATTR(daemon, funcname, cmdname, cmdstr, helpstr, 0) + #define DEFUNSH_HIDDEN(daemon, funcname, cmdname, cmdstr, helpstr) \ DEFUNSH_ATTR(daemon, funcname, cmdname, cmdstr, helpstr, \ CMD_ATTR_HIDDEN) -#define DEFUNSH_DEPRECATED(daemon, funcname, cmdname, cmdstr, helpstr) \ - DEFUNSH_ATTR(daemon, funcname, cmdname, cmdstr, helpstr, \ - CMD_ATTR_DEPRECATED) - -#define DEFUNSH_YANG(daemon, funcname, cmdname, cmdstr, helpstr) \ - DEFUNSH_ATTR(daemon, funcname, cmdname, cmdstr, helpstr, CMD_ATTR_YANG) - /* ALIAS macro which define existing command's alias. */ -#define ALIAS(funcname, cmdname, cmdstr, helpstr) \ - DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, 0) - #define ALIAS_ATTR(funcname, cmdname, cmdstr, helpstr, attr) \ DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, attr, 0) +#define ALIAS(funcname, cmdname, cmdstr, helpstr) \ + ALIAS_ATTR(funcname, cmdname, cmdstr, helpstr, 0) + #define ALIAS_HIDDEN(funcname, cmdname, cmdstr, helpstr) \ - DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_HIDDEN, \ - 0) + ALIAS_ATTR(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_HIDDEN) +/* note: DEPRECATED implies HIDDEN, and other than that there is currently no + * difference. It's purely for expressing intent in the source code - a + * DEPRECATED command is supposed to go away, a HIDDEN one is likely to stay. + */ #define ALIAS_DEPRECATED(funcname, cmdname, cmdstr, helpstr) \ - DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, \ - CMD_ATTR_DEPRECATED, 0) + ALIAS_ATTR(funcname, cmdname, cmdstr, helpstr, \ + CMD_ATTR_DEPRECATED | CMD_ATTR_HIDDEN) #define ALIAS_YANG(funcname, cmdname, cmdstr, helpstr) \ - DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_YANG, 0) - -#define ALIAS_SH(daemon, funcname, cmdname, cmdstr, helpstr) \ - DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, daemon) - -#define ALIAS_SH_HIDDEN(daemon, funcname, cmdname, cmdstr, helpstr) \ - DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_HIDDEN, \ - daemon) - -#define ALIAS_SH_DEPRECATED(daemon, funcname, cmdname, cmdstr, helpstr) \ - DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, \ - CMD_ATTR_DEPRECATED, daemon) + ALIAS_ATTR(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_YANG) #endif /* VTYSH_EXTRACT_PL */ diff --git a/lib/command_graph.c b/lib/command_graph.c index 09d802e79..e94068525 100644 --- a/lib/command_graph.c +++ b/lib/command_graph.c @@ -494,9 +494,10 @@ void cmd_graph_node_print_cb(struct graph_node *gn, struct buffer *buf) snprintf(nbuf, sizeof(nbuf), "<b>%s</b>", lookup_msg(tokennames, tok->type, NULL)); buffer_putstr(buf, nbuf); - if (tok->attr == CMD_ATTR_DEPRECATED) + if (tok->attr & CMD_ATTR_DEPRECATED) buffer_putstr(buf, " (d)"); - else if (tok->attr == CMD_ATTR_HIDDEN) + /* DEPRECATED implies HIDDEN, don't print both */ + else if (tok->attr & CMD_ATTR_HIDDEN) buffer_putstr(buf, " (h)"); if (tok->text) { if (tok->type == WORD_TKN) diff --git a/lib/command_graph.h b/lib/command_graph.h index ed4da6aa4..b8c7a9c72 100644 --- a/lib/command_graph.h +++ b/lib/command_graph.h @@ -73,10 +73,11 @@ enum cmd_token_type { #define IS_VARYING_TOKEN(x) ((x) >= VARIABLE_TKN && (x) < FORK_TKN) /* Command attributes */ -enum { CMD_ATTR_NORMAL, - CMD_ATTR_DEPRECATED, - CMD_ATTR_HIDDEN, - CMD_ATTR_YANG, +enum { + CMD_ATTR_YANG = (1 << 0), + CMD_ATTR_HIDDEN = (1 << 1), + CMD_ATTR_DEPRECATED = (1 << 2), + CMD_ATTR_NOSH = (1 << 3), }; enum varname_src { diff --git a/lib/command_match.c b/lib/command_match.c index f221e0a02..ce2dbc952 100644 --- a/lib/command_match.c +++ b/lib/command_match.c @@ -395,8 +395,7 @@ enum matcher_rv command_complete(struct graph *graph, vector vline, for (ALL_LIST_ELEMENTS_RO(current, node, gstack)) { struct cmd_token *token = gstack[0]->data; - if (token->attr == CMD_ATTR_HIDDEN - || token->attr == CMD_ATTR_DEPRECATED) + if (token->attr & CMD_ATTR_HIDDEN) continue; enum match_type minmatch = min_match_level(token->type); diff --git a/lib/command_py.c b/lib/command_py.c index 6301eec5e..cce9542e3 100644 --- a/lib/command_py.c +++ b/lib/command_py.c @@ -226,8 +226,8 @@ static PyObject *graph_to_pyobj(struct wrap_graph *wgraph, wrap->type = "???"; } - wrap->deprecated = (tok->attr == CMD_ATTR_DEPRECATED); - wrap->hidden = (tok->attr == CMD_ATTR_HIDDEN); + wrap->deprecated = !!(tok->attr & CMD_ATTR_DEPRECATED); + wrap->hidden = !!(tok->attr & CMD_ATTR_HIDDEN); wrap->text = tok->text; wrap->desc = tok->desc; wrap->varname = tok->varname; @@ -353,6 +353,12 @@ PyMODINIT_FUNC command_py_init(void) if (!pymod) initret(NULL); + if (PyModule_AddIntMacro(pymod, CMD_ATTR_YANG) + || PyModule_AddIntMacro(pymod, CMD_ATTR_HIDDEN) + || PyModule_AddIntMacro(pymod, CMD_ATTR_DEPRECATED) + || PyModule_AddIntMacro(pymod, CMD_ATTR_NOSH)) + initret(NULL); + Py_INCREF(&typeobj_graph_node); PyModule_AddObject(pymod, "GraphNode", (PyObject *)&typeobj_graph_node); Py_INCREF(&typeobj_graph); diff --git a/lib/grammar_sandbox.c b/lib/grammar_sandbox.c index f9778c5d4..8fa47c053 100644 --- a/lib/grammar_sandbox.c +++ b/lib/grammar_sandbox.c @@ -76,8 +76,7 @@ DEFUN (grammar_test, // parse the command and install it into the command graph struct graph *graph = graph_new(); - struct cmd_token *token = - cmd_token_new(START_TKN, CMD_ATTR_NORMAL, NULL, NULL); + struct cmd_token *token = cmd_token_new(START_TKN, 0, NULL, NULL); graph_new_node(graph, token, (void (*)(void *)) & cmd_token_del); cmd_graph_parse(graph, cmd); diff --git a/lib/log_vty.c b/lib/log_vty.c index 81280f302..c9268734c 100644 --- a/lib/log_vty.c +++ b/lib/log_vty.c @@ -761,8 +761,8 @@ DEFPY (log_immediate_mode, log_immediate_mode_cmd, "[no] log immediate-mode", NO_STR - "Logging control" - "Output immediately, without buffering") + "Logging control\n" + "Output immediately, without buffering\n") { zlog_set_immediate(!no); return CMD_SUCCESS; diff --git a/pimd/pim6_mld.c b/pimd/pim6_mld.c index 23042ef14..c34c78296 100644 --- a/pimd/pim6_mld.c +++ b/pimd/pim6_mld.c @@ -2997,9 +2997,9 @@ DEFPY(gm_debug_show, "debug show mld interface IFNAME", DEBUG_STR SHOW_STR - "MLD" + MLD_STR INTERFACE_STR - "interface name") + "interface name\n") { struct interface *ifp; struct pim_interface *pim_ifp; diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 1ac22f38a..ab0689a15 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -5438,7 +5438,7 @@ DEFPY(no_ip_msdp_mesh_group, IP_STR CFG_MSDP_STR "Delete MSDP mesh-group\n" - "Mesh group name") + "Mesh group name\n") { const char *vrfname; char xpath_value[XPATH_MAXLEN]; diff --git a/python/clippy/__init__.py b/python/clippy/__init__.py index 344a1c91e..281e2bb3c 100644 --- a/python/clippy/__init__.py +++ b/python/clippy/__init__.py @@ -17,8 +17,23 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import os, stat + +try: + from enum import IntFlag as _IntFlag +except ImportError: + # python <3.6 + from enum import IntEnum as _IntFlag # type: ignore + import _clippy -from _clippy import parse, Graph, GraphNode +from _clippy import ( + parse, + Graph, + GraphNode, + CMD_ATTR_YANG, + CMD_ATTR_HIDDEN, + CMD_ATTR_DEPRECATED, + CMD_ATTR_NOSH, +) frr_top_src = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) @@ -78,3 +93,10 @@ def wrdiff(filename, buf, reffiles=[]): with open(newname, "w") as out: out.write(buf) os.rename(newname, filename) + + +class CmdAttr(_IntFlag): + YANG = CMD_ATTR_YANG + HIDDEN = CMD_ATTR_HIDDEN + DEPRECATED = CMD_ATTR_DEPRECATED + NOSH = CMD_ATTR_NOSH diff --git a/python/makefile.py b/python/makefile.py index afc993b5b..bd897b750 100644 --- a/python/makefile.py +++ b/python/makefile.py @@ -160,6 +160,9 @@ for clippy_file in clippy_scan: # combine daemon .xref files into frr.xref out_lines.append("") +xref_targets = [ + target for target in xref_targets if target not in ["tools/ssd", "vtysh/vtysh"] +] out_lines.append( "xrefs = %s" % (" ".join(["%s.xref" % target for target in xref_targets])) ) diff --git a/python/xrelfo.py b/python/xrelfo.py index 17262da8d..09455ea9b 100644 --- a/python/xrelfo.py +++ b/python/xrelfo.py @@ -21,12 +21,21 @@ import os import struct import re import traceback -import json + +json_dump_args = {} + +try: + import ujson as json + + json_dump_args["escape_forward_slashes"] = False +except ImportError: + import json + import argparse from clippy.uidhash import uidhash from clippy.elf import * -from clippy import frr_top_src +from clippy import frr_top_src, CmdAttr from tiabwarfo import FieldApplicator try: @@ -196,8 +205,6 @@ Xref.containers[XREFT_LOGMSG] = XrefLogmsg class CmdElement(ELFDissectStruct, XrelfoJson): struct = 'cmd_element' - cmd_attrs = { 0: None, 1: 'deprecated', 2: 'hidden'} - def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -207,10 +214,14 @@ class CmdElement(ELFDissectStruct, XrelfoJson): jsobj.update({ 'string': self.string, 'doc': self.doc, - 'attr': self.cmd_attrs.get(self.attr, self.attr), }) - if jsobj['attr'] is None: - del jsobj['attr'] + if self.attr: + jsobj['attr'] = attr = self.attr + for attrname in CmdAttr.__members__: + val = CmdAttr[attrname] + if attr & val: + jsobj.setdefault('attrs', []).append(attrname.lower()) + attr &= ~val jsobj['defun'] = dict([(i, getattr(self.xref, i)) for i in ['file', 'line', 'func']]) @@ -416,12 +427,12 @@ def _main(args): if args.output: with open(args.output + '.tmp', 'w') as fd: - json.dump(out, fd, indent=2, sort_keys=True) + json.dump(out, fd, indent=2, sort_keys=True, **json_dump_args) os.rename(args.output + '.tmp', args.output) if args.out_by_file: with open(args.out_by_file + '.tmp', 'w') as fd: - json.dump(outbyfile, fd, indent=2, sort_keys=True) + json.dump(outbyfile, fd, indent=2, sort_keys=True, **json_dump_args) os.rename(args.out_by_file + '.tmp', args.out_by_file) if __name__ == '__main__': diff --git a/tools/permutations.c b/tools/permutations.c index b280cc15b..a0b041f2f 100644 --- a/tools/permutations.c +++ b/tools/permutations.c @@ -80,8 +80,7 @@ void permute(struct graph_node *start) for (unsigned int i = 0; i < vector_active(start->to); i++) { struct graph_node *gn = vector_slot(start->to, i); struct cmd_token *tok = gn->data; - if (tok->attr == CMD_ATTR_HIDDEN - || tok->attr == CMD_ATTR_DEPRECATED) + if (tok->attr & CMD_ATTR_HIDDEN) continue; else if (tok->type == END_TKN || gn == start) { fprintf(stdout, " "); diff --git a/vrrpd/vrrp_vty.c b/vrrpd/vrrp_vty.c index d2f25f2d4..aea7d9abc 100644 --- a/vrrpd/vrrp_vty.c +++ b/vrrpd/vrrp_vty.c @@ -121,7 +121,7 @@ DEFPY_YANG(vrrp_priority, VRRP_STR VRRP_VRID_STR VRRP_PRIORITY_STR - "Priority value") + "Priority value\n") { nb_cli_enqueue_change(vty, "./priority", NB_OP_MODIFY, priority_str); @@ -138,7 +138,7 @@ DEFPY_YANG(no_vrrp_priority, VRRP_STR VRRP_VRID_STR VRRP_PRIORITY_STR - "Priority value") + "Priority value\n") { nb_cli_enqueue_change(vty, "./priority", NB_OP_MODIFY, NULL); @@ -162,7 +162,7 @@ DEFPY_YANG(vrrp_advertisement_interval, vrrp_advertisement_interval_cmd, "vrrp (1-255)$vrid advertisement-interval (10-40950)", VRRP_STR VRRP_VRID_STR VRRP_ADVINT_STR - "Advertisement interval in milliseconds; must be multiple of 10") + "Advertisement interval in milliseconds; must be multiple of 10\n") { char val[20]; @@ -183,7 +183,7 @@ DEFPY_YANG(no_vrrp_advertisement_interval, no_vrrp_advertisement_interval_cmd, "no vrrp (1-255)$vrid advertisement-interval [(10-40950)]", NO_STR VRRP_STR VRRP_VRID_STR VRRP_ADVINT_STR - "Advertisement interval in milliseconds; must be multiple of 10") + "Advertisement interval in milliseconds; must be multiple of 10\n") { nb_cli_enqueue_change(vty, "./advertisement-interval", NB_OP_MODIFY, NULL); diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index f39ecf070..48274d717 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -2951,7 +2951,7 @@ DEFUN_HIDDEN (show_config_running, show_config_running_cmd, "show configuration running\ [<json|xml> [translate WORD]]\ - [with-defaults]" DAEMONS_LIST, + [with-defaults] " DAEMONS_LIST, SHOW_STR "Configuration information\n" "Running configuration\n" @@ -2972,7 +2972,7 @@ DEFUN (show_yang_operational_data, format <json|xml>\ |translate WORD\ |with-config\ - }]" DAEMONS_LIST, + }] " DAEMONS_LIST, SHOW_STR "YANG information\n" "Show YANG operational data\n" diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c index 1b2753377..c74c692ee 100644 --- a/zebra/zebra_fpm.c +++ b/zebra/zebra_fpm.c @@ -1841,12 +1841,15 @@ DEFUN (clear_zebra_fpm_stats, /* * update fpm connection information */ -DEFUN ( fpm_remote_ip, +DEFUN (fpm_remote_ip, fpm_remote_ip_cmd, - "fpm connection ip A.B.C.D port (1-65535)", - "fpm connection remote ip and port\n" - "Remote fpm server ip A.B.C.D\n" - "Enter ip ") + "fpm connection ip A.B.C.D port (1-65535)", + "Forwarding Path Manager\n" + "Configure FPM connection\n" + "Connect to IPv4 address\n" + "Connect to IPv4 address\n" + "TCP port number\n" + "TCP port number\n") { in_addr_t fpm_server; @@ -1867,13 +1870,16 @@ DEFUN ( fpm_remote_ip, return CMD_SUCCESS; } -DEFUN ( no_fpm_remote_ip, +DEFUN (no_fpm_remote_ip, no_fpm_remote_ip_cmd, - "no fpm connection ip A.B.C.D port (1-65535)", - "fpm connection remote ip and port\n" - "Connection\n" - "Remote fpm server ip A.B.C.D\n" - "Enter ip ") + "no fpm connection ip A.B.C.D port (1-65535)", + NO_STR + "Forwarding Path Manager\n" + "Remove configured FPM connection\n" + "Connect to IPv4 address\n" + "Connect to IPv4 address\n" + "TCP port number\n" + "TCP port number\n") { if (zfpm_g->fpm_server != inet_addr(argv[4]->arg) || zfpm_g->fpm_port != atoi(argv[6]->arg)) |