ICT job submission

svn path=/trunk/boinc/; revision=26073
This commit is contained in:
Wenjing Wu 2012-09-05 14:36:39 +00:00
parent b412b9d172
commit 487916c8e9
2 changed files with 55 additions and 33 deletions

View File

@ -5,16 +5,19 @@
// from the Institute for Computing Technology in Beijing
//
define("PROJECT", "http://casbak.ihep.ac.cn/castest/");
define("PROJECT", "http://casbak.ihep.ac.cn/casw/");
function usage() {
global $argv;
die("
Usage:
tt_boinc submit sequence_file authenticator
submit batch, print batch ID
tt_boinc get_output batch_id auth
show URL of output file
");
$argv[0] submit sequence_file (submit batch, print batch ID)
$argv[0] get_output batch_id (show URL of output file)
\n");
}
function get_auth() {
return trim(file_get_contents("auth"));
}
function do_http_op($xml, $file=null) {
@ -38,9 +41,10 @@ function do_http_op($xml, $file=null) {
function handle_submit() {
global $argc, $argv;
if ($argc != 4) usage();
if ($argc != 3) usage();
if (!is_file($argv[2])) die("seq file missing");
$auth = $argv[3];
//$auth = $argv[3];
$auth = get_auth();
$req_xml = "
<tt_request>
<action>submit</action>
@ -49,15 +53,16 @@ function handle_submit() {
";
list($reply, $errmsg) = do_http_op($req_xml, $argv[2]);
if ($errmsg) die("Error: $errmsg\n");
if ($reply->message) die("Error: $reply->message);
print_r($reply);
echo "batch ID: ".(int)$reply->batch_id."\n";
}
function handle_get_output() {
global $argc, $argv;
if ($argc != 4) usage();
if ($argc != 3) usage();
$batch_id = $argv[2];
$auth = $argv[3];
//$auth = $argv[3];
$auth = get_auth();
$req_xml = "
<tt_request>
<action>get_output</action>

View File

@ -4,22 +4,21 @@
// FIRST WHACK AT A REMOTE JOB SUBMISSION TOOL; NOT FINISHED
require_once("../html/inc/submit.inc");
require_once("submit.inc");
//define("PROJECT", "http://casbak.ihep.ac.cn/castest/");
define("PROJECT", "http://isaac.ssl.berkeley.edu/test/");
define("PROJECT", "http://casbak.ihep.ac.cn/casw");
define("APP_NAME", "uppercase");
function usage() {
global $argv;
die("
Usage:
submit sequence_file
submit 1 job, print batch ID
get_output batch_id
show URL of output file
abort batch_id
retire batch_id
");
$argv[0] submit sequence_file (submit 1 job, print batch ID)
$argv[0] query batch_id|all (get the status of a specific batch or all batches)
$argv[0] get_output batch_id (show URL of output file)
$argv[0] abort batch_id (abort a batch)
$argv[0] retire batch_id (retire a batch)
\n");
}
function get_auth() {
@ -49,6 +48,7 @@ function handle_submit() {
}
function handle_query() {
global $argc,$argv;
$req->project = PROJECT;
$req->authenticator = get_auth();
list($batches, $errmsg) = boinc_query_batches($req);
@ -56,16 +56,33 @@ function handle_query() {
echo "Error: $errmsg\n";
return;
}
if($argv[2]!='all')$batch_id=$argv[2];
else $batch_id=-1;
if($batch_id==-1){
foreach ($batches as $batch) {
echo "batch $batch->id: ";
switch ($batch->state) {
case 1: echo "In progress"; break;
case 2: echo "Completed"; break;
case 3: echo "Aborted"; break;
case 4: echo "Retired"; break;
}
case 1: echo "In progress\n"; break;
case 2: echo "Completed\n"; break;
case 3: echo "Aborted\n"; break;
case 4: echo "Retired\n"; break;
}
}
}else{
foreach ($batches as $batch) {
if ($batch->id==$batch_id){
echo "batch $batch_id: ";
switch ($batch->state) {
case 1: echo "In progress\n"; break;
case 2: echo "Completed\n"; break;
case 3: echo "Aborted\n"; break;
case 4: echo "Retired\n"; break;
}//switch
} //if
}//foreach
}//else
}//query_batch()
function handle_get_output() {
global $argc, $argv;
@ -105,7 +122,7 @@ function handle_retire() {
}
}
if ($argc < 2) usage();
if ($argc < 3) usage();
switch ($argv[1]) {
case "submit": handle_submit(); break;
case "query": handle_query(); break;