mirror of https://github.com/BOINC/boinc.git
- remote job submission: add a web RPC for getting an app's templates
(can use this to consistency-check job submission info)
This commit is contained in:
parent
2b95c65555
commit
29444b3edb
|
@ -420,6 +420,17 @@ function handle_retire_batch($r) {
|
|||
echo "<success>1</success>";
|
||||
}
|
||||
|
||||
function get_templates($r) {
|
||||
$app = get_app($r);
|
||||
list($user, $user_submit) = authenticate_user($r, $app);
|
||||
$in = file_get_string("../../templates/".$app->name."_in");
|
||||
$out = file_get_string("../../templates/".$app->name."_out");
|
||||
if ($in === false || $out === false) {
|
||||
xml_error(-1, "template file missing");
|
||||
}
|
||||
echo "<templates>\n$in\n$out\n</templates>\n";
|
||||
}
|
||||
|
||||
if (0) {
|
||||
$r = simplexml_load_string("
|
||||
<query_batch>
|
||||
|
@ -481,6 +492,7 @@ switch ($r->getName()) {
|
|||
case 'retire_batch': handle_retire_batch($r); break;
|
||||
case 'submit_batch': submit_batch($r); break;
|
||||
case 'create_batch': create_batch($r); break;
|
||||
case 'get_templates': get_templates($r); break;
|
||||
default: xml_error(-1, "bad command: ".$r->getName());
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,12 @@
|
|||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// C++ interfaces to web RPCs related to remote job submission,
|
||||
// namely those described here:
|
||||
// http://boinc.berkeley.edu/trac/wiki/RemoteInputFiles
|
||||
// http://boinc.berkeley.edu/trac/wiki/RemoteOutputFiles
|
||||
// http://boinc.berkeley.edu/trac/wiki/RemoteJobs
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <stdio.h>
|
||||
#include <vector>
|
||||
|
@ -383,6 +389,67 @@ int abort_jobs(
|
|||
return retval;
|
||||
}
|
||||
|
||||
int get_templates(
|
||||
const char* project_url,
|
||||
const char* authenticator,
|
||||
const char* app_name,
|
||||
TEMPLATE_DESC &td
|
||||
) {
|
||||
string request;
|
||||
char url[1024], buf[256];
|
||||
request = "<get_templates>\n";
|
||||
sprintf(buf, "<authenticator>%s</authenticator>\n", authenticator);
|
||||
request += string(buf);
|
||||
sprintf(buf, "<app_name>%s</app_name>\n", app_name);
|
||||
request += string(buf);
|
||||
request = "</get_templates>\n";
|
||||
sprintf(url, "%ssubmit_rpc_handler.php", project_url);
|
||||
FILE* reply = tmpfile();
|
||||
vector<string> x;
|
||||
int retval = do_http_post(url, request.c_str(), reply, x);
|
||||
if (retval) {
|
||||
fclose(reply);
|
||||
return retval;
|
||||
}
|
||||
fseek(reply, 0, SEEK_SET);
|
||||
MIOFILE mf;
|
||||
XML_PARSER xp(&mf);
|
||||
mf.init_file(reply);
|
||||
return td.parse(xp);
|
||||
}
|
||||
|
||||
int TEMPLATE_DESC::parse(XML_PARSER& xp) {
|
||||
int retval;
|
||||
string s;
|
||||
while (!xp.get_tag()) {
|
||||
if (xp.match_tag("error")) {
|
||||
while (!xp.get_tag()) {
|
||||
if (xp.parse_int("error_num", retval)) {
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
if (xp.match_tag("input_template")) {
|
||||
while (!xp.get_tag()) {
|
||||
if (xp.match_tag("/input_template")) break;
|
||||
if (xp.parse_string("open_name", s)) {
|
||||
input_files.push_back(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (xp.match_tag("output_template")) {
|
||||
while (!xp.get_tag()) {
|
||||
if (xp.match_tag("/output_template")) break;
|
||||
if (xp.parse_string("open_name", s)) {
|
||||
output_files.push_back(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_output_file(
|
||||
const char* project_url,
|
||||
const char* authenticator,
|
||||
|
|
|
@ -69,6 +69,13 @@ struct FETCH_OUTPUT_REQ {
|
|||
vector<string> file_names;
|
||||
};
|
||||
|
||||
struct TEMPLATE_DESC {
|
||||
vector<string> input_files;
|
||||
vector<string> output_files;
|
||||
|
||||
int parse(XML_PARSER&);
|
||||
};
|
||||
|
||||
//////////////////////////
|
||||
|
||||
|
||||
|
@ -124,3 +131,10 @@ extern int abort_jobs(
|
|||
string batch_name,
|
||||
vector<string> &job_names
|
||||
);
|
||||
|
||||
extern int get_templates(
|
||||
const char* project_url,
|
||||
const char* authenticator,
|
||||
const char* app_name,
|
||||
TEMPLATE_DESC&
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue