]> git.proxmox.com Git - pve-manager.git/blobdiff - PVE/API2/Replication.pm
PVE/API2/Replication.pm: add schedule_now API
[pve-manager.git] / PVE / API2 / Replication.pm
index 2a4bf537af58e5b4be8822281ad07f8ee38cbf4e..dca93d8cdbf8d45d021bc944b186c6fe99eadd40 100644 (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;