WIP: Aruba switches #103
2 changed files with 26 additions and 8 deletions
17
filter_plugins/aruba.py
Normal file
17
filter_plugins/aruba.py
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
class FilterModule:
|
||||||
|
def filters(self):
|
||||||
|
return {
|
||||||
|
"aruba_ints": aruba_ints,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def aruba_ints(seq, sep=",", hyphen="-"):
|
||||||
|
ranges = []
|
||||||
|
for value in sorted(seq):
|
||||||
|
if not ranges or ranges[-1][1] + 1 != value:
|
||||||
|
ranges.append((value, value))
|
||||||
|
else:
|
||||||
|
ranges[-1] = (ranges[-1][0], value)
|
||||||
|
return sep.join(
|
||||||
|
(f"{a}" if a == b else f"{a}{hyphen}{b}" for a, b in ranges)
|
||||||
|
)
|
|
@ -48,11 +48,10 @@ set lldp_enabled =
|
||||||
set lldp_disabled =
|
set lldp_disabled =
|
||||||
aruba__interfaces.keys()
|
aruba__interfaces.keys()
|
||||||
| difference(lldp_enabled)
|
| difference(lldp_enabled)
|
||||||
| map("int")
|
|
||||||
| list
|
| list
|
||||||
%}
|
%}
|
||||||
{% if lldp_disabled %}
|
{% if lldp_disabled %}
|
||||||
lldp admin-status {{ lldp_disabled | join(",") }} disable
|
lldp admin-status {{ lldp_disabled | aruba_ints }} disable
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
password manager plaintext {{ aruba__manager_password | enquote }}
|
password manager plaintext {{ aruba__manager_password | enquote }}
|
||||||
|
@ -82,13 +81,12 @@ set loop_protect =
|
||||||
| selectattr("value.loop_protect", "defined")
|
| selectattr("value.loop_protect", "defined")
|
||||||
| selectattr("value.loop_protect")
|
| selectattr("value.loop_protect")
|
||||||
| map(attribute="key")
|
| map(attribute="key")
|
||||||
| map("int")
|
|
||||||
| list
|
| list
|
||||||
%}
|
%}
|
||||||
{% if loop_protect %}
|
{% if loop_protect %}
|
||||||
loop-protect disable-timer {{ aruba__loop_protect_disable_timer | int }}
|
loop-protect disable-timer {{ aruba__loop_protect_disable_timer | int }}
|
||||||
loop-protect transmit-interval {{ aruba__loop_protect_tx_interval | int }}
|
loop-protect transmit-interval {{ aruba__loop_protect_tx_interval | int }}
|
||||||
loop-protect {{ loop_protect | join(",") }}
|
loop-protect {{ loop_protect | aruba_ints }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if aruba__default_gateways | ipv4 %}
|
{% if aruba__default_gateways | ipv4 %}
|
||||||
|
@ -110,11 +108,10 @@ set untagged =
|
||||||
| selectattr("value.untagged", "defined")
|
| selectattr("value.untagged", "defined")
|
||||||
| selectattr("value.untagged", "==", id)
|
| selectattr("value.untagged", "==", id)
|
||||||
| map(attribute="key")
|
| map(attribute="key")
|
||||||
| map("int")
|
|
||||||
| list
|
| list
|
||||||
%}
|
%}
|
||||||
{% if untagged %}
|
{% if untagged %}
|
||||||
untagged {{ untagged | join(",") }}
|
untagged {{ untagged | aruba_ints }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{%
|
{%
|
||||||
set tagged =
|
set tagged =
|
||||||
|
@ -123,11 +120,10 @@ set tagged =
|
||||||
| selectattr("value.tagged", "defined")
|
| selectattr("value.tagged", "defined")
|
||||||
| selectattr("value.tagged", "contains", id)
|
| selectattr("value.tagged", "contains", id)
|
||||||
| map(attribute="key")
|
| map(attribute="key")
|
||||||
| map("int")
|
|
||||||
| list
|
| list
|
||||||
%}
|
%}
|
||||||
{% if tagged %}
|
{% if tagged %}
|
||||||
tagged {{ tagged | join(",") }}
|
tagged {{ tagged | aruba_ints }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if vlan.addresses | default([]) %}
|
{% if vlan.addresses | default([]) %}
|
||||||
{% for address in vlan.addresses | ipv4 %}
|
{% for address in vlan.addresses | ipv4 %}
|
||||||
|
@ -148,6 +144,11 @@ set tagged =
|
||||||
interface {{ id | int }}
|
interface {{ id | int }}
|
||||||
{% if iface.name is defined %}
|
{% if iface.name is defined %}
|
||||||
name {{ iface.name | enquote }}
|
name {{ iface.name | enquote }}
|
||||||
|
{% endif %}
|
||||||
|
{% if iface.enabled | default(True) %}
|
||||||
|
enable
|
||||||
|
{% else %}
|
||||||
|
no enable
|
||||||
{% endif %}
|
{% endif %}
|
||||||
exit
|
exit
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue