From d4fa9981b805bcb53144b92aa28b47b9e56d4082 Mon Sep 17 00:00:00 2001 From: Mira Limbeck Date: Thu, 28 May 2020 16:48:36 +0200 Subject: [PATCH] fix #2748: make order of interfaces consistent As perl hashes have random order, sort them before iterating through. This makes the output of 'qm cloudinit dump network' consistent between calls if the config has not changed. Signed-off-by: Mira Limbeck --- PVE/QemuServer/Cloudinit.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PVE/QemuServer/Cloudinit.pm b/PVE/QemuServer/Cloudinit.pm index b3ae57b1..439de99c 100644 --- a/PVE/QemuServer/Cloudinit.pm +++ b/PVE/QemuServer/Cloudinit.pm @@ -172,7 +172,7 @@ sub configdrive2_network { } my @ifaces = grep(/^net(\d+)$/, keys %$conf); - foreach my $iface (@ifaces) { + foreach my $iface (sort @ifaces) { (my $id = $iface) =~ s/^net//; next if !$conf->{"ipconfig$id"}; my $net = PVE::QemuServer::parse_ipconfig($conf->{"ipconfig$id"}); @@ -252,7 +252,7 @@ sub nocloud_network_v2 { my $dns_done; my @ifaces = grep(/^net(\d+)$/, keys %$conf); - foreach my $iface (@ifaces) { + foreach my $iface (sort @ifaces) { (my $id = $iface) =~ s/^net//; next if !$conf->{"ipconfig$id"}; @@ -323,7 +323,7 @@ sub nocloud_network { . "config:\n"; my @ifaces = grep(/^net(\d+)$/, keys %$conf); - foreach my $iface (@ifaces) { + foreach my $iface (sort @ifaces) { (my $id = $iface) =~ s/^net//; next if !$conf->{"ipconfig$id"};