2010-05-24 23:14:48 +00:00
|
|
|
#include "sched_limit.h"
|
|
|
|
|
|
|
|
int RSC_JOB_LIMIT::parse(XML_PARSER& xp, const char* end_tag) {
|
2010-06-25 18:54:37 +00:00
|
|
|
char tag[1024];
|
2010-05-24 23:14:48 +00:00
|
|
|
bool is_tag;
|
|
|
|
|
|
|
|
while (!xp.get(tag, sizeof(tag), is_tag)) {
|
|
|
|
if (!is_tag) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!strcmp(tag, end_tag)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (xp.parse_int(tag, "jobs", base_limit)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (xp.parse_bool(tag, "per_proc", per_proc)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ERR_XML_PARSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int JOB_LIMIT::parse(XML_PARSER& xp, const char* end_tag) {
|
2010-06-25 18:54:37 +00:00
|
|
|
char tag[1024];
|
2010-05-24 23:14:48 +00:00
|
|
|
bool is_tag;
|
|
|
|
|
|
|
|
while (!xp.get(tag, sizeof(tag), is_tag)) {
|
|
|
|
if (!is_tag) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!strcmp(tag, end_tag)) {
|
|
|
|
return 0;
|
|
|
|
}
|
2010-06-03 04:59:27 +00:00
|
|
|
if (xp.parse_str(tag, "app_name", app_name, sizeof(app_name))) {
|
2010-05-24 23:14:48 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!strcmp(tag, "total_limit")) {
|
2010-06-04 16:57:33 +00:00
|
|
|
total.parse(xp, "/total_limit");
|
2010-05-24 23:14:48 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!strcmp(tag, "cpu_limit")) {
|
2010-06-04 16:57:33 +00:00
|
|
|
cpu.parse(xp, "/cpu_limit");
|
2010-05-24 23:14:48 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!strcmp(tag, "gpu_limit")) {
|
2010-06-04 16:57:33 +00:00
|
|
|
gpu.parse(xp, "/gpu_limit");
|
2010-05-24 23:14:48 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ERR_XML_PARSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int JOB_LIMITS::parse(XML_PARSER& xp, const char* end_tag) {
|
2010-06-25 18:54:37 +00:00
|
|
|
char tag[1024];
|
2010-05-24 23:14:48 +00:00
|
|
|
bool is_tag;
|
|
|
|
|
|
|
|
while (!xp.get(tag, sizeof(tag), is_tag)) {
|
|
|
|
if (!is_tag) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!strcmp(tag, end_tag)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (!strcmp(tag, "project")) {
|
|
|
|
project_limits.parse(xp, "/project");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!strcmp(tag, "app")) {
|
|
|
|
JOB_LIMIT jl;
|
|
|
|
jl.parse(xp, "/app");
|
|
|
|
if (!strlen(jl.app_name)) {
|
|
|
|
log_messages.printf(MSG_NORMAL, "missing app name\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
app_limits.push_back(jl);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2010-06-04 16:57:33 +00:00
|
|
|
return ERR_XML_PARSE;
|
2010-05-24 23:14:48 +00:00
|
|
|
}
|