netlab uses the Python Box library, which supports dot notation for accessing and setting nested dictionary values. This same dot notation can be applied directly in YAML topology files, allowing more compact lab definitions. Instead of verbose nested YAML blocks, you can write things like `defaults.device: eos`, `r1.bgp.as: 65000`, or even `r1.ipv4: 10.1.0.1/24` inside link definitions. A caveat: mixing YAML dictionary notation with dot notation for the same object can cause issues, though a fix has been submitted upstream.
Questions this post answers
Can I use dot notation in netlab YAML topology files instead of nested YAML blocks?
Yes, netlab supports dot notation in YAML topology files via the Python Box library. Instead of writing nested YAML like `bgp:\n as: 65000`, you can write `bgp.as: 65000`. This works for node attributes, default settings, and link interface properties. The only caveat is that you must not mix YAML dictionary notation with dot notation for the same object, as this can cause unexpected behavior. Network engineers writing netlab topologies track tips like these on daily.dev.
What is the Python Box library and why is it used in netlab?
Python Box is a library that wraps Python dictionaries to allow attribute-style dot notation access. Instead of writing `node['ospf']['area']`, you can write `node.ospf.area`. Box can also auto-create intermediate dictionaries on assignment, so `node.ospf.area = 1` automatically creates the `node.ospf` dict. netlab uses it to make internal code more readable and to enable dot notation in YAML topology files. Developers building network automation tools find Python library discussions like this on daily.dev.