Docs
Concepts

Functions

Functions a design calls while it renders, to find objects and bring in types.

A function is called inside an expression while the design renders. Functions find objects, in the design itself or in NetBox, and bring in types from the Device Type Library. None of them allocate anything: a design states the names and addresses it wants, and the plan shows exactly those.

How the compute rack uses them

Each cable in the rack connects a server port to a switch port. A cable's ends are interfaces, and an interface belongs to a device, so each end is found with nbd.lookup.endpoint:

termination_a: "{{ nbd.lookup.endpoint('{{ variables.rack_name }}-COMPUTE-{{ loop.i | zeropad }}', 'Interface', 'Ethernet/PCIE1/1') }}"
termination_b: "{{ nbd.lookup.endpoint('{{ variables.rack_name }}-TOR-01', 'Interface', 'GigabitEthernet1/0/{{ loop.i * 2 - 1 }}') }}"

It takes a device name, the kind of port, and the port's name. The expressions inside it are worked out first, so on the third pass of the loop in rack R1 it finds Ethernet/PCIE1/1 on R1-COMPUTE-03 and GigabitEthernet1/0/5 on R1-TOR-01. The interfaces it finds don't exist in NetBox yet: they are part of the same plan, created by the device types the server and switch designs bring in.

The server design places its network card with nbd.nbt.get_module_bay, which finds the bay a device type created:

module_bay: "{{ nbd.nbt.get_module_bay(parent, 'PCIE1') }}"

The functions there are

FunctionWhat it does
nbd.lookup.endpoint(device, kind, name)Finds a port on a device: an interface, console port or power port
nbd.lookup.mgmt_interface(device)Finds a device's management interface
nbd.lookup.object(type, field=value, ...)Finds any object by its fields
nbd.nbt.get_module_bay(device, position)Finds a device's module bay by position
nbd.dtl.device_type(path)Brings in a device type from the Device Type Library
nbd.dtl.module_type(path)Brings in a module type from the Device Type Library
nbd.design.lookup(reference)Loads another design from the catalogue

A dtl: reference in a type field, as the device designs use, does what nbd.dtl.device_type and nbd.dtl.module_type do, and is how most designs bring types in.

A function that can't find what it's asked for refuses the render, saying what it looked for.

Functions reference has each function's parameters and examples.

On this page