X-Git-Url: https://git.proxmox.com/?p=pve-common.git;a=blobdiff_plain;f=src%2FPVE%2FSectionConfig.pm;fp=src%2FPVE%2FSectionConfig.pm;h=e3546559d29f581f79f493533c4e7bc4805d036a;hp=0a9f1cd0bca202b32ed8f391a387412f1fc07bf8;hb=5028848d42f90535a0c8a1e60a488cf7b8986b62;hpb=6870afa45594da42ee7742e219358c5c76d059d2 diff --git a/src/PVE/SectionConfig.pm b/src/PVE/SectionConfig.pm index 0a9f1cd..e354655 100644 --- a/src/PVE/SectionConfig.pm +++ b/src/PVE/SectionConfig.pm @@ -543,4 +543,19 @@ sub assert_if_modified { PVE::Tools::assert_if_modified($cfg->{digest}, $digest); } +sub delete_from_config { + my ($config, $option_schema, $new_options, $to_delete) = @_; + + for my $k ($to_delete->@*) { + my $d = $option_schema->{$k} || die "no such option '$k'\n"; + die "unable to delete required option '$k'\n" if !$d->{optional}; + die "unable to delete fixed option '$k'\n" if $d->{fixed}; + die "cannot set and delete property '$k' at the same time!\n" + if defined($new_options->{$k}); + delete $config->{$k}; + } + + return $config; +} + 1;