[pve-devel] [RFC PATCH 1/3] PVE::API2::Ceph: network_interfaces update + ipv6

Wolfgang Bumiller w.bumiller at proxmox.com
Mon Jun 22 16:07:05 CEST 2015


---
 PVE/API2/Ceph.pm | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/PVE/API2/Ceph.pm b/PVE/API2/Ceph.pm
index 217b8ce..b7eea84 100644
--- a/PVE/API2/Ceph.pm
+++ b/PVE/API2/Ceph.pm
@@ -765,16 +765,18 @@ __PACKAGE__->register_method ({
 my $find_node_ip = sub {
     my ($cidr) = @_;
 
-    my $config = PVE::INotify::read_file('interfaces');
-
     my $net = Net::IP->new($cidr) || die Net::IP::Error() . "\n";
+    my $id = $net->version == 6 ? 'address6' : 'address';
+
+    my $config = PVE::INotify::read_file('interfaces');
+    my $ifaces = $config->{ifaces};
 
-    foreach my $iface (keys %$config) {
+    foreach my $iface (keys %$ifaces) {
 	my $d = $config->{$iface};
-	next if !$d->{address};
-	my $a = Net::IP->new($d->{address});
+	next if !$d->{$id};
+	my $a = Net::IP->new($d->{$id});
 	next if !$a;
-	return $d->{address} if $net->overlaps($a);
+	return $d->{$id} if $net->overlaps($a);
     }
 
     die "unable to find local address within network '$cidr'\n";
-- 
2.1.4





More information about the pve-devel mailing list