From 00f40d5f6cd1bde442acb3e165046fc7a590314c Mon Sep 17 00:00:00 2001 From: Ivo Marino Date: Thu, 3 Oct 2024 14:18:51 +0200 Subject: [PATCH] Added support for interface name in cloud-init, implements #559 --- lib/vm-core | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/vm-core b/lib/vm-core index f6ca126..d04029f 100644 --- a/lib/vm-core +++ b/lib/vm-core @@ -266,7 +266,8 @@ core::create_cloud_init(){ mkdir -p "${_cloud_init_dir}" if [ -n "${_network_config}" ]; then - # Example netconfig param: "ip=10.0.0.2/24;gateway=10.0.0.1;nameservers=1.1.1.1,8.8.8.8" + # Example netconfig param: "interface=vio0;ip=10.0.0.2/24;gateway=10.0.0.1;nameservers=1.1.1.1,8.8.8.8" + _network_config_interface="$(echo "${_network_config}" | pcregrep -o "interface=\K[^;]*" || true)"; _network_config_interface="${_network_config_interface:-eth0}" _network_config_ipaddress="$(echo "${_network_config}" | pcregrep -o "ip=\K[^;]*")" _network_config_gateway="$(echo "${_network_config}" | pcregrep -o "gateway=\K[^;]*")" _network_config_nameservers="$(echo "${_network_config}" | pcregrep -o "nameservers=\K[^;]*")" @@ -281,7 +282,7 @@ core::create_cloud_init(){ version: 2 ethernets: id0: - set-name: eth0 + set-name: ${_network_config_interface} match: macaddress: "${_mac}" addresses: