mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-06-05 23:49:42 +00:00
Merge pull request #17190 from baozhen-H3C/202410180176
isisd: The command "'show isis vrf all summary json" has no output.
This commit is contained in:
commit
b5c3b44de1
@ -2366,35 +2366,34 @@ static void common_isis_summary_json(struct json_object *json,
|
|||||||
struct isis *isis)
|
struct isis *isis)
|
||||||
{
|
{
|
||||||
int level;
|
int level;
|
||||||
json_object *areas_json, *area_json, *tx_pdu_json, *rx_pdu_json,
|
json_object *vrf_json, *areas_json, *area_json, *tx_pdu_json, *rx_pdu_json, *levels_json,
|
||||||
*levels_json, *level_json;
|
*level_json;
|
||||||
struct listnode *node, *node2;
|
struct listnode *node, *node2;
|
||||||
struct isis_area *area;
|
struct isis_area *area;
|
||||||
time_t cur;
|
time_t cur;
|
||||||
char uptime[MONOTIME_STRLEN];
|
char uptime[MONOTIME_STRLEN];
|
||||||
char stier[5];
|
char stier[5];
|
||||||
|
|
||||||
json_object_string_add(json, "vrf", isis->name);
|
vrf_json = json_object_new_object();
|
||||||
json_object_int_add(json, "process-id", isis->process_id);
|
json_object_string_add(vrf_json, "vrf", isis->name);
|
||||||
|
json_object_int_add(vrf_json, "process-id", isis->process_id);
|
||||||
if (isis->sysid_set)
|
if (isis->sysid_set)
|
||||||
json_object_string_addf(json, "system-id", "%pSY", isis->sysid);
|
json_object_string_addf(vrf_json, "system-id", "%pSY", isis->sysid);
|
||||||
|
|
||||||
cur = time(NULL);
|
cur = time(NULL);
|
||||||
cur -= isis->uptime;
|
cur -= isis->uptime;
|
||||||
frrtime_to_interval(cur, uptime, sizeof(uptime));
|
frrtime_to_interval(cur, uptime, sizeof(uptime));
|
||||||
json_object_string_add(json, "up-time", uptime);
|
json_object_string_add(vrf_json, "up-time", uptime);
|
||||||
if (isis->area_list)
|
if (isis->area_list)
|
||||||
json_object_int_add(json, "number-areas",
|
json_object_int_add(vrf_json, "number-areas", isis->area_list->count);
|
||||||
isis->area_list->count);
|
|
||||||
areas_json = json_object_new_array();
|
areas_json = json_object_new_array();
|
||||||
json_object_object_add(json, "areas", areas_json);
|
json_object_object_add(vrf_json, "areas", areas_json);
|
||||||
for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) {
|
for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) {
|
||||||
area_json = json_object_new_object();
|
area_json = json_object_new_object();
|
||||||
json_object_string_add(area_json, "area",
|
json_object_string_add(area_json, "area",
|
||||||
area->area_tag ? area->area_tag
|
area->area_tag ? area->area_tag
|
||||||
: "null");
|
: "null");
|
||||||
|
|
||||||
|
|
||||||
if (fabricd) {
|
if (fabricd) {
|
||||||
uint8_t tier = fabricd_tier(area);
|
uint8_t tier = fabricd_tier(area);
|
||||||
snprintfrr(stier, sizeof(stier), "%s", &tier);
|
snprintfrr(stier, sizeof(stier), "%s", &tier);
|
||||||
@ -2471,6 +2470,7 @@ static void common_isis_summary_json(struct json_object *json,
|
|||||||
}
|
}
|
||||||
json_object_array_add(areas_json, area_json);
|
json_object_array_add(areas_json, area_json);
|
||||||
}
|
}
|
||||||
|
json_object_array_add(json, vrf_json);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void common_isis_summary_vty(struct vty *vty, struct isis *isis)
|
static void common_isis_summary_vty(struct vty *vty, struct isis *isis)
|
||||||
@ -2573,13 +2573,27 @@ static void common_isis_summary_vty(struct vty *vty, struct isis *isis)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void common_isis_summary(struct vty *vty, struct json_object *json,
|
static void common_isis_summary(struct vty *vty, struct json_object *json, const char *vrf_name,
|
||||||
struct isis *isis)
|
bool all_vrf)
|
||||||
{
|
{
|
||||||
if (json) {
|
struct listnode *node;
|
||||||
common_isis_summary_json(json, isis);
|
struct isis *isis;
|
||||||
|
|
||||||
|
if (all_vrf) {
|
||||||
|
for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis)) {
|
||||||
|
if (json)
|
||||||
|
common_isis_summary_json(json, isis);
|
||||||
|
else
|
||||||
|
common_isis_summary_vty(vty, isis);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
common_isis_summary_vty(vty, isis);
|
isis = isis_lookup_by_vrfname(vrf_name);
|
||||||
|
if (isis != NULL) {
|
||||||
|
if (json)
|
||||||
|
common_isis_summary_json(json, isis);
|
||||||
|
else
|
||||||
|
common_isis_summary_vty(vty, isis);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2590,31 +2604,24 @@ DEFUN(show_isis_summary, show_isis_summary_cmd,
|
|||||||
"json output\n"
|
"json output\n"
|
||||||
"summary\n")
|
"summary\n")
|
||||||
{
|
{
|
||||||
struct listnode *node;
|
|
||||||
int idx_vrf = 0;
|
int idx_vrf = 0;
|
||||||
struct isis *isis;
|
|
||||||
const char *vrf_name = VRF_DEFAULT_NAME;
|
const char *vrf_name = VRF_DEFAULT_NAME;
|
||||||
bool all_vrf = false;
|
bool all_vrf = false;
|
||||||
bool uj = use_json(argc, argv);
|
bool uj = use_json(argc, argv);
|
||||||
json_object *json = NULL;
|
json_object *json = NULL, *vrfs_json = NULL;
|
||||||
|
|
||||||
ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf)
|
ISIS_FIND_VRF_ARGS(argv, argc, idx_vrf, vrf_name, all_vrf)
|
||||||
if (!im) {
|
if (!im) {
|
||||||
vty_out(vty, PROTO_NAME " is not running\n");
|
vty_out(vty, PROTO_NAME " is not running\n");
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
if (uj)
|
if (uj) {
|
||||||
json = json_object_new_object();
|
json = json_object_new_object();
|
||||||
|
vrfs_json = json_object_new_array();
|
||||||
if (all_vrf) {
|
json_object_object_add(json, "vrfs", vrfs_json);
|
||||||
for (ALL_LIST_ELEMENTS_RO(im->isis, node, isis))
|
|
||||||
common_isis_summary(vty, json, isis);
|
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
|
||||||
}
|
}
|
||||||
isis = isis_lookup_by_vrfname(vrf_name);
|
|
||||||
if (isis != NULL)
|
common_isis_summary(vty, vrfs_json, vrf_name, all_vrf);
|
||||||
common_isis_summary(vty, json, isis);
|
|
||||||
|
|
||||||
if (uj)
|
if (uj)
|
||||||
vty_json(vty, json);
|
vty_json(vty, json);
|
||||||
|
@ -237,9 +237,9 @@ def test_isis_summary_json():
|
|||||||
assertmsg = "Test isis summary json failed in '{}' data '{}'".format(
|
assertmsg = "Test isis summary json failed in '{}' data '{}'".format(
|
||||||
rname, json_output
|
rname, json_output
|
||||||
)
|
)
|
||||||
assert json_output["vrf"] == "default", assertmsg
|
assert json_output["vrfs"][0]["vrf"] == "default", assertmsg
|
||||||
assert json_output["areas"][0]["area"] == "1", assertmsg
|
assert json_output["vrfs"][0]["areas"][0]["area"] == "1", assertmsg
|
||||||
assert json_output["areas"][0]["levels"][0]["id"] != "3", assertmsg
|
assert json_output["vrfs"][0]["areas"][0]["levels"][0]["id"] != "3", assertmsg
|
||||||
|
|
||||||
|
|
||||||
def test_isis_interface_json():
|
def test_isis_interface_json():
|
||||||
|
Loading…
Reference in New Issue
Block a user