[pve-devel] r5722 - pve-manager/pve2/lib/PVE/API2
svn-commits at proxmox.com
svn-commits at proxmox.com
Thu Mar 17 13:29:45 CET 2011
Author: dietmar
Date: 2011-03-17 13:29:45 +0100 (Thu, 17 Mar 2011)
New Revision: 5722
Modified:
pve-manager/pve2/lib/PVE/API2/Cluster.pm
Log:
implement tasklist API
Modified: pve-manager/pve2/lib/PVE/API2/Cluster.pm
===================================================================
--- pve-manager/pve2/lib/PVE/API2/Cluster.pm 2011-03-17 12:29:06 UTC (rev 5721)
+++ pve-manager/pve2/lib/PVE/API2/Cluster.pm 2011-03-17 12:29:45 UTC (rev 5722)
@@ -42,6 +42,7 @@
{ name => 'log' },
{ name => 'vms' },
{ name => 'storage' },
+ { name => 'tasks' },
];
return $result;
@@ -215,4 +216,44 @@
return $res;
}});
+__PACKAGE__->register_method({
+ name => 'tasks',
+ path => 'tasks',
+ method => 'GET',
+ description => "List recent tasks (cluster wide).",
+ permissions => { user => 'all' },
+ parameters => {
+ additionalProperties => 0,
+ properties => {},
+ },
+ returns => {
+ type => 'array',
+ items => {
+ type => "object",
+ properties => {
+ upid => { type => 'string' },
+ },
+ },
+ },
+ code => sub {
+ my ($param) = @_;
+
+ my $rpcenv = PVE::RPCEnvironment::get();
+ my $user = $rpcenv->get_user();
+
+ my $tlist = PVE::RPCEnvironment::active_workers();
+
+ my $res = [];
+
+ return $res if !$tlist;
+
+ my $all = $rpcenv->check($user, "/", [ 'Sys.Audit' ]);
+
+ foreach my $task (@$tlist) {
+ push @$res, $task if $all || ($task->{user} eq $user);
+ }
+
+ return $res;
+ }});
+
1;
More information about the pve-devel
mailing list