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:
parent
915e7a0216
commit
1791dd4a71
@ -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
65
src/PVE/VZDump/JobBase.pm
Normal 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;
|
Loading…
Reference in New Issue
Block a user