]> git.proxmox.com Git - pve-manager.git/blame - PVE/Jobs/VZDump.pm
vzdump: handle new 'performance' property string
[pve-manager.git] / PVE / Jobs / VZDump.pm
CommitLineData
76c6ee8a
DC
1package PVE::Jobs::VZDump;
2
3use strict;
4use warnings;
5
6use PVE::INotify;
7use PVE::VZDump::Common;
8use PVE::API2::VZDump;
9use PVE::Cluster;
b3422046 10use PVE::JSONSchema;
76c6ee8a
DC
11
12use base qw(PVE::Jobs::Plugin);
13
14sub type {
15 return 'vzdump';
16}
17
18my $props = PVE::VZDump::Common::json_config_properties();
19
20sub properties {
21 return $props;
22}
23
24sub options {
25 my $options = {
26 enabled => { optional => 1 },
27 schedule => {},
998b61fb 28 comment => { optional => 1 },
c61c192e 29 'repeat-missed' => { optional => 1 },
76c6ee8a
DC
30 };
31 foreach my $opt (keys %$props) {
32 if ($props->{$opt}->{optional}) {
33 $options->{$opt} = { optional => 1 };
34 } else {
35 $options->{$opt} = {};
36 }
37 }
38
39 return $options;
40}
41
b3422046
DC
42sub decode_value {
43 my ($class, $type, $key, $value) = @_;
44
93880785
FE
45 if ((my $format = $PVE::VZDump::Common::PROPERTY_STRINGS->{$key}) && !ref($value)) {
46 $value = PVE::JSONSchema::parse_property_string($format, $value);
b3422046
DC
47 }
48
49 return $value;
50}
51
52sub encode_value {
53 my ($class, $type, $key, $value) = @_;
54
93880785
FE
55 if ((my $format = $PVE::VZDump::Common::PROPERTY_STRINGS->{$key}) && ref($value) eq 'HASH') {
56 $value = PVE::JSONSchema::print_property_string($value, $format);
b3422046
DC
57 }
58
59 return $value;
60}
61
76c6ee8a
DC
62sub run {
63 my ($class, $conf) = @_;
64
65 # remove all non vzdump related options
66 foreach my $opt (keys %$conf) {
67 delete $conf->{$opt} if !defined($props->{$opt});
68 }
69
93880785
FE
70 # Required as string parameters
71 for my $key (keys $PVE::VZDump::Common::PROPERTY_STRINGS->%*) {
72 if ($conf->{$key} && ref($conf->{$key}) eq 'HASH') {
73 my $format = $PVE::VZDump::Common::PROPERTY_STRINGS->{$key};
74 $conf->{$key} = PVE::JSONSchema::print_property_string($conf->{$key}, $format);
75 }
4048af34 76 }
80ea4443 77
76c6ee8a
DC
78 $conf->{quiet} = 1; # do not write to stdout/stderr
79
80 PVE::Cluster::cfs_update(); # refresh vmlist
81
82 return PVE::API2::VZDump->vzdump($conf);
83}
84
851;