]> git.proxmox.com Git - pve-manager.git/commitdiff
task index: allow filtering by task type
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Wed, 23 Jan 2019 13:56:32 +0000 (14:56 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 23 Jan 2019 17:42:59 +0000 (18:42 +0100)
convenience filter if caller is only interested in certain actions

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Reviewed-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Tested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/API2/Tasks.pm

index 0f2a622b0c396f15e435aa8e6ce9427caba956d8..8cdc534d0230ab568df9c6b02bc17c9ec0521d46 100644 (file)
@@ -49,6 +49,11 @@ __PACKAGE__->register_method({
                optional => 1,
                description => "Only list tasks from this user.",
            },
+           typefilter => {
+               type => 'string',
+               optional => 1,
+               description => 'Only list tasks of this type (e.g., vzstart, vzdump).',
+           },
            vmid => get_standard_option('pve-vmid', {
                description => "Only list tasks for this VM.",
                optional => 1,
@@ -100,6 +105,7 @@ __PACKAGE__->register_method({
        my $start = $param->{start} // 0;
        my $limit = $param->{limit} // 50;
        my $userfilter = $param->{userfilter};
+       my $typefilter = $param->{typefilter};
        my $errors = $param->{errors} // 0;
        my $source = $param->{source} // 'archive';
 
@@ -114,6 +120,8 @@ __PACKAGE__->register_method({
            return 1 if $userfilter && $task->{user} !~ m/\Q$userfilter\E/i;
            return 1 if !($auditor || $user eq $task->{user});
 
+           return 1 if $typefilter && $task->{type} ne $typefilter;
+
            return 1 if $errors && $task->{status} && $task->{status} eq 'OK';
            return 1 if $param->{vmid} && (!$task->{id} || $task->{id} ne $param->{vmid});