]> git.proxmox.com Git - pve-storage.git/commitdiff
cephconfig: allow writing arbitrary sections
authorMax Carrara <m.carrara@proxmox.com>
Tue, 2 Apr 2024 14:55:16 +0000 (16:55 +0200)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Thu, 11 Apr 2024 09:53:37 +0000 (11:53 +0200)
This adds support for writing arbitrary sections to 'ceph.conf' while
ensuring that already written sections are not duplicated.

Signed-off-by: Max Carrara <m.carrara@proxmox.com>
Tested-by: Friedrich Weber <f.weber@proxmox.com>
src/PVE/CephConfig.pm

index 9934fd52cbec6c160880a938f63e78849a32d011..1fb467daeaeec1f1297d920813fff69dead3a4be 100644 (file)
@@ -60,6 +60,7 @@ my $parse_ceph_file = sub {
 sub write_ceph_config {
     my ($filename, $cfg) = @_;
 
+    my $written_sections = {};
     my $out = '';
 
     my $cond_write_sec = sub {
@@ -67,12 +68,15 @@ sub write_ceph_config {
 
        for my $section (sort keys $cfg->%*) {
            next if $section !~ m/^$re$/;
+           next if exists($written_sections->{$section});
 
            $out .= "[$section]\n";
            for my $key (sort keys $cfg->{$section}->%*) {
                $out .= "\t $key = $cfg->{$section}->{$key}\n";
            }
            $out .= "\n";
+
+           $written_sections->{$section} = 1;
        }
     };
 
@@ -89,6 +93,8 @@ sub write_ceph_config {
        qr/mon\..*/,
        qr/osd\..*/,
        qr/mgr\..*/,
+
+       qr/.*/,
     );
 
     for my $re (@rexprs) {