From a3fcd5d9f011d3c86a9a8f2f4260dd7619f7cb1f Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Fri, 17 Sep 2021 15:11:35 +0100 Subject: [PATCH] Support VLAN links network_info.json With older versions of cloud-init (e.g. CentOS 7), it seemed to be possible to specify an interface named ., and cloud-init would assume that this is a VLAN interface on with VLAN ID . In more recent versions of cloud-init (e.g. CentOS 8), several additional parameters are required in more recent cloud-init versions: * vlan_id * vlan_link * vlan_mac_address While the MAC address is required, it does seem possible to set it to null. Additionally, the backend device must be listed in the configuration. --- templates/network_info.json.j2 | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/templates/network_info.json.j2 b/templates/network_info.json.j2 index bb3048e..cba3024 100644 --- a/templates/network_info.json.j2 +++ b/templates/network_info.json.j2 @@ -4,12 +4,24 @@ {%- set device_list=configdrive_network_device_list | map(attribute='device') | list %} "links": [ {%- for dev in configdrive_network_device_list %} +{%- if dev.type | default == "vlan" and dev.backend is defined and dev.backend[0] not in device_list %} + { + "name": "{{ dev.backend[0] }}", + "id": "{{ dev.backend[0] }}", + "type": "phy" + }, +{%- endif %} { "name": "{{ dev.device }}", "id": "{{ dev.device }}", "type": "{{ dev.type | default('phy') }}", -{%- if dev.mac is defined %} +{%- if dev.type | default == "vlan" and dev.backend is defined %} + "vlan_id": {{ dev.device.split('.')[1] }}, + "vlan_link": "{{ dev.backend[0] }}", + "vlan_mac_address": {% if dev.mac is defined %}"{{ dev.mac }}"{% else %}null{% endif %}, +{%- elif dev.mac is defined %} "ethernet_mac_address": "{{ dev.mac }}", +{%- endif %} {%- endif %} "mtu": "{{ dev.mtu | default(1500) }}" }{% if not loop.last %},{% endif %}