]> git.proxmox.com Git - pve-storage.git/commitdiff
CephConfig: read monitor addresses also from mon_host for cephfs
authorDominik Csapak <d.csapak@proxmox.com>
Thu, 27 Jun 2019 08:43:12 +0000 (10:43 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 27 Jun 2019 14:16:36 +0000 (16:16 +0200)
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@proxmox.com>
PVE/CephConfig.pm

index 31bb887d56386b8a8bc761009044d61941664966..4a303c27111819ad5e1948508e0833187e3f3519 100644 (file)
@@ -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) = @_;