newstates.pl 994 Bytes
Newer Older
1
#!/usr/bin/perl -w
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use English;
use Errno;
#use POSIX;
#use Socket;
#use BSD::Resource;
#use URI::Escape;

use lib "/usr/testbed/lib";
use libdb;
use libtestbed;

my $query_result =
    DBQueryFatal("select pid,eid,state ".
		 "from experiments where batchmode=0");

while (my ($pid,$eid,$state) =
       $query_result->fetchrow_array) {
    my $batchstate;

    if ($state eq EXPTSTATE_ACTIVATING) {
	$batchstate = BATCHSTATE_ACTIVATING;
    }
    elsif ($state eq EXPTSTATE_ACTIVE) {
	$batchstate = BATCHSTATE_RUNNING;
    }
    elsif ($state eq EXPTSTATE_SWAPPED) {
	$batchstate = BATCHSTATE_PAUSED;
    }
    elsif ($state eq EXPTSTATE_SWAPPING ||
	   $state eq EXPTSTATE_TERMINATING ||
	   $state eq EXPTSTATE_TERMINATED) {
	$batchstate = BATCHSTATE_TERMINATING;
    }
    elsif ($state eq EXPTSTATE_NEW ||
	   $state eq EXPTSTATE_PRERUN) {
	$batchstate = BATCHSTATE_PAUSED;
    }

    print "update experiments set batchstate='$batchstate' ".
	"where pid='$pid' and eid='$eid';\n";
}