Add missing user defined interface support

Macvlan interfaces can have a user defined interface within the host
config. This change ensures that the capability, which is documented in
the nspawn_host role, is actually functional.

Change-Id: I083042a791d9213b9b1872a239dc18dc6c7ae46e
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
Kevin Carter 2018-08-21 15:23:06 -05:00
parent 29608b5012
commit d01150301e
No known key found for this signature in database
GPG Key ID: 9443251A787B9FB3
4 changed files with 12 additions and 7 deletions

View File

@ -18,7 +18,7 @@
nspawn_networks:
nspawn_address:
bridge: "nspawn0"
interface: "mv-mv-nspawn0"
interface: "mv-nspawn0"
address: dhcp
# This is a list of items that will be passed into the container as READ-ONLY

View File

@ -362,10 +362,10 @@
systemd_networks: |-
{% set _networks = [] %}
{% for _, value in nspawn_combined_networks.items() %}
{% if value.bridge is defined %}
{% set _network = {'interface': 'mv-mv-' + value.bridge.split('br-')[-1]} %}
{% if value.interface is defined %}
{% set _network = {'interface': 'mv-' + value.interface} %}
{% else %}
{% set _network = {'interface': value.interface} %}
{% set _network = {'interface': 'mv-mv-' + value.bridge.split('br-')[-1]} %}
{% endif %}
{% if value.address is defined %}
{% set _ = _network.__setitem__('address', value.address) %}

View File

@ -25,9 +25,12 @@ Bind={{ bind }}:{{ bind }}
[Network]
{% set macvlans = [] %}
{% for key, value in nspawn_combined_networks.items() %}
{% if value.bridge is defined %}
{% set _ = macvlans.append('mv-' + value.bridge.split('br-')[-1]) %}
{% if value.interface is defined %}
{% set macvlan = value.interface %}
{% else %}
{% set macvlan = 'mv-' + value.bridge.split('br-')[-1] %}
{% endif %}
{% set _ = macvlans.append(macvlan) %}
{% endfor %}
{% if macvlans | length > 0 %}
Private=yes

View File

@ -19,7 +19,9 @@
{% endif %}
{% set macvlans = [] %}
{% for key, value in nspawn_combined_networks.items() %}
{% if value.bridge is defined %}
{% if value.interface is defined %}
{% set macvlan = value.interface %}
{% else %}
{% set macvlan = 'mv-' + value.bridge.split('br-')[-1] %}
{% endif %}
{% if macvlan not in macvlans %}