bgpd: remove json option from 'sh ip bgp' commands that do not support it

Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
This commit is contained in:
Daniel Walton 2017-08-22 19:11:31 +00:00
parent 318cac96ef
commit 7b2ff25031

View File

@ -8838,32 +8838,28 @@ DEFUN (show_ip_bgp_large_community,
static int bgp_table_stats(struct vty *vty, struct bgp *bgp, afi_t afi, static int bgp_table_stats(struct vty *vty, struct bgp *bgp, afi_t afi,
safi_t safi); safi_t safi);
/* BGP route print out function. */
/* BGP route print out function without JSON */
DEFUN (show_ip_bgp, DEFUN (show_ip_bgp,
show_ip_bgp_cmd, show_ip_bgp_cmd,
"show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]]\ "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]]\
[<\ <dampening <parameters>\
cidr-only\ |route-map WORD\
|dampening <flap-statistics|dampened-paths|parameters>\ |prefix-list WORD\
|route-map WORD\ |filter-list WORD\
|prefix-list WORD\ |statistics\
|filter-list WORD\ |community <AA:NN|local-AS|no-advertise|no-export> [exact-match]\
|statistics\ |community-list <(1-500)|WORD> [exact-match]\
|community [<AA:NN|local-AS|no-advertise|no-export> [exact-match]]\ |A.B.C.D/M longer-prefixes\
|community-list <(1-500)|WORD> [exact-match]\ |X:X::X:X/M longer-prefixes\
|A.B.C.D/M longer-prefixes\ >",
|X:X::X:X/M longer-prefixes>\
] [json]",
SHOW_STR SHOW_STR
IP_STR IP_STR
BGP_STR BGP_STR
BGP_INSTANCE_HELP_STR BGP_INSTANCE_HELP_STR
BGP_AFI_HELP_STR BGP_AFI_HELP_STR
BGP_SAFI_WITH_LABEL_HELP_STR BGP_SAFI_WITH_LABEL_HELP_STR
"Display only routes with non-natural netmasks\n"
"Display detailed information about dampening\n" "Display detailed information about dampening\n"
"Display flap statistics of routes\n"
"Display paths suppressed due to dampening\n"
"Display detail of configured dampening parameters\n" "Display detail of configured dampening parameters\n"
"Display routes matching the route-map\n" "Display routes matching the route-map\n"
"A route-map to match on\n" "A route-map to match on\n"
@ -8885,13 +8881,11 @@ DEFUN (show_ip_bgp,
"IPv4 prefix\n" "IPv4 prefix\n"
"Display route and more specific routes\n" "Display route and more specific routes\n"
"IPv6 prefix\n" "IPv6 prefix\n"
"Display route and more specific routes\n" "Display route and more specific routes\n")
JSON_STR)
{ {
afi_t afi = AFI_IP6; afi_t afi = AFI_IP6;
safi_t safi = SAFI_UNICAST; safi_t safi = SAFI_UNICAST;
int exact_match = 0; int exact_match = 0;
enum bgp_show_type sh_type = bgp_show_type_normal;
struct bgp *bgp = NULL; struct bgp *bgp = NULL;
int idx = 0; int idx = 0;
@ -8900,23 +8894,8 @@ DEFUN (show_ip_bgp,
if (!idx) if (!idx)
return CMD_WARNING; return CMD_WARNING;
int uj = use_json(argc, argv);
if (uj)
argc--;
if (argv_find(argv, argc, "cidr-only", &idx))
return bgp_show(vty, bgp, afi, safi, bgp_show_type_cidr_only,
NULL, uj);
if (argv_find(argv, argc, "dampening", &idx)) { if (argv_find(argv, argc, "dampening", &idx)) {
if (argv_find(argv, argc, "dampened-paths", &idx)) if (argv_find(argv, argc, "parameters", &idx))
return bgp_show(vty, bgp, afi, safi,
bgp_show_type_dampend_paths, NULL, uj);
else if (argv_find(argv, argc, "flap-statistics", &idx))
return bgp_show(vty, bgp, afi, safi,
bgp_show_type_flap_statistics, NULL,
uj);
else if (argv_find(argv, argc, "parameters", &idx))
return bgp_show_dampening_parameters(vty, afi, safi); return bgp_show_dampening_parameters(vty, afi, safi);
} }
@ -8945,10 +8924,6 @@ DEFUN (show_ip_bgp,
return bgp_show_community(vty, bgp, argc, argv, return bgp_show_community(vty, bgp, argc, argv,
exact_match, afi, safi); exact_match, afi, safi);
} }
/* show all communities */
else
return bgp_show(vty, bgp, afi, safi,
bgp_show_type_community_all, NULL, uj);
} }
if (argv_find(argv, argc, "community-list", &idx)) { if (argv_find(argv, argc, "community-list", &idx)) {
@ -8965,6 +8940,66 @@ DEFUN (show_ip_bgp,
safi, safi,
bgp_show_type_prefix_longer); bgp_show_type_prefix_longer);
return CMD_WARNING;
}
/* BGP route print out function with JSON */
DEFUN (show_ip_bgp_json,
show_ip_bgp_json_cmd,
"show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR" ["BGP_SAFI_WITH_LABEL_CMD_STR"]]\
[<\
cidr-only\
|dampening <flap-statistics|dampened-paths>\
|community \
>] [json]",
SHOW_STR
IP_STR
BGP_STR
BGP_INSTANCE_HELP_STR
BGP_AFI_HELP_STR
BGP_SAFI_WITH_LABEL_HELP_STR
"Display only routes with non-natural netmasks\n"
"Display detailed information about dampening\n"
"Display flap statistics of routes\n"
"Display paths suppressed due to dampening\n"
"Display routes matching the communities\n"
JSON_STR)
{
afi_t afi = AFI_IP6;
safi_t safi = SAFI_UNICAST;
enum bgp_show_type sh_type = bgp_show_type_normal;
struct bgp *bgp = NULL;
int idx = 0;
bgp_vty_find_and_parse_afi_safi_bgp(vty, argv, argc, &idx, &afi, &safi,
&bgp);
if (!idx)
return CMD_WARNING;
int uj = use_json(argc, argv);
if (uj)
argc--;
if (argv_find(argv, argc, "cidr-only", &idx))
return bgp_show(vty, bgp, afi, safi, bgp_show_type_cidr_only,
NULL, uj);
if (argv_find(argv, argc, "dampening", &idx)) {
if (argv_find(argv, argc, "dampened-paths", &idx))
return bgp_show(vty, bgp, afi, safi,
bgp_show_type_dampend_paths, NULL, uj);
else if (argv_find(argv, argc, "flap-statistics", &idx))
return bgp_show(vty, bgp, afi, safi,
bgp_show_type_flap_statistics, NULL,
uj);
}
if (argv_find(argv, argc, "community", &idx)) {
/* show all communities */
return bgp_show(vty, bgp, afi, safi,
bgp_show_type_community_all, NULL, uj);
}
if (safi == SAFI_MPLS_VPN) if (safi == SAFI_MPLS_VPN)
return bgp_show_mpls_vpn(vty, afi, NULL, bgp_show_type_normal, return bgp_show_mpls_vpn(vty, afi, NULL, bgp_show_type_normal,
NULL, 0, uj); NULL, 0, uj);
@ -11283,6 +11318,7 @@ void bgp_route_init(void)
/* IPv4 labeled-unicast configuration. */ /* IPv4 labeled-unicast configuration. */
install_element(VIEW_NODE, &show_ip_bgp_instance_all_cmd); install_element(VIEW_NODE, &show_ip_bgp_instance_all_cmd);
install_element(VIEW_NODE, &show_ip_bgp_cmd); install_element(VIEW_NODE, &show_ip_bgp_cmd);
install_element(VIEW_NODE, &show_ip_bgp_json_cmd);
install_element(VIEW_NODE, &show_ip_bgp_route_cmd); install_element(VIEW_NODE, &show_ip_bgp_route_cmd);
install_element(VIEW_NODE, &show_ip_bgp_regexp_cmd); install_element(VIEW_NODE, &show_ip_bgp_regexp_cmd);