diff options
author | Christian Poessinger <christian@poessinger.com> | 2022-04-01 21:56:53 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2022-04-01 21:56:53 +0200 |
commit | 1684773712b92e70130b618937700b472da22fce (patch) | |
tree | dc7667081c9e10bb16f2ce7a33c5ab436ffeae86 /src/migration-scripts/isis/0-to-1 | |
parent | 3ce13fe3c5c4161825fb36174d0da18668dca80c (diff) | |
download | vyos-1x-1684773712b92e70130b618937700b472da22fce.tar.gz vyos-1x-1684773712b92e70130b618937700b472da22fce.zip |
vyos.template: T4333: add Jinja2 plugin to test if a variable is defined and not none
We have a lot of boiler plate template code like
{% if config.interface is defined and config.interface.remote_as is defined
and config.interface.remote_as is not none %}
...
{% endif %}
This can be stripped down using a custom test to:
{% if config.interface.remote_as is vyos_defined %}
...
{% endif %}
In addition the new vyos_defined test supports comparison
{% if foo.bar.baz is vyos_defined('zoo') %}
...
{% endif %}
So the above will only evaluate to true if the variable foo.bar.baz is defined
and its content is zoo
This is inspired from https://github.com/aristanetworks/ansible-avd/ which make
heavy use of it.
All new templates should be written in this new style.
Diffstat (limited to 'src/migration-scripts/isis/0-to-1')
0 files changed, 0 insertions, 0 deletions