Fix: Recognize a.b or a/b in included VyOS dataplane templates#3587
Conversation
VyOS initial device configuration includes interface configuration code from plugin configuration templates. The plugin name in the node data is sometimes in 'a.b' format (for example, 'tunnel.gre'), whereas the new directory structure uses slashes (i.e. 'tunnel/gre'). This fix tries both names to allow users to override plugin dataplane templates in their own 'tunnel.gre' directory.
|
@ssasso -- Are you OK if I extend the same approach to VLANs and VRFs? That would clean up the "initial" directory. |
Yes please |
| {% set dp_initial = x_dp + '/vyos.initial.j2' %} | ||
| {% set dp_alt = x_dp.replace('.','/') + '/vyos.initial.j2' %} | ||
| {% include [ dp_initial, dp_alt ] ignore missing %} | ||
| {% endfor %} |
There was a problem hiding this comment.
{% for x_dp in config|default([]) %}
{% for dir in [ x_dp, x_dp.replace('.', '/') ] %}
{% include dir + '/vyos.initial.j2' ignore missing %}
{% endfor %}
{% endfor %}```
There was a problem hiding this comment.
... and if the server behaves as weirdly as mine does, you'll get two copies of the same config commands. That's why I went for a list in the "include" directive.
There was a problem hiding this comment.
Understood, in that case:
{% macro include_plugin_initial_configs(device_name) -%}
{% set template = '/' + device_name + '.initial.j2' %}
{% for x_dp in config|default([]) %}
{% include [ x_dp + template, x_dp.replace('.', '/') + template ] ignore missing %}
{% endfor %}
{%- endmacro %}
so we can use it for frr too?
There was a problem hiding this comment.
You're reading my mind. The next step will be a generic (macro) solution that will work with all devices, and I'll use it to clean up a few VLAN/VRF templats.
However, I still think we don't need it for FRR ;)) but we already have that discussion in #3585
There was a problem hiding this comment.
However, I still think we don't need it for FRR ;)) but we already have that discussion in #3585
I guess I'll have to disagree on multiple fronts then, perhaps it's more effective that way ;)
Will do after merging this one. Does it work for you? |
Yes absolutely, no problem |
…ce#3587) VyOS initial device configuration includes interface configuration code from plugin configuration templates. The plugin name in the node data is sometimes in 'a.b' format (for example, 'tunnel.gre'), whereas the new directory structure uses slashes (i.e. 'tunnel/gre'). This fix tries both names to allow users to override plugin dataplane templates in their own 'tunnel.gre' directory.
VyOS initial device configuration includes interface configuration code from plugin configuration templates. The plugin name in the node data is sometimes in 'a.b' format (for example, 'tunnel.gre'), whereas the new directory structure uses slashes (i.e. 'tunnel/gre').
This fix tries both names to allow users to override plugin dataplane templates in their own 'tunnel.gre' directory.