mirror of https://github.com/BOINC/boinc.git
create_work: allow targeting commands in stdin job descriptions
This commit is contained in:
parent
16e45a1ddc
commit
aa04502db4
|
@ -89,6 +89,15 @@ bool arg(char** argv, int i, const char* name) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void check_assign_id(int x) {
|
||||||
|
if (x == 0) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"you must specify a nonzero database ID for assigning jobs to users, teams, or hosts.\n"
|
||||||
|
);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct JOB_DESC {
|
struct JOB_DESC {
|
||||||
DB_WORKUNIT wu;
|
DB_WORKUNIT wu;
|
||||||
char wu_template[BLOB_SIZE];
|
char wu_template[BLOB_SIZE];
|
||||||
|
@ -146,6 +155,16 @@ void JOB_DESC::parse_cmdline(int argc, char** argv) {
|
||||||
id.nbytes = atof(argv[++i]);
|
id.nbytes = atof(argv[++i]);
|
||||||
strcpy(id.md5, argv[++i]);
|
strcpy(id.md5, argv[++i]);
|
||||||
infiles.push_back(id);
|
infiles.push_back(id);
|
||||||
|
} else if (arg(argv, i, "target_host")) {
|
||||||
|
assign_flag = true;
|
||||||
|
assign_type = ASSIGN_HOST;
|
||||||
|
assign_id = atoi(argv[++i]);
|
||||||
|
check_assign_id(assign_id);
|
||||||
|
} else if (arg(argv, i, "target_user")) {
|
||||||
|
assign_flag = true;
|
||||||
|
assign_type = ASSIGN_USER;
|
||||||
|
assign_id = atoi(argv[++i]);
|
||||||
|
check_assign_id(assign_id);
|
||||||
} else {
|
} else {
|
||||||
if (!strncmp("-", argv[i], 1)) {
|
if (!strncmp("-", argv[i], 1)) {
|
||||||
fprintf(stderr, "create_work: bad stdin argument '%s'\n", argv[i]);
|
fprintf(stderr, "create_work: bad stdin argument '%s'\n", argv[i]);
|
||||||
|
@ -159,15 +178,6 @@ void JOB_DESC::parse_cmdline(int argc, char** argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void check_assign_id(int x) {
|
|
||||||
if (x == 0) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"you must specify a nonzero database ID for assigning jobs to users, teams, or hosts.\n"
|
|
||||||
);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
DB_APP app;
|
DB_APP app;
|
||||||
int retval;
|
int retval;
|
||||||
|
@ -382,6 +392,16 @@ int main(int argc, char** argv) {
|
||||||
if (!strlen(jd2.wu.name)) {
|
if (!strlen(jd2.wu.name)) {
|
||||||
sprintf(jd2.wu.name, "%s_%d", jd.wu.name, j);
|
sprintf(jd2.wu.name, "%s_%d", jd.wu.name, j);
|
||||||
}
|
}
|
||||||
|
// if the stdin line specified assignment,
|
||||||
|
// create the job individually
|
||||||
|
//
|
||||||
|
if (jd2.assign_flag) {
|
||||||
|
jd2.create();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// otherwise accumulate a SQL query so that we can
|
||||||
|
// create jobs en masse
|
||||||
|
//
|
||||||
retval = create_work2(
|
retval = create_work2(
|
||||||
jd2.wu,
|
jd2.wu,
|
||||||
jd2.wu_template,
|
jd2.wu_template,
|
||||||
|
|
Loading…
Reference in New Issue