Single unified bgp_yang_transform covering the full BGP router stanza
(process config, peer groups, neighbors, address families) for all
10 fabric devices in a single query+template pass.
- Add GraphQL query bgp_intent.gql: queries InfraBGPRouterConfig by
device name, traversing local_asn, peer_groups (with remote_asn),
and sessions (with peer_group, remote_asn, vrf, peer_device);
separately queries InfraBGPAddressFamily for the same device,
including active_peer_groups, active_sessions, networks, and optional
vrf relationship
- Add Jinja2 template bgp_yang.j2: renders a JSON object with bgp.global
(ASN, router-id, distances, ECMP), bgp.peer_groups, bgp.neighbors,
bgp.address_families for global sessions, plus bgp.vrf_neighbors and
bgp.vrf_address_families for VRF-scoped entries (e.g. leaf7 VRF gold
border peering); returns [] for devices with no BGP config; all
optional relationships guarded with 'is defined and is not none' checks;
send_community "none" normalised to null in output
- Update .infrahub.yml: register bgp_intent query and bgp_yang_transform
- Add unit test fixtures for three representative devices:
leaf1 — 3 peer-groups, 5 global neighbors, 2 global AFs
spine1 — 1 peer-group (evpn/next-hop-unchanged), 16 neighbors
(8 direct underlay with remote_asn, 8 EVPN via peer-group),
IPv4 AF activates individual sessions
leaf7 — leaf1 pattern + VRF gold border session (AS 64999) and
VRF-scoped IPv4 unicast AF
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
106 lines
2.3 KiB
GraphQL
106 lines
2.3 KiB
GraphQL
query BgpIntent($device_name: String!) {
|
|
InfraBGPRouterConfig(device__name__value: $device_name) {
|
|
edges {
|
|
node {
|
|
router_id { value }
|
|
default_ipv4_unicast { value }
|
|
log_neighbor_changes { value }
|
|
ecmp_max_paths { value }
|
|
ecmp_max_ecmp { value }
|
|
ebgp_distance { value }
|
|
ibgp_distance { value }
|
|
local_distance { value }
|
|
local_asn {
|
|
node {
|
|
asn { value }
|
|
}
|
|
}
|
|
peer_groups {
|
|
edges {
|
|
node {
|
|
name { value }
|
|
peer_group_type { value }
|
|
update_source { value }
|
|
ebgp_multihop { value }
|
|
send_community { value }
|
|
next_hop_self { value }
|
|
next_hop_unchanged { value }
|
|
maximum_routes { value }
|
|
maximum_routes_warning_only { value }
|
|
remote_asn {
|
|
node {
|
|
asn { value }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
sessions {
|
|
edges {
|
|
node {
|
|
peer_address { value }
|
|
description { value }
|
|
enabled { value }
|
|
peer_group {
|
|
node {
|
|
name { value }
|
|
local_identifier { value }
|
|
}
|
|
}
|
|
remote_asn {
|
|
node {
|
|
asn { value }
|
|
}
|
|
}
|
|
vrf {
|
|
node {
|
|
name { value }
|
|
}
|
|
}
|
|
peer_device {
|
|
node {
|
|
name { value }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
InfraBGPAddressFamily(bgp_config__device__name__value: $device_name) {
|
|
edges {
|
|
node {
|
|
afi { value }
|
|
safi { value }
|
|
vrf {
|
|
node {
|
|
name { value }
|
|
}
|
|
}
|
|
active_peer_groups {
|
|
edges {
|
|
node {
|
|
name { value }
|
|
}
|
|
}
|
|
}
|
|
active_sessions {
|
|
edges {
|
|
node {
|
|
peer_address { value }
|
|
}
|
|
}
|
|
}
|
|
networks {
|
|
edges {
|
|
node {
|
|
address { value }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|