Skip to content

Commit

Permalink
scheduler: store plan class reg exprs so we can including them in mes…
Browse files Browse the repository at this point in the history
…sages
  • Loading branch information
davidpanderson committed Jun 2, 2021
1 parent f5232b1 commit 6c06524
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
21 changes: 13 additions & 8 deletions sched/plan_class_spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ using std::string;
int REGEX_CLAUSE::init(const char* p) {
present = true;
negate = false;
expr = p;
if (*p == '!') {
p++;
negate = true;
Expand Down Expand Up @@ -328,8 +329,9 @@ bool PLAN_CLASS_SPEC::check(
if (host_summary_regex.mismatch(g_reply->host.serialnum)) {
if (config.debug_version_select) {
log_messages.printf(MSG_NORMAL,
"[version] plan_class_spec: host summary '%s' didn't match regexp\n",
g_reply->host.serialnum
"[version] plan_class_spec: host summary '%s' didn't match regexp %s\n",
g_reply->host.serialnum,
host_summary_regex.expr.c_str()
);
}
return false;
Expand All @@ -340,8 +342,9 @@ bool PLAN_CLASS_SPEC::check(
if (os_regex.mismatch(sreq.host.os_version)) {
if (config.debug_version_select) {
log_messages.printf(MSG_NORMAL,
"[version] plan_class_spec: OS version '%s' didn't match regexp\n",
sreq.host.os_version
"[version] plan_class_spec: OS version '%s' didn't match regexp %s\n",
sreq.host.os_version,
os_regex.expr.c_str()
);
}
return false;
Expand Down Expand Up @@ -413,8 +416,9 @@ bool PLAN_CLASS_SPEC::check(
if (cpu_vendor_regex.mismatch(sreq.host.p_vendor)) {
if (config.debug_version_select) {
log_messages.printf(MSG_NORMAL,
"[version] plan_class_spec: CPU vendor '%s' didn't match regexp\n",
sreq.host.p_vendor
"[version] plan_class_spec: CPU vendor '%s' didn't match regexp %s\n",
sreq.host.p_vendor,
cpu_vendor_regex.expr.c_str()
);
}
return false;
Expand All @@ -423,8 +427,9 @@ bool PLAN_CLASS_SPEC::check(
if (cpu_model_regex.mismatch (sreq.host.p_model)) {
if (config.debug_version_select) {
log_messages.printf(MSG_NORMAL,
"[version] plan_class_spec: CPU model '%s' didn't match regexp\n",
sreq.host.p_model
"[version] plan_class_spec: CPU model '%s' didn't match regexp %s\n",
sreq.host.p_model,
cpu_model_regex.expr.c_str()
);
}
return false;
Expand Down
13 changes: 8 additions & 5 deletions sched/plan_class_spec.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,23 @@
#include <vector>
#include <regex.h>

// represents a plan class clause with a regular expression
// Represents a plan class clause with a regular expression
// (os, cpu_vendor, etc.).
// Has the compiled regex, and whether it's negated
//
struct REGEX_CLAUSE {
bool present; // clause is present
bool negate; // regex is negated (starts with !)
regex_t regex; // compiled regex
bool present; // clause is present
bool negate; // regex is negated (starts with !)
std::string expr; // the regex string
regex_t regex; // compiled regex

REGEX_CLAUSE() {
present = 0;
}
int init(const char* p);
// p is the regex, possibly preceded by !
bool mismatch(const char*);
// clause is present, and the string doesn't match it
// return true if clause is present and the string doesn't match it
};

// if you add anything here, initialize it in the constructor
Expand Down

0 comments on commit 6c06524

Please sign in to comment.