]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/CephConfig.pm
CephConfig: do not always interpret '; ' as a comment
[pve-storage.git] / PVE / CephConfig.pm
index b420fcc3ca83cb61e4d58cf772595f561f502a57..3ff49eeecdc77adc7ef5716e59b1c69dbc05ca10 100644 (file)
@@ -21,8 +21,9 @@ sub parse_ceph_config {
     my $section;
 
     foreach my $line (@lines) {
-       $line =~ s/[;#].*$//;
+       $line =~ s/#.*$//;
        $line =~ s/^\s+//;
+       $line =~ s/^;.*$//;
        $line =~ s/\s+$//;
        next if !$line;
 
@@ -33,7 +34,10 @@ sub parse_ceph_config {
        }
 
        if ($line =~ m/^(.*?\S)\s*=\s*(\S.*)$/) {
-           $cfg->{$section}->{$1} = $2;
+           my ($key, $val) = ($1, $2);
+           # ceph treats ' ', '_' and '-' in keys the same, so lets do too
+           $key =~ s/[-\ ]/_/g;
+           $cfg->{$section}->{$key} = $val;
        }
 
     }
@@ -99,17 +103,16 @@ my $ceph_get_key = sub {
 sub get_monaddr_list {
     my ($configfile) = shift;
 
-    my $server;
-
     if (!defined($configfile)) {
        warn "No ceph config specified\n";
        return;
     }
 
     my $config = $parse_ceph_file->($configfile);
-    @$server = sort map { $config->{$_}->{'mon addr'} } grep {/mon/} %{$config};
 
-    return join(',', @$server);
+    my @monids = grep { /mon\./ && defined($config->{$_}->{'mon addr'}) } %{$config};
+
+    return join(',', sort map { $config->{$_}->{'mon addr'} } @monids);
 };
 
 sub hostlist {