]>
git.proxmox.com Git - pve-manager.git/blob - PVE/API2/Replication.pm
1 package PVE
::API2
::Replication
;
6 use PVE
::JSONSchema
qw(get_standard_option);
7 use PVE
::RPCEnvironment
;
9 use PVE
::ReplicationConfig
;
14 use base
qw(PVE::RESTHandler);
16 __PACKAGE__-
>register_method ({
20 permissions
=> { user
=> 'all' },
21 description
=> "Directory index.",
23 additionalProperties
=> 0,
25 node
=> get_standard_option
('pve-node'),
34 links
=> [ { rel
=> 'child', href
=> "{name}" } ],
45 __PACKAGE__-
>register_method ({
49 description
=> "List replication job status.",
51 description
=> "Requires the VM.Audit permission on /vms/<vmid>.",
57 additionalProperties
=> 0,
59 node
=> get_standard_option
('pve-node'),
60 guest
=> get_standard_option
('pve-vmid', {
62 description
=> "Only list replication jobs for this guest.",
72 links
=> [ { rel
=> 'child', href
=> "{id}" } ],
77 my $rpcenv = PVE
::RPCEnvironment
::get
();
78 my $authuser = $rpcenv->get_user();
80 my $jobs = PVE
::Replication
::job_status
();
83 foreach my $id (sort keys %$jobs) {
85 my $state = delete $d->{state};
86 my $guest = $d->{guest
};
87 next if defined($param->{guest
}) && $guest != $param->{guest
};
88 next if !$rpcenv->check($authuser, "/vms/$guest", [ 'VM.Audit' ]);
90 foreach my $k (qw(last_sync last_try fail_count error duration)) {
91 $d->{$k} = $state->{$k} if defined($state->{$k});
93 if ($state->{pid
} && $state->{ptime
}) {
94 if (PVE
::ProcFSTools
::check_process_running
($state->{pid
}, $state->{ptime
})) {
95 $d->{pid
} = $state->{pid
};