use base qw(PVE::RESTHandler);
__PACKAGE__->register_method({
- name => 'node_tasks',
- path => '',
+ name => 'node_tasks',
+ path => '',
method => 'GET',
- permissions => {
+ permissions => {
description => "List task associated with the current user, or all task the user has 'Sys.Audit' permissions on /nodes/<node> (the <node> the task runs on).",
- user => 'all'
+ user => 'all'
},
description => "Read task list for one node (finished tasks).",
proxyto => 'node',
return if $errors && $status && $status eq 'OK';
- return if $param->{vmid} && (!$task->{id} || $task->{id} ne $param->{vmid});
+ return if $param->{vmid} && (!$task->{id} || $task->{id} ne $param->{vmid});
return if $count++ < $start;
return if $limit <= 0;
}
};
- if (my $bw = File::ReadBackwards->new($filename)) {
+ if (my $bw = File::ReadBackwards->new($filename)) {
while (defined ($line = $bw->readline)) {
&$parse_line();
}
$bw->close();
}
- if (my $bw = File::ReadBackwards->new("$filename.1")) {
+ if (my $bw = File::ReadBackwards->new("$filename.1")) {
while (defined ($line = $bw->readline)) {
&$parse_line();
}
}});
__PACKAGE__->register_method({
- name => 'upid_index',
- path => '{upid}',
+ name => 'upid_index',
+ path => '{upid}',
method => 'GET',
description => '', # index helper
permissions => { user => 'all' },
}});
__PACKAGE__->register_method({
- name => 'stop_task',
- path => '{upid}',
+ name => 'stop_task',
+ path => '{upid}',
method => 'DELETE',
description => 'Stop a task.',
- permissions => {
+ permissions => {
description => "The user needs 'Sys.Modify' permissions on '/nodes/<node>' if the task does not belong to him.",
- user => 'all',
+ user => 'all',
},
protected => 1,
proxyto => 'node',
}});
__PACKAGE__->register_method({
- name => 'read_task_log',
- path => '{upid}/log',
+ name => 'read_task_log',
+ path => '{upid}/log',
method => 'GET',
- permissions => {
+ permissions => {
description => "The user needs 'Sys.Audit' permissions on '/nodes/<node>' if the task does not belong to him.",
user => 'all',
},
},
returns => {
type => 'array',
- items => {
+ items => {
type => "object",
properties => {
n => {
my $exit_status_cache = {};
__PACKAGE__->register_method({
- name => 'read_task_status',
- path => '{upid}/status',
+ name => 'read_task_status',
+ path => '{upid}/status',
method => 'GET',
- permissions => {
+ permissions => {
description => "The user needs 'Sys.Audit' permissions on '/nodes/<node>' if the task does not belong to him.",
user => 'all',
},
returns => {
type => "object",
properties => {
- pid => {
+ pid => {
type => 'integer'
},
- status => {
- type => 'string', enum => ['running', 'stopped'],
+ status => {
+ type => 'string', enum => ['running', 'stopped'],
},
},
},
if ($task->{status} eq 'stopped') {
if (!defined($exit_status_cache->{$task->{upid}})) {
- $exit_status_cache->{$task->{upid}} =
+ $exit_status_cache->{$task->{upid}} =
PVE::Tools::upid_read_status($task->{upid});
}
$task->{exitstatus} = $exit_status_cache->{$task->{upid}};