[pve-devel] [PATCH pve-network 27/38] small bugfixes

Alexandre Derumier aderumier at odiso.com
Sun Nov 8 15:19:29 CET 2020


---
 PVE/API2/Network/SDN/Dns.pm        | 2 +-
 PVE/Network/SDN/Controllers.pm     | 2 +-
 PVE/Network/SDN/Ipams/PVEPlugin.pm | 6 +++---
 PVE/Network/SDN/Subnets.pm         | 4 ++--
 PVE/Network/SDN/Vnets.pm           | 2 +-
 PVE/Network/SDN/Zones.pm           | 2 +-
 6 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/PVE/API2/Network/SDN/Dns.pm b/PVE/API2/Network/SDN/Dns.pm
index ea26af3..3d08552 100644
--- a/PVE/API2/Network/SDN/Dns.pm
+++ b/PVE/API2/Network/SDN/Dns.pm
@@ -147,7 +147,7 @@ __PACKAGE__->register_method ({
 
 		$dns_cfg->{ids}->{$id} = $opts;
 
-		my $plugin = PVE::Network::SDN::Dns::Plugin->lookup($scfg->{type});
+		my $plugin = PVE::Network::SDN::Dns::Plugin->lookup($opts->{type});
 		$plugin->on_update_hook($opts);
 
 		PVE::Network::SDN::Dns::write_config($dns_cfg);
diff --git a/PVE/Network/SDN/Controllers.pm b/PVE/Network/SDN/Controllers.pm
index c210516..f652d7f 100644
--- a/PVE/Network/SDN/Controllers.pm
+++ b/PVE/Network/SDN/Controllers.pm
@@ -55,7 +55,7 @@ sub lock_sdn_controllers_config {
 sub sdn_controllers_ids {
     my ($cfg) = @_;
 
-    return keys %{$cfg->{ids}};
+    return sort keys %{$cfg->{ids}};
 }
 
 sub complete_sdn_controller {
diff --git a/PVE/Network/SDN/Ipams/PVEPlugin.pm b/PVE/Network/SDN/Ipams/PVEPlugin.pm
index 741a680..a3ad3d6 100644
--- a/PVE/Network/SDN/Ipams/PVEPlugin.pm
+++ b/PVE/Network/SDN/Ipams/PVEPlugin.pm
@@ -56,7 +56,7 @@ sub del_subnet {
 
 	my $db = read_db();
 	my $ips = $db->{subnets}->{$cidr}->{ips};
-	die "can't delete subnet, not empty" if keys %{$ips} > 0;
+	die "can't delete subnet $cidr , not empty" if keys %{$ips} > 0;
 	delete $db->{subnets}->{$cidr};
 	write_db($db);
     });
@@ -74,7 +74,7 @@ sub add_ip {
 	my $db = read_db();
 	my $s = $db->{subnets}->{$cidr};
 
-	die "ip already exist" if defined($s->{ips}->{$ip});
+	die "ip $ip already exist" if defined($s->{ips}->{$ip});
 
 	#verify that ip is valid for this subnet
 	$s->{ips}->{$ip} = 1;
@@ -127,7 +127,7 @@ sub del_ip {
 	my $s = $db->{subnets}->{$cidr};
 	return if !$ip;
 
-	die "ip does not exist in pam" if !defined($s->{ips}->{$ip});
+	die "ip $ip does not exist in pam" if !defined($s->{ips}->{$ip});
 	delete $s->{ips}->{$ip};
 	write_db($db);
     });
diff --git a/PVE/Network/SDN/Subnets.pm b/PVE/Network/SDN/Subnets.pm
index 5b99c91..0f14f6f 100644
--- a/PVE/Network/SDN/Subnets.pm
+++ b/PVE/Network/SDN/Subnets.pm
@@ -37,7 +37,7 @@ sub write_config {
 sub sdn_subnets_ids {
     my ($cfg) = @_;
 
-    return keys %{$cfg->{ids}};
+    return sort keys %{$cfg->{ids}};
 }
 
 sub complete_sdn_subnet {
@@ -191,7 +191,7 @@ sub next_free_ip {
 sub add_ip {
     my ($subnetid, $subnet, $ip, $hostname) = @_;
 
-    return if !$subnet;
+    return if !$subnet || !$ip; 
 
     my $ipamid = $subnet->{ipam};
     my $dns = $subnet->{dns};
diff --git a/PVE/Network/SDN/Vnets.pm b/PVE/Network/SDN/Vnets.pm
index d45ef2a..96aa422 100644
--- a/PVE/Network/SDN/Vnets.pm
+++ b/PVE/Network/SDN/Vnets.pm
@@ -35,7 +35,7 @@ sub write_config {
 sub sdn_vnets_ids {
     my ($cfg) = @_;
 
-    return keys %{$cfg->{ids}};
+    return sort keys %{$cfg->{ids}};
 }
 
 sub complete_sdn_vnet {
diff --git a/PVE/Network/SDN/Zones.pm b/PVE/Network/SDN/Zones.pm
index 75f3233..cef4dd2 100644
--- a/PVE/Network/SDN/Zones.pm
+++ b/PVE/Network/SDN/Zones.pm
@@ -61,7 +61,7 @@ sub write_config {
 sub sdn_zones_ids {
     my ($cfg) = @_;
 
-    return keys %{$cfg->{ids}};
+    return sort keys %{$cfg->{ids}};
 }
 
 sub complete_sdn_zone {
-- 
2.20.1





More information about the pve-devel mailing list