[pve-devel] [PATCH storage 3/3] CephConfig: read monitor addresses also from mon_host for cephfs

Dominik Csapak d.csapak at proxmox.com
Thu Jun 27 10:43:12 CEST 2019


since we write only the mon_host config beginning with nautilus,
we have to get the monitor ips from there as well

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 PVE/CephConfig.pm | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/PVE/CephConfig.pm b/PVE/CephConfig.pm
index 31bb887..4a303c2 100644
--- a/PVE/CephConfig.pm
+++ b/PVE/CephConfig.pm
@@ -121,10 +121,31 @@ sub get_monaddr_list {
 
     my $config = $parse_ceph_file->($configfile);
 
-    my @monids = grep { /mon\./ && defined($config->{$_}->{'mon addr'}) } %{$config};
+    my $monhostlist = {};
 
-    return join(',', sort map { $config->{$_}->{'mon addr'} } @monids);
-};
+    # get all ip adresses from mon_host
+    my $monhosts = [ split (/[ ,;]+/, $config->{global}->{mon_host} // "") ];
+
+    foreach my $monhost (@$monhosts) {
+	$monhost =~ s/^\[?v\d\://; # remove beginning of vector
+	$monhost =~ s|/\d+\]?||; # remove end of vector
+	my $host = $get_host->($monhost);
+	if ($host ne "") {
+	    $monhostlist->{$host} = 1;
+	}
+    }
+
+    # then get all addrs from mon. sections
+    for my $section ( keys %$config ) {
+	next if $section !~ m/^mon\./;
+
+	if (my $addr = $config->{$section}->{mon_addr}) {
+	    $monhostlist->{$addr} = 1;
+	}
+    }
+
+    return join(',', sort keys %$monhostlist);
+}
 
 sub hostlist {
     my ($list_text, $separator) = @_;
-- 
2.20.1





More information about the pve-devel mailing list