Troubles with creating a config template for HP Aruba switch #16242
Unanswered
Wildeagle23
asked this question in
Help Wanted!
Replies: 1 comment
-
Here are two versions of a prototype template I wrote for a Mikrotik device, which may be similar to what you're trying to do. Try them and see if either is helpful.
There is a variation of this for Zyxel switches in #12573 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
For the last couple days i have tried to create a config template for a aruba switch, but get stuck on something.
If you have a Cisco switch it wil define vlans under the interface.
But on a Aruba switch it defines the tagged and untagged ports under the vlan interface.
Now have I created a couple normal interfaces and a vlan interface under a test device in Netbox.
But I can't seen to get all the ports used as tagged and untagged under a vlan.
I have used this configuration till now but I am stuck at this point:
{# Creating variables for (un-)tagged vlans #}
{% set tagged_vlans = {} %}
{%- for interface in device.interfaces.all() %}
{%- if "vlan" in interface.name %}
{% set vlan_name = "tagged_" ~ interface.name %}
{% set _ = tagged_vlans.update({vlan_name: interface}) %}
{% set untaggedvlan_name = "untagged_" ~ interface.name %}
{% set _ = untagged_vlans.update({untaggedvlan_name: interface}) %}
{%- endif %}
{%- endfor %}
{%- for vlan_name, interface in tagged_vlans.items() %}
{# Now I can use variables as tagged_vlan1, tagged_vlan2 etc. #}
{{ vlan_name }}: {{ interface }}
{%- endfor %}
{%- for untaggedvlan_name, interface in untagged_vlans.items() %}
{# Now I can use variables as untagged_vlan1, untagged_vlan2 etc. #}
{{ untaggedvlan_name }}: {{ interface }}
{%- endfor %}
{# For test use only!!! #}
{% set untagged_vlan10 = test %}
{# From here configuration #}
{% for interface in device.interfaces.all() %}
{%- if "vlan" in interface.name | lower %}
{%- else %}
name "{{ interface.label }}"
{%- endif %}
{% endfor %}
{% for interface in device.interfaces.all() %}
{%- if "vlan" in interface.name | lower %}
interface {{ interface.name }}
name "{{ interface.label }}"
{% set tagged = '{{ "tagged_" + interface.name }}' %}
{{ tagged }}
untagged {{ "untagged_" + interface.name }}
{%- endif %}
{% endfor %}
What I am trying to do is create a variable based on the name of a vlan interface which I have accomplished.
But now I need to recreate that variable at the vlan interface, is there a way to do that based on the name if the interface?
I hope somebody can help me.
Beta Was this translation helpful? Give feedback.
All reactions