Skip to content

Assertions

Assertions define expected network state in YAML format.

assertions:
- target: device:port
path: path/to/leaf
expect: expected_value

netsert uses a short path syntax that expands to full OpenConfig paths:

Short pathExpands to
interfaces[Ethernet1]/state/oper-status/interfaces/interface[name=Ethernet1]/state/oper-status
bgp[default]/neighbors[10.0.0.1]/state/session-state/network-instances/network-instance[name=default]/protocols/protocol[identifier=BGP][name=BGP]/bgp/neighbors/neighbor[neighbor-address=10.0.0.1]/state/session-state
system/state/hostname/system/state/hostname

Rule: Leading / = full path (passthrough). No leading / = short path (expanded).

assertions:
- target: spine1.example.com:6030
path: interfaces[Ethernet1]/state/oper-status
expect: UP
assertions:
- target:
- spine1:6030
- spine2:6030
path: interfaces[Ethernet1]/state/oper-status
expect: UP

Define groups in your config file, then reference them with @:

netsert.yaml
inventory:
groups:
spines:
- spine1:6030
- spine2:6030
leaves:
- leaf1:6030
- leaf2:6030
assertions.yaml
assertions:
- target: "@spines"
path: interfaces[Ethernet1]/state/oper-status
expect: UP
OperatorUsageExample
equalsExact match (default)expect: UP
containsSubstring matchexpect: "contains:Ethernet"
regexRegular expressionexpect: "regex:^4\\.2[89]\\."
existsPath existsexpect: exists
not_existsPath doesn’t existexpect: not_exists
>Greater thanexpect: ">100"
<Less thanexpect: "<500"
assertions:
- target: "@all"
path: interfaces[Ethernet1]/state/oper-status
expect: UP
assertions:
- target: "@leaves"
path: bgp[default]/neighbors[10.0.0.1]/state/session-state
expect: ESTABLISHED
assertions:
- target: "@core"
path: ospf[default][0]/neighbors[10.0.0.2]/state/adjacency-state
expect: FULL
assertions:
- target: "@all"
path: system/state/software-version
expect: "regex:^4\\.2[89]\\."