CephConfig: map special config key characters to _

we want a consistent config has, regardless of how the user or a tool
adds it to the config, so we map ' ' and '-' to '_' in the keys

this way we can always access the correct key without trying multiple
times

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak
2019-06-19 09:17:52 +02:00
committed by Thomas Lamprecht
parent de0cd0c2e0
commit 9841fa31b5

View File

@ -33,7 +33,11 @@ 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 we
# map it to '_' to get a consistent hash
$key =~ s/[-\ ]/_/g;
$cfg->{$section}->{$key} = $val;
}
}