[pve-devel] r6031 - pve-manager/pve2/lib/PVE/API2

svn-commits at proxmox.com svn-commits at proxmox.com
Fri May 27 11:11:50 CEST 2011


Author: dietmar
Date: 2011-05-27 11:11:50 +0200 (Fri, 27 May 2011)
New Revision: 6031

Modified:
   pve-manager/pve2/lib/PVE/API2/Tasks.pm
Log:
return correct status


Modified: pve-manager/pve2/lib/PVE/API2/Tasks.pm
===================================================================
--- pve-manager/pve2/lib/PVE/API2/Tasks.pm	2011-05-27 09:06:41 UTC (rev 6030)
+++ pve-manager/pve2/lib/PVE/API2/Tasks.pm	2011-05-27 09:11:50 UTC (rev 6031)
@@ -8,6 +8,7 @@
 use PVE::Tools;
 use PVE::SafeSyslog;
 use PVE::RESTHandler;
+use PVE::ProcFSTools;
 use PVE::RPCEnvironment;
 use PVE::JSONSchema qw(get_standard_option);
 use PVE::AccessControl;
@@ -181,7 +182,6 @@
 	my $limit = $param->{limit} || 50;
 	my $count = 0;
 	my $line;
-
 	while (defined ($line = <$fh>)) {
 	    next if $count++ < $start;
 	    next if $limit <= 0;
@@ -214,7 +214,14 @@
     },
     returns => {
 	type => "object",
-	properties => {},
+	properties => {
+	    pid => { 
+		type => 'integer'
+	    },
+	    status => { 
+		type => 'string', enum => ['running', 'stopped'], 
+	    },
+	},
     },
     code => sub {
 	my ($param) = @_;
@@ -232,6 +239,10 @@
 	die "Permission check failed\n"
 	    if !($auditor || $user eq $task->{user});
 
+	my $pstart = PVE::ProcFSTools::read_proc_starttime($task->{pid});
+	$task->{status} = ($pstart && ($pstart == $task->{pstart})) ?
+	    'running' : 'stopped';
+
 	$task->{upid} = $param->{upid}; # include upid
 
 	return $task;




More information about the pve-devel mailing list