From 9841fa31b584d323d5389685e39d650433139450 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Wed, 19 Jun 2019 09:17:52 +0200 Subject: [PATCH] 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 --- PVE/CephConfig.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/PVE/CephConfig.pm b/PVE/CephConfig.pm index 1719b8b..ced8358 100644 --- a/PVE/CephConfig.pm +++ b/PVE/CephConfig.pm @@ -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; } } -- 2.39.2