]> git.proxmox.com Git - qemu-server.git/commitdiff
fix #2748: make order of interfaces consistent
authorMira Limbeck <m.limbeck@proxmox.com>
Thu, 28 May 2020 14:48:36 +0000 (16:48 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 2 Jun 2020 09:45:35 +0000 (11:45 +0200)
As perl hashes have random order, sort them before iterating through.
This makes the output of 'qm cloudinit dump <vmid> network' consistent
between calls if the config has not changed.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
PVE/QemuServer/Cloudinit.pm

index b3ae57b11bdceaef514d2b2ee73652dc5bf8915a..439de99c009c88966e5a94f638a47026aecba87c 100644 (file)
@@ -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"};