Merge pull request #11906 from louis-6wind/show_isis_db_json

isisd: fix show isis database [detail] json
This commit is contained in:
Russ White 2024-06-06 16:27:57 -04:00 committed by GitHub
commit 64f447fb10
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 1006 additions and 60 deletions

View file

@ -705,6 +705,10 @@ void lsp_print_common(struct isis_lsp *lsp, struct vty *vty, struct json_object
}
}
#if CONFDATE > 20240916
CPP_NOTICE("Remove JSON in '-' format")
#endif
void lsp_print_json(struct isis_lsp *lsp, struct json_object *json,
char dynhost, struct isis *isis)
{
@ -718,10 +722,20 @@ void lsp_print_json(struct isis_lsp *lsp, struct json_object *json,
own_json = json_object_new_object();
json_object_object_add(json, "lsp", own_json);
json_object_string_add(own_json, "id", LSPid);
#if CONFDATE > 20240916
CPP_NOTICE("remove own key")
#endif
json_object_string_add(own_json, "own", lsp->own_lsp ? "*" : " ");
if (lsp->own_lsp)
json_object_boolean_add(own_json, "ownLSP", true);
json_object_int_add(json, "pdu-len", lsp->hdr.pdu_len);
json_object_int_add(json, "pduLen", lsp->hdr.pdu_len);
snprintfrr(buf, sizeof(buf), "0x%08x", lsp->hdr.seqno);
#if CONFDATE > 20240916
CPP_NOTICE("remove seq-number key")
#endif
json_object_string_add(json, "seq-number", buf);
json_object_string_add(json, "seqNumber", buf);
snprintfrr(buf, sizeof(buf), "0x%04hx", lsp->hdr.checksum);
json_object_string_add(json, "chksum", buf);
if (lsp->hdr.rem_lifetime == 0) {
@ -731,8 +745,13 @@ void lsp_print_json(struct isis_lsp *lsp, struct json_object *json,
} else {
json_object_int_add(json, "holdtime", lsp->hdr.rem_lifetime);
}
#if CONFDATE > 20240916
CPP_NOTICE("remove att-p-ol key")
#endif
json_object_string_add(
json, "att-p-ol", lsp_bits2string(lsp->hdr.lsp_bits, b, sizeof(b)));
json_object_string_add(json, "attPOl",
lsp_bits2string(lsp->hdr.lsp_bits, b, sizeof(b)));
}
void lsp_print_vty(struct isis_lsp *lsp, struct vty *vty,

File diff suppressed because it is too large Load diff

View file

@ -2649,6 +2649,7 @@ void show_isis_database_lspdb_json(struct json_object *json,
struct lspdb_head *lspdb,
const char *sysid_str, int ui_level)
{
struct json_object *array_json, *lsp_json;
struct isis_lsp *lsp;
int lsp_count;
struct json_object *lsp_arr_json;
@ -2661,11 +2662,19 @@ void show_isis_database_lspdb_json(struct json_object *json,
}
if (lsp) {
json_object_object_get_ex(json, "lsps", &array_json);
if (!array_json) {
array_json = json_object_new_array();
json_object_object_add(json, "lsps", array_json);
}
lsp_json = json_object_new_object();
json_object_array_add(array_json, lsp_json);
if (ui_level == ISIS_UI_LEVEL_DETAIL)
lsp_print_detail(lsp, NULL, json,
lsp_print_detail(lsp, NULL, lsp_json,
area->dynhostname, area->isis);
else
lsp_print_json(lsp, json, area->dynhostname,
lsp_print_json(lsp, lsp_json, area->dynhostname,
area->isis);
} else if (sysid_str == NULL) {
lsp_arr_json = json_object_new_array();
@ -2739,6 +2748,8 @@ static void show_isis_database_json(struct json_object *json, const char *sysid_
json_object_object_add(area_json,"area",tag_area_json);
json_object_object_add(area_json,"levels",arr_json);
for (level = 0; level < ISIS_LEVELS; level++) {
if (lspdb_count(&area->lspdb[level]) == 0)
continue;
lsp_json = json_object_new_object();
show_isis_database_lspdb_json(lsp_json, area, level,
&area->lspdb[level],

View file

@ -685,7 +685,7 @@ def _check_lsp_overload_bit(router, overloaded_router_lsp, att_p_ol_expected):
)
database_json = json.loads(isis_database_output)
att_p_ol = database_json["areas"][0]["levels"][1]["att-p-ol"]
att_p_ol = database_json["areas"][0]["levels"][1]["lsps"][0]["attPOl"]
if att_p_ol == att_p_ol_expected:
return True
return "{} peer with expected att_p_ol {} got {} ".format(