mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-07-24 11:19:14 +00:00
bgpd: add json error message to rpki
Add error messages to rpki JSON output instead of an empty JSON. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
This commit is contained in:
parent
4011682a1a
commit
aecdab5bd4
@ -733,9 +733,10 @@ static void print_prefix_table_by_asn(struct vty *vty, as_t as,
|
||||
arg.asnotation = bgp_get_asnotation(bgp_lookup_by_vrf_id(VRF_DEFAULT));
|
||||
|
||||
if (!group) {
|
||||
if (json)
|
||||
if (json) {
|
||||
json_object_string_add(json, "error", "Cannot find a connected group.");
|
||||
vty_json(vty, json);
|
||||
else
|
||||
} else
|
||||
vty_out(vty, "Cannot find a connected group.\n");
|
||||
return;
|
||||
}
|
||||
@ -788,9 +789,10 @@ static void print_prefix_table(struct vty *vty, json_object *json)
|
||||
arg.asnotation = bgp_get_asnotation(bgp_lookup_by_vrf_id(VRF_DEFAULT));
|
||||
|
||||
if (!group) {
|
||||
if (json)
|
||||
if (json) {
|
||||
json_object_string_add(json, "error", "Cannot find a connected group.");
|
||||
vty_json(vty, json);
|
||||
else
|
||||
} else
|
||||
vty_out(vty, "Cannot find a connected group.\n");
|
||||
return;
|
||||
}
|
||||
@ -1334,9 +1336,10 @@ DEFPY (show_rpki_prefix_table,
|
||||
json = json_object_new_object();
|
||||
|
||||
if (!is_synchronized()) {
|
||||
if (uj)
|
||||
if (json) {
|
||||
json_object_string_add(json, "error", "No Connection to RPKI cache server.");
|
||||
vty_json(vty, json);
|
||||
else
|
||||
} else
|
||||
vty_out(vty, "No connection to RPKI cache server.\n");
|
||||
return CMD_WARNING;
|
||||
}
|
||||
@ -1360,9 +1363,10 @@ DEFPY (show_rpki_as_number,
|
||||
json = json_object_new_object();
|
||||
|
||||
if (!is_synchronized()) {
|
||||
if (uj)
|
||||
if (json) {
|
||||
json_object_string_add(json, "error", "No Connection to RPKI cache server.");
|
||||
vty_json(vty, json);
|
||||
else
|
||||
} else
|
||||
vty_out(vty, "No Connection to RPKI cache server.\n");
|
||||
return CMD_WARNING;
|
||||
}
|
||||
@ -1390,9 +1394,10 @@ DEFPY (show_rpki_prefix,
|
||||
json = json_object_new_object();
|
||||
|
||||
if (!is_synchronized()) {
|
||||
if (uj)
|
||||
if (json) {
|
||||
json_object_string_add(json, "error", "No Connection to RPKI cache server.");
|
||||
vty_json(vty, json);
|
||||
else
|
||||
} else
|
||||
vty_out(vty, "No Connection to RPKI cache server.\n");
|
||||
return CMD_WARNING;
|
||||
}
|
||||
@ -1405,9 +1410,10 @@ DEFPY (show_rpki_prefix,
|
||||
memcpy(addr_str, prefix_str, addr_len);
|
||||
|
||||
if (lrtr_ip_str_to_addr(addr_str, &addr) != 0) {
|
||||
if (json)
|
||||
if (json) {
|
||||
json_object_string_add(json, "error", "Invalid IP prefix.");
|
||||
vty_json(vty, json);
|
||||
else
|
||||
} else
|
||||
vty_out(vty, "Invalid IP prefix\n");
|
||||
return CMD_WARNING;
|
||||
}
|
||||
@ -1419,9 +1425,10 @@ DEFPY (show_rpki_prefix,
|
||||
if (pfx_table_validate_r(rtr_config->pfx_table, &matches, &match_count,
|
||||
asn, &addr, prefix->prefixlen,
|
||||
&result) != PFX_SUCCESS) {
|
||||
if (json)
|
||||
if (json) {
|
||||
json_object_string_add(json, "error", "Prefix lookup failed.");
|
||||
vty_json(vty, json);
|
||||
else
|
||||
} else
|
||||
vty_out(vty, "Prefix lookup failed\n");
|
||||
return CMD_WARNING;
|
||||
}
|
||||
@ -1564,20 +1571,22 @@ DEFPY (show_rpki_cache_connection,
|
||||
json = json_object_new_object();
|
||||
|
||||
if (!is_synchronized()) {
|
||||
if (!json)
|
||||
vty_out(vty, "No connection to RPKI cache server.\n");
|
||||
else
|
||||
if (json) {
|
||||
json_object_string_add(json, "error", "No connection to RPKI cache server.");
|
||||
vty_json(vty, json);
|
||||
} else
|
||||
vty_out(vty, "No connection to RPKI cache server.\n");
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
group = get_connected_group();
|
||||
if (!group) {
|
||||
if (!json)
|
||||
vty_out(vty, "Cannot find a connected group.\n");
|
||||
else
|
||||
if (json) {
|
||||
json_object_string_add(json, "error", "Cannot find a connected group.");
|
||||
vty_json(vty, json);
|
||||
} else
|
||||
vty_out(vty, "Cannot find a connected group.\n");
|
||||
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user