From 5b79dac99b3e4c4c7e23cf8acc3f7e29961f3d72 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Thu, 27 Jun 2019 10:43:12 +0200 Subject: [PATCH] CephConfig: read monitor addresses also from mon_host for cephfs 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 --- 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) = @_;