cephconfig: allow writing arbitrary sections
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>
This commit is contained in:
committed by
Fabian Grünbichler
parent
094f3f901f
commit
8777f4a600
@ -60,6 +60,7 @@ my $parse_ceph_file = sub {
|
|||||||
sub write_ceph_config {
|
sub write_ceph_config {
|
||||||
my ($filename, $cfg) = @_;
|
my ($filename, $cfg) = @_;
|
||||||
|
|
||||||
|
my $written_sections = {};
|
||||||
my $out = '';
|
my $out = '';
|
||||||
|
|
||||||
my $cond_write_sec = sub {
|
my $cond_write_sec = sub {
|
||||||
@ -67,12 +68,15 @@ sub write_ceph_config {
|
|||||||
|
|
||||||
for my $section (sort keys $cfg->%*) {
|
for my $section (sort keys $cfg->%*) {
|
||||||
next if $section !~ m/^$re$/;
|
next if $section !~ m/^$re$/;
|
||||||
|
next if exists($written_sections->{$section});
|
||||||
|
|
||||||
$out .= "[$section]\n";
|
$out .= "[$section]\n";
|
||||||
for my $key (sort keys $cfg->{$section}->%*) {
|
for my $key (sort keys $cfg->{$section}->%*) {
|
||||||
$out .= "\t $key = $cfg->{$section}->{$key}\n";
|
$out .= "\t $key = $cfg->{$section}->{$key}\n";
|
||||||
}
|
}
|
||||||
$out .= "\n";
|
$out .= "\n";
|
||||||
|
|
||||||
|
$written_sections->{$section} = 1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -89,6 +93,8 @@ sub write_ceph_config {
|
|||||||
qr/mon\..*/,
|
qr/mon\..*/,
|
||||||
qr/osd\..*/,
|
qr/osd\..*/,
|
||||||
qr/mgr\..*/,
|
qr/mgr\..*/,
|
||||||
|
|
||||||
|
qr/.*/,
|
||||||
);
|
);
|
||||||
|
|
||||||
for my $re (@rexprs) {
|
for my $re (@rexprs) {
|
||||||
|
|||||||
Reference in New Issue
Block a user