ipspace / netlab

Making virtual networking labs suck less
https://netlab.tools
Other
428 stars 63 forks source link

[BUG] Wrong search path for clab bindings #1230

Closed ssasso closed 1 month ago

ssasso commented 1 month ago

According to: https://netlab.tools/labs/clab/#generating-and-binding-custom-configuration-files

netlab tries to locate the templates in the current directory, in a subdirectory with the name of the device, and within the system directory templates/provider/clab/<device>. .j2 suffix is always appended to the template name.

For example, the daemons template used in the above example could be ./daemons.j2, ./frr/daemons.j2 or <netsim_moddir>/templates/provider/clab/frr/daemons.j2; the result gets mapped to /etc/frr/daemons within the container file system.

However, the search path for the files seem wrong. It never has the local directory, nor the <device> one.

This is a part of the netlab create --debug:

Searching for daemons.j2 in ['/root/GIT_H/netlab/netsim/ansible/templates/frr', '/root/GIT_H/netlab/netsim/daemons/frr', '/root/GIT_H/netlab/netsim/templates/provider/clab/frr']
Found file: /root/GIT_H/netlab/netsim/templates/provider/clab/frr/daemons.j2
write_template /root/GIT_H/netlab/netsim/templates/provider/clab/frr/daemons.j2 -> clab_files/nxrt/daemons
TEMPLATE PATH for daemons.j2: ['/root/GIT_H/netlab/netsim/templates/provider/clab/frr']
[MAPPED]  clab_files/nxrt/daemons to nxrt:/etc/frr/daemons (from templates/provider/clab/frr/daemons.j2)
ssasso commented 1 month ago

(FYI - for now I solved in a similar way you did with the 'fix_frr' plugin)

ipspace commented 1 month ago

Will fix, and push out -post2 together with #1232.

Thank you!

ipspace commented 1 month ago

Did a bit of archeology ;) The ability to use user-defined templates was introduced in January 2023, and the current implementation (using paths) was added in January 2024 with release 1.8.0 (control-plane daemons).

The current implementation requires the templates to be in templates/device directory, and I find it more structured ;) than having the templates in the topology directory, so I'll boldly declare this to be a documentation error, fix the documentation, and add another breaking change to 1.8.0 release. Hope you're OK with that -- all you have to do is to move the daemons.j2 into 'templates/frr' and potentially make a symbolic link to that file in 'templates/cumulus'.