[pve-devel] [PATCH manager 1/2] PVE/API2/Tasks: add since/until filter for the task list

Dominik Csapak d.csapak at proxmox.com
Thu Jun 24 09:10:12 CEST 2021


similar to pbs

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 PVE/API2/Tasks.pm | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/PVE/API2/Tasks.pm b/PVE/API2/Tasks.pm
index 8f6ab603..8df701e5 100644
--- a/PVE/API2/Tasks.pm
+++ b/PVE/API2/Tasks.pm
@@ -90,6 +90,16 @@ __PACKAGE__->register_method({
 		optional => 1,
 		description => 'List archived, active or all tasks.',
 	    },
+	    since => {
+		type => 'integer',
+		description => "Only list tasks since this UNIX epoch.",
+		optional => 1,
+	    },
+	    until => {
+		type => 'integer',
+		description => "Only list tasks until this UNIX epoch.",
+		optional => 1,
+	    },
 	},
     },
     returns => {
@@ -128,6 +138,8 @@ __PACKAGE__->register_method({
 	my $typefilter = $param->{typefilter};
 	my $errors = $param->{errors} // 0;
 	my $source = $param->{source} // 'archive';
+	my $since = $param->{since};
+	my $until = $param->{until};
 
 	my $count = 0;
 	my $line;
@@ -145,6 +157,9 @@ __PACKAGE__->register_method({
 	    return 1 if $errors && $task->{status} && $task->{status} eq 'OK';
 	    return 1 if $param->{vmid} && (!$task->{id} || $task->{id} ne $param->{vmid});
 
+	    return 1 if defined($since) && $task->{starttime} < $since;
+	    return 1 if defined($until) && $task->{starttime} > $until;
+
 	    return 1 if $count++ < $start;
 	    return 1 if $limit <= 0;
 
-- 
2.20.1






More information about the pve-devel mailing list