[pve-devel] [PATCH storage] CephConfig: map special config key characters to _

Dominik Csapak d.csapak at proxmox.com
Wed Jun 19 09:17:52 CEST 2019


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 at proxmox.com>
---
i forgot to send this patch, it is necessary to get consistent
config accesses in our ceph stack

 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.11.0





More information about the pve-devel mailing list