mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-07 21:38:56 +00:00
api: backup/jobs: add comment field to jobs
and encode them with PVE::Tools::encode_text in the config Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
e177268741
commit
998b61fbff
@ -168,6 +168,12 @@ __PACKAGE__->register_method({
|
|||||||
description => "Enable or disable the job.",
|
description => "Enable or disable the job.",
|
||||||
default => '1',
|
default => '1',
|
||||||
},
|
},
|
||||||
|
comment => {
|
||||||
|
optional => 1,
|
||||||
|
type => 'string',
|
||||||
|
description => "Description for the Job.",
|
||||||
|
maxLength => 512,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
returns => { type => 'null' },
|
returns => { type => 'null' },
|
||||||
@ -363,6 +369,12 @@ __PACKAGE__->register_method({
|
|||||||
description => "Enable or disable the job.",
|
description => "Enable or disable the job.",
|
||||||
default => '1',
|
default => '1',
|
||||||
},
|
},
|
||||||
|
comment => {
|
||||||
|
optional => 1,
|
||||||
|
type => 'string',
|
||||||
|
description => "Description for the Job.",
|
||||||
|
maxLength => 512,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
returns => { type => 'null' },
|
returns => { type => 'null' },
|
||||||
@ -417,7 +429,7 @@ __PACKAGE__->register_method({
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach my $k (@$delete) {
|
foreach my $k (@$delete) {
|
||||||
if (!PVE::VZDump::option_exists($k)) {
|
if (!PVE::VZDump::option_exists($k) && $k ne 'comment') {
|
||||||
raise_param_exc({ delete => "unknown option '$k'" });
|
raise_param_exc({ delete => "unknown option '$k'" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,12 @@ my $defaultData = {
|
|||||||
type => 'string', format => 'pve-calendar-event',
|
type => 'string', format => 'pve-calendar-event',
|
||||||
maxLength => 128,
|
maxLength => 128,
|
||||||
},
|
},
|
||||||
|
comment => {
|
||||||
|
optional => 1,
|
||||||
|
type => 'string',
|
||||||
|
description => "Description for the Job.",
|
||||||
|
maxLength => 512,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -47,6 +53,10 @@ sub parse_config {
|
|||||||
|
|
||||||
$data->{id} = $id;
|
$data->{id} = $id;
|
||||||
$data->{enabled} //= 1;
|
$data->{enabled} //= 1;
|
||||||
|
|
||||||
|
if (defined($data->{comment})) {
|
||||||
|
$data->{comment} = PVE::Tools::decode_text($data->{comment});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $cfg;
|
return $cfg;
|
||||||
@ -67,6 +77,18 @@ sub encode_value {
|
|||||||
return $plugin->encode_value($type, $key, $value);
|
return $plugin->encode_value($type, $key, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub write_config {
|
||||||
|
my ($class, $filename, $cfg) = @_;
|
||||||
|
|
||||||
|
for my $job (values $cfg->{ids}->%*) {
|
||||||
|
if (defined($job->{comment})) {
|
||||||
|
$job->{comment} = PVE::Tools::encode_text($job->{comment});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$class->SUPER::write_config($filename, $cfg);
|
||||||
|
}
|
||||||
|
|
||||||
sub run {
|
sub run {
|
||||||
my ($class, $cfg) = @_;
|
my ($class, $cfg) = @_;
|
||||||
# implement in subclass
|
# implement in subclass
|
||||||
|
@ -25,6 +25,7 @@ sub options {
|
|||||||
my $options = {
|
my $options = {
|
||||||
enabled => { optional => 1 },
|
enabled => { optional => 1 },
|
||||||
schedule => {},
|
schedule => {},
|
||||||
|
comment => { optional => 1 },
|
||||||
};
|
};
|
||||||
foreach my $opt (keys %$props) {
|
foreach my $opt (keys %$props) {
|
||||||
if ($props->{$opt}->{optional}) {
|
if ($props->{$opt}->{optional}) {
|
||||||
|
Loading…
Reference in New Issue
Block a user