Also generalizes the way vzdump property strings are handled for jobs.
Something similar could be done in VZDump.pm, but there the maxfiles
and prune-backups settings are currently coupled, so a dedicated
parse_performance() is used instead. Can be changed once maxfiles is
dropped.
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
method => 'POST',
description => "Create backup.",
permissions => {
- description => "The user needs 'VM.Backup' permissions on any VM, and 'Datastore.AllocateSpace'"
- ." on the backup storage. The 'maxfiles', 'prune-backups', 'tmpdir', 'dumpdir', 'script',"
- ." 'bwlimit' and 'ionice' parameters are restricted to the 'root\@pam' user.",
+ description => "The user needs 'VM.Backup' permissions on any VM, and "
+ ."'Datastore.AllocateSpace' on the backup storage. The 'maxfiles', 'prune-backups', "
+ ."'tmpdir', 'dumpdir', 'script', 'bwlimit', 'performance' and 'ionice' parameters are "
+ ."restricted to the 'root\@pam' user.",
user => 'all',
},
protected => 1,
if $param->{stdout};
}
- foreach my $key (qw(maxfiles prune-backups tmpdir dumpdir script bwlimit ionice)) {
+ for my $key (qw(maxfiles prune-backups tmpdir dumpdir script bwlimit performance ionice)) {
raise_param_exc({ $key => "Only root may set this option."})
if defined($param->{$key}) && ($user ne 'root@pam');
}
sub decode_value {
my ($class, $type, $key, $value) = @_;
- if ($key eq 'prune-backups' && !ref($value)) {
- $value = PVE::JSONSchema::parse_property_string(
- 'prune-backups',
- $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 ($key eq 'prune-backups' && ref($value) eq 'HASH') {
- $value = PVE::JSONSchema::print_property_string(
- $value,
- 'prune-backups',
- );
+ if ((my $format = $PVE::VZDump::Common::PROPERTY_STRINGS->{$key}) && ref($value) eq 'HASH') {
+ $value = PVE::JSONSchema::print_property_string($value, $format);
}
return $value;
delete $conf->{$opt} if !defined($props->{$opt});
}
- my $retention = $conf->{'prune-backups'};
- if ($retention && ref($retention) eq 'HASH') { # fixup, its required as string parameter
- $conf->{'prune-backups'} = PVE::JSONSchema::print_property_string($retention, 'prune-backups');
+ # Required as string parameters
+ for my $key (keys $PVE::VZDump::Common::PROPERTY_STRINGS->%*) {
+ if ($conf->{$key} && ref($conf->{$key}) eq 'HASH') {
+ my $format = $PVE::VZDump::Common::PROPERTY_STRINGS->{$key};
+ $conf->{$key} = PVE::JSONSchema::print_property_string($conf->{$key}, $format);
+ }
}
$conf->{quiet} = 1; # do not write to stdout/stderr
return $notes_template;
};
+my sub parse_performance {
+ my ($param) = @_;
+
+ if (defined(my $perf = $param->{performance})) {
+ return if ref($perf) eq 'HASH'; # already parsed
+ $param->{performance} = PVE::JSONSchema::parse_property_string('backup-performance', $perf);
+ }
+}
+
my $parse_prune_backups_maxfiles = sub {
my ($param, $kind) = @_;
} keys %$confdesc_for_defaults
};
$parse_prune_backups_maxfiles->($defaults, "defaults in VZDump schema");
+ parse_performance($defaults);
my $raw;
eval { $raw = PVE::Tools::file_get_contents($fn); };
$res->{mailto} = [ @mailto ];
}
$parse_prune_backups_maxfiles->($res, "options in '$fn'");
+ parse_performance($res);
foreach my $key (keys %$defaults) {
$res->{$key} = $defaults->{$key} if !defined($res->{$key});
if defined($param->{'prune-backups'}) && defined($param->{maxfiles});
$parse_prune_backups_maxfiles->($param, 'CLI parameters');
+ parse_performance($param);
if (my $template = $param->{'notes-template'}) {
eval { $verify_notes_template->($template); };
#storage: STORAGE_ID
#mode: snapshot|suspend|stop
#bwlimit: KBPS
+#performance: max-workers=N
#ionice: PRI
#lockwait: MINUTES
#stopwait: MINUTES
delete job['repeat-missed'];
job.all = job.all === true ? 1 : 0;
- if (job['prune-backups']) {
- job['prune-backups'] = PVE.Parser.printPropertyString(job['prune-backups']);
- }
+ ['performance', 'prune-backups'].forEach(key => {
+ if (job[key]) {
+ job[key] = PVE.Parser.printPropertyString(job[key]);
+ }
+ });
let allNodes = PVE.data.ResourceStore.getNodes();
let nodes = allNodes.filter(node => node.status === 'online').map(node => node.node);