Skip to content

Interfaces - #77

Open
djothi wants to merge 7 commits into
criteo:mainfrom
djothi:interfaces
Open

djothi wants to merge 7 commits into
criteo:mainfrom
djothi:interfaces

Conversation

@djothi

@djothi djothi commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Generate interface configuration from the CMDB

This PR adds interfaces to the generated OpenConfig device config. That covers physical and logical interfaces, IP addressing, VRF bindings and management static routes.

What's included

  • YANG models: adds openconfig-interfaces and openconfig-if-ip, plus a new afk-interfaces-ext module. The new module holds the SONiC settings OpenConfig has no field for: alias, lanes, index, management, IPv6 link-local only, forced routes, the remote end of each link, and the FEC_AUTO / FEC_RS FEC
    modes. criteo-oc-deviations drops the if-ip subtrees we never generate (VRRP, static neighbors, IPv6 router advertisements). The ygot models are regenerated.
  • CMDB ingestion: new ingestors and models for device interfaces, logical interfaces, port layouts, links and management routes. Each has unit tests.
  • DCIM: exposes the device type ID and role ID, which are used to look up a device's port layout.
  • Convertor: a new internal/convertor/interfaces package converts:
    • CMDB interfaces into openconfig-interfaces. Port names come from the port layout, and the remote end of each link is filled in.
    • Management routes into static routes in the matching network instance.
  • Pipeline: the new data is fetched, precomputed per device and merged into the generated config. Interfaces are bound to their network instance, and any non-default VRF that doesn't exist yet is created as L3VRF.

Housekeeping

  • update_yang_models.sh: fixes the order of the rm -rf arguments, and passes -trimpath so local paths don't end up in the generated files.

Put the -rf flag before the operand: BSD rm (macOS) rejects options
placed after the first operand.
…face extensions

Generate openconfig-if-ip (which pulls openconfig-interfaces,
openconfig-if-ethernet and openconfig-vlan) so that interfaces,
subinterfaces, addresses and VLANs can be emitted.

Add afk-interfaces-ext, the AFK augmentations for SONiC configuration
OpenConfig has no leaf for: management flag, use-ipv6-link-local-only,
alias, lanes, port index, forced-routes, neighbor-name/neighbor-port,
and the FEC_AUTO / FEC_RS fec-mode identities.

Bump criteo-oc-deviations to 0.2.0 to prune the openconfig-if-ip
subtrees AFK does not generate (VRRP, static neighbors, IPv6 router
advertisements).

Run the generator with -trimpath so that the generated headers no
longer embed the local Go module cache path.
Decode the device_type and role references of the NetBox device
inventory, which identify the port layout of a device. NetBox exposes
the role as "role" since 3.6 and as "device_role" before: both are
accepted through RoleID().
…s and links

Add the models and ingestors of the Network CMDB interface objects:

- device interfaces (/api/plugins/cmdb/device-interfaces/): the physical
  interfaces of a device with their Ethernet attributes;
- logical interfaces (/api/plugins/cmdb/logical-interfaces/): the L1/L2/L3
  units of a device interface with addresses, VRF and VLANs. They are
  filtered through their parent interface, hence the prefixed datacenter
  filter;
- port layouts (/api/plugins/cmdb/port-layouts/): the front-panel ports
  of a hardware model in a network role, with their NOS names and ASIC
  lanes. They are precomputed per (device type, role), not per device;
- links (/api/plugins/cmdb/links/): point-to-point links between device
  interfaces, precomputed as the neighbor table of each device with the
  remote port resolved through the remote device port layout.
@djothi
djothi requested a review from a team October 14, 2026 15:18
Convert the device and logical interfaces of a device to
/interfaces/interface/:

- front-panel ports are renamed to the vendor name of their port layout
  entry and carry its alias, lanes and, for AFK managed devices, the
  port index derived from the port short name;
- the Ethernet attributes (speed, FEC, autonegotiation) are mapped to
  the OpenConfig identities, auto and rs using the afk-interfaces-ext
  ones;
- logical interfaces become subinterfaces with their IPv4/IPv6
  addresses (loopbacks exposed as host prefixes), VRF binding, 802.1Q
  mode and VLANs, and use-ipv6-link-local-only;
- the remote end of each link is emitted as neighbor-name/neighbor-port;
- eth0 is flagged as the management interface.

The network instance bindings of the subinterfaces are returned
alongside the interfaces so that the caller can attach them to their
VRF.
…on pipeline

Fetch the device interfaces, logical interfaces, port layouts, links and
management routes from the CMDB alongside the existing ingestors,
precompute them per device (port layouts per hardware model and network
role, resolved per device through the inventory) and convert them in
the per-device configuration generation:

- /interfaces/interface/ is filled from InterfacesToOpenconfig;
- the subinterfaces bound to a VRF create or complete the matching
  network instance, typed as L3VRF;
- the management routing table is generated from the CMDB management
  routes: the static default route becomes a STATIC protocol instance
  of the network instance the management subinterface is bound to, with
  the subinterface as interface-ref, and forced routes are emitted on
  the IPv4 container of the management subinterface
  (afk-interfaces-ext forced-routes). Devices without management routes
  are the normal case (not SONiC).

ingestorNumber grows from 7 to 13: 5 new ingestors here, plus the NTP
one that was added without bumping it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants