PVE/API2/Replication.pm: add schedule_now API

This commit is contained in:
Dietmar Maurer 2017-06-28 06:55:16 +02:00
parent 1ec226c31d
commit 88ea8e67d3

View File

@ -192,6 +192,7 @@ __PACKAGE__->register_method ({
my ($param) = @_;
return [
{ name => 'schedule_now' },
{ name => 'log' },
{ name => 'status' },
];
@ -311,4 +312,38 @@ __PACKAGE__->register_method({
return $lines;
}});
__PACKAGE__->register_method ({
name => 'schedule_now',
path => '{id}/schedule_now',
method => 'POST',
description => "Schedule replication job to start as soon as possible.",
proxyto => 'node',
protected => 1,
permissions => {
check => ['perm', '/storage', ['Datastore.Allocate']],
},
parameters => {
additionalProperties => 0,
properties => {
id => get_standard_option('pve-replication-id'),
node => get_standard_option('pve-node'),
},
},
returns => {
type => 'string',
},
code => sub {
my ($param) = @_;
my $jobid = $param->{id};
my $cfg = PVE::ReplicationConfig->new();
my $jobcfg = $cfg->{ids}->{$jobid};
die "no such replication job '$jobid'\n" if !defined($jobcfg);
PVE::ReplicationState::schedule_job_now($jobcfg);
}});
1;