mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 14:17:20 +00:00
ospfd: show ip ospf interface json output format
Current json output does not differentiate start of interface objects. Adding "interfaces" keyword at the beginning of the interface list. This is useful when displaying vrf level output along with interface list. Ticket:CM-19115 Testing Done: show ip ospf vrf all interface json show ip ospf vrf all interface <specific intf> json show ip ospf interface json show ip ospf interface <specific intf> json Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
This commit is contained in:
parent
7c0c85a2eb
commit
7dab10ce94
@ -3693,14 +3693,15 @@ static int show_ip_ospf_interface_common(struct vty *vty, struct ospf *ospf,
|
|||||||
{
|
{
|
||||||
struct interface *ifp;
|
struct interface *ifp;
|
||||||
struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id);
|
struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id);
|
||||||
json_object *json_vrf = NULL;
|
json_object *json_vrf = NULL, *json_intf_array = NULL;
|
||||||
json_object *json_interface_sub = NULL;
|
json_object *json_interface_sub = NULL, *json_interface = NULL;
|
||||||
|
|
||||||
if (use_json) {
|
if (use_json) {
|
||||||
if (use_vrf)
|
if (use_vrf)
|
||||||
json_vrf = json_object_new_object();
|
json_vrf = json_object_new_object();
|
||||||
else
|
else
|
||||||
json_vrf = json;
|
json_vrf = json;
|
||||||
|
json_intf_array = json_object_new_array();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ospf->instance) {
|
if (ospf->instance) {
|
||||||
@ -3714,23 +3715,31 @@ static int show_ip_ospf_interface_common(struct vty *vty, struct ospf *ospf,
|
|||||||
ospf_show_vrf_name(ospf, vty, json_vrf, use_vrf);
|
ospf_show_vrf_name(ospf, vty, json_vrf, use_vrf);
|
||||||
|
|
||||||
if (intf_name == NULL) {
|
if (intf_name == NULL) {
|
||||||
|
if (use_json)
|
||||||
|
json_object_object_add(json_vrf, "interfaces",
|
||||||
|
json_intf_array);
|
||||||
/* Show All Interfaces.*/
|
/* Show All Interfaces.*/
|
||||||
FOR_ALL_INTERFACES (vrf, ifp) {
|
FOR_ALL_INTERFACES (vrf, ifp) {
|
||||||
if (ospf_oi_count(ifp)) {
|
if (ospf_oi_count(ifp)) {
|
||||||
if (use_json)
|
if (use_json) {
|
||||||
|
json_interface =
|
||||||
|
json_object_new_object();
|
||||||
json_interface_sub =
|
json_interface_sub =
|
||||||
json_object_new_object();
|
json_object_new_object();
|
||||||
|
}
|
||||||
show_ip_ospf_interface_sub(vty, ospf, ifp,
|
show_ip_ospf_interface_sub(vty, ospf, ifp,
|
||||||
json_interface_sub,
|
json_interface_sub,
|
||||||
use_json);
|
use_json);
|
||||||
|
|
||||||
if (use_json)
|
if (use_json) {
|
||||||
|
json_object_array_add(json_intf_array,
|
||||||
|
json_interface);
|
||||||
json_object_object_add(
|
json_object_object_add(
|
||||||
json_vrf, ifp->name,
|
json_interface, ifp->name,
|
||||||
json_interface_sub);
|
json_interface_sub);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Interface name is specified. */
|
/* Interface name is specified. */
|
||||||
ifp = if_lookup_by_name(intf_name, ospf->vrf_id);
|
ifp = if_lookup_by_name(intf_name, ospf->vrf_id);
|
||||||
@ -3741,17 +3750,25 @@ static int show_ip_ospf_interface_common(struct vty *vty, struct ospf *ospf,
|
|||||||
else
|
else
|
||||||
vty_out(vty, "No such interface name\n");
|
vty_out(vty, "No such interface name\n");
|
||||||
} else {
|
} else {
|
||||||
if (use_json)
|
if (use_json) {
|
||||||
json_interface_sub = json_object_new_object();
|
json_interface_sub = json_object_new_object();
|
||||||
|
json_interface = json_object_new_object();
|
||||||
|
json_object_object_add(json_vrf, "interfaces",
|
||||||
|
json_intf_array);
|
||||||
|
}
|
||||||
|
|
||||||
show_ip_ospf_interface_sub(
|
show_ip_ospf_interface_sub(
|
||||||
vty, ospf, ifp, json_interface_sub, use_json);
|
vty, ospf, ifp, json_interface_sub, use_json);
|
||||||
|
|
||||||
if (use_json)
|
if (use_json) {
|
||||||
json_object_object_add(json_vrf, ifp->name,
|
json_object_array_add(json_intf_array,
|
||||||
|
json_interface);
|
||||||
|
json_object_object_add(json_interface,
|
||||||
|
ifp->name,
|
||||||
json_interface_sub);
|
json_interface_sub);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (use_json) {
|
if (use_json) {
|
||||||
if (use_vrf) {
|
if (use_vrf) {
|
||||||
|
Loading…
Reference in New Issue
Block a user