diff --git a/PVE/Jobs/Plugin.pm b/PVE/Jobs/Plugin.pm index 69c31cf2..9cf7f98d 100644 --- a/PVE/Jobs/Plugin.pm +++ b/PVE/Jobs/Plugin.pm @@ -52,6 +52,21 @@ sub parse_config { return $cfg; } +# call the plugin specific decode/encode code +sub decode_value { + my ($class, $type, $key, $value) = @_; + + my $plugin = __PACKAGE__->lookup($type); + return $plugin->decode_value($type, $key, $value); +} + +sub encode_value { + my ($class, $type, $key, $value) = @_; + + my $plugin = __PACKAGE__->lookup($type); + return $plugin->encode_value($type, $key, $value); +} + sub run { my ($class, $cfg) = @_; # implement in subclass diff --git a/PVE/Jobs/VZDump.pm b/PVE/Jobs/VZDump.pm index 043b7ace..87733e74 100644 --- a/PVE/Jobs/VZDump.pm +++ b/PVE/Jobs/VZDump.pm @@ -7,6 +7,7 @@ use PVE::INotify; use PVE::VZDump::Common; use PVE::API2::VZDump; use PVE::Cluster; +use PVE::JSONSchema; use base qw(PVE::Jobs::Plugin); @@ -36,6 +37,32 @@ sub options { return $options; } +sub decode_value { + my ($class, $type, $key, $value) = @_; + + if ($key eq 'prune-backups' && !ref($value)) { + $value = PVE::JSONSchema::parse_property_string( + 'prune-backups', + $value, + ); + } + + return $value; +} + +sub encode_value { + my ($class, $type, $key, $value) = @_; + + if ($key eq 'prune-backups' && ref($value) eq 'HASH') { + $value = PVE::JSONSchema::print_property_string( + $value, + 'prune-backups', + ); + } + + return $value; +} + sub run { my ($class, $conf) = @_;