Skip to content

Commit

Permalink
Ignore dev option in custom routes
Browse files Browse the repository at this point in the history
Network scripts custom route needed to use dev with options.
Network manager don't need it. Ignoring dev for backwards
compatibility.
  • Loading branch information
bbezak authored and eb4x committed Apr 13, 2023
1 parent aa422fc commit b34979c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
7 changes: 4 additions & 3 deletions templates/bond_nmconnection.j2
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ method=disabled
{% endif %}
{% for route in item.route | default([]) %}
{% set route_options = [] %}
{% for option in route.options | default([]) %}
{# Ignoring dev option - needed in Network Scripts #}
{# as it is not needed in Network Manager #}
{% for option in route.options | default([]) | reject('match', '^dev ') %}
{% if option is mapping %}
{# We're gonna assume it's a mapping of one key with value, and #}
{# since dict2items returns a array, we're selecting the first item #}
{# since dict2items returns an array, we're selecting the first item #}
{% set option = option | dict2items | first %}
{% set _ = route_options.append(option.key ~ '=' ~ option.value) %}
{% elif option in ['onlink', 'lock-window', 'lock-cwdn', 'lock-mtu'] %}
Expand All @@ -69,7 +71,6 @@ method=disabled
{% set _ = route_options.append(option) %}
{% endif %}
{% endfor %}
{# TODO: dev #}
{% if 'gateway' in route %}
{% set route_string = (route.network ~'/'~ route.netmask) | ipaddr('network/prefix') ~ ',' ~ route.gateway %}
{% else %}
Expand Down
7 changes: 4 additions & 3 deletions templates/bridge_nmconnection.j2
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ method=disabled
{% endif %}
{% for route in item.route | default([]) %}
{% set route_options = [] %}
{% for option in route.options | default([]) %}
{# Ignoring dev option - needed in Network Scripts #}
{# as it is not needed in Network Manager #}
{% for option in route.options | default([]) | reject('match', '^dev ') %}
{% if option is mapping %}
{# We're gonna assume it's a mapping of one key with value, and #}
{# since dict2items returns a array, we're selecting the first item #}
{# since dict2items returns an array, we're selecting the first item #}
{% set option = option | dict2items | first %}
{% set _ = route_options.append(option.key ~ '=' ~ option.value) %}
{% elif option in ['onlink', 'lock-window', 'lock-cwdn', 'lock-mtu'] %}
Expand All @@ -47,7 +49,6 @@ method=disabled
{% set _ = route_options.append(option) %}
{% endif %}
{% endfor %}
{# TODO: dev #}
{% if 'gateway' in route %}
{% set route_string = (route.network ~'/'~ route.netmask) | ipaddr('network/prefix') ~ ',' ~ route.gateway %}
{% else %}
Expand Down
7 changes: 4 additions & 3 deletions templates/ethernet_nmconnection.j2
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ method=disabled
{% endif %}
{% for route in item.route | default([]) %}
{% set route_options = [] %}
{% for option in route.options | default([]) %}
{# Ignoring dev option - needed in Network Scripts #}
{# as it is not needed in Network Manager #}
{% for option in route.options | default([]) | reject('match', '^dev ') %}
{% if option is mapping %}
{# We're gonna assume it's a mapping of one key with value, and #}
{# since dict2items returns a array, we're selecting the first item #}
{# since dict2items returns an array, we're selecting the first item #}
{% set option = option | dict2items | first %}
{% set _ = route_options.append(option.key ~ '=' ~ option.value) %}
{% elif option in ['onlink', 'lock-window', 'lock-cwdn', 'lock-mtu'] %}
Expand All @@ -55,7 +57,6 @@ method=disabled
{% set _ = route_options.append(option) %}
{% endif %}
{% endfor %}
{# TODO: dev #}
{% if 'gateway' in route %}
{% set route_string = (route.network ~'/'~ route.netmask) | ipaddr('network/prefix') ~ ',' ~ route.gateway %}
{% else %}
Expand Down

0 comments on commit b34979c

Please sign in to comment.