5
0
mirror of git://git.proxmox.com/git/pve-guest-common.git synced 2024-12-22 13:34:00 +03:00

add VZDump::JobBase, split out from manager

We need access to vzdump type jobs at this level, else we cannot do
things like removing VMIDs on purge of their guest.

So split out the independent part (all but the actual run method)
from pve-manager's PVE::Jobs::VZDump module.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2022-11-12 16:21:33 +01:00
parent 915e7a0216
commit 1791dd4a71
2 changed files with 66 additions and 0 deletions

View File

@ -17,6 +17,7 @@ install: PVE
install -d ${PERL5DIR}/PVE/VZDump
install -m 0644 PVE/VZDump/Plugin.pm ${PERL5DIR}/PVE/VZDump/
install -m 0644 PVE/VZDump/Common.pm ${PERL5DIR}/PVE/VZDump/
install -m 0644 PVE/VZDump/JobBase.pm ${PERL5DIR}/PVE/VZDump/
.PHONY: check
check:

65
src/PVE/VZDump/JobBase.pm Normal file
View File

@ -0,0 +1,65 @@
package PVE::VZDump::JobBase;
use strict;
use warnings;
use PVE::JSONSchema;
use PVE::VZDump::Common;
use base qw(PVE::Job::Registry);
sub type {
return 'vzdump';
}
my $props = PVE::VZDump::Common::json_config_properties();
sub properties {
return $props;
}
sub options {
my $options = {
enabled => { optional => 1 },
schedule => {},
comment => { optional => 1 },
'repeat-missed' => { optional => 1 },
};
foreach my $opt (keys %$props) {
if ($props->{$opt}->{optional}) {
$options->{$opt} = { optional => 1 };
} else {
$options->{$opt} = {};
}
}
return $options;
}
sub decode_value {
my ($class, $type, $key, $value) = @_;
if ((my $format = $PVE::VZDump::Common::PROPERTY_STRINGS->{$key}) && !ref($value)) {
$value = PVE::JSONSchema::parse_property_string($format, $value);
}
return $value;
}
sub encode_value {
my ($class, $type, $key, $value) = @_;
if ((my $format = $PVE::VZDump::Common::PROPERTY_STRINGS->{$key}) && ref($value) eq 'HASH') {
$value = PVE::JSONSchema::print_property_string($value, $format);
}
return $value;
}
sub run {
my ($class, $conf) = @_;
die "config base class, implement me in sub class"
}
1;