Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit ad431672 authored by Alessio Netti's avatar Alessio Netti
Browse files

Changes to auto-publish

- Auto-publish is now case insensitive with respect to the <sensor> and
<group> patterns
- If an invalid pattern was specified (missing <sensor> clause) the
configuration is aborted
- Checks for the uniqueness of sensor and group names have been
temporarily dropped as they interfere with templates and entities
(until we find a good solution for MQTT topics)
parent a9fadfc3
......@@ -52,8 +52,8 @@ protected:
const string ALL_CLAUSE = "all";
const string ALL_REC_CLAUSE = "all-recursive";
const std::string SENSOR_PATTERN = "<sensor>";
const std::string GROUP_PATTERN = "<group>";
const std::string SENSOR_PATTERN = "(?i)<sensor>";
const std::string GROUP_PATTERN = "(?i)<group>";
public:
......@@ -396,7 +396,11 @@ protected:
}
for (auto &u: *units) {
constructSensorNames(*u, an);
if(!constructSensorNames(*u, an)) {
an.clearUnits();
delete units;
return false;
}
if (an.getStreaming()) {
if (!unit(*u)) {
LOG(error) << " Unit " << u->getName() << " did not pass the final check!";
......@@ -493,17 +497,19 @@ protected:
*
* Names are modified according to the sensorPattern specified in the global
* settings. Operates in tandem with the auto-publish feature.
*
* @return true if successful, false otherwise
*/
//TODO: switch to textual MQTT topics and use only MQTTPrefix
void constructSensorNames(UnitTemplate<SBase>& u, Analyzer& an) {
bool constructSensorNames(UnitTemplate<SBase>& u, Analyzer& an) {
boost::regex sensorReg(SENSOR_PATTERN), groupReg(GROUP_PATTERN);
boost::cmatch match;
//TODO: move sensorpattern checks somewhere else
if(_sensorPattern == "")
return;
return true;
else if (!boost::regex_search(_sensorPattern.c_str(), match, sensorReg)) {
LOG(error) << "Invalid sensor naming pattern " << _sensorPattern << ". You must at least include " << SENSOR_PATTERN << "!";
return;
LOG(error) << "Invalid sensor naming pattern " << _sensorPattern << ". You must at least include <sensor>!";
return false;
}
std::string name;
......@@ -520,7 +526,7 @@ protected:
}
s->setName(name);
}
return;
return true;
}
// Instance of a QueryEngine object
......
......@@ -101,10 +101,10 @@ public:
*/
bool checkName(const std::string& name) {
auto returnIt = _names.insert(name);
if (!returnIt.second) {
LOG(error) << "Name \"" << name << "\" used twice!";
return false;
}
//if (!returnIt.second) {
// LOG(error) << "Name \"" << name << "\" used twice!";
// return false;
//}
return true;
}
......@@ -130,10 +130,10 @@ public:
*/
bool checkGroup(const std::string& name) {
auto returnIt = _groups.insert(name);
if (!returnIt.second) {
LOG(error) << "Group name \"" << name << "\" used twice!";
return false;
}
//if (!returnIt.second) {
// LOG(error) << "Group name \"" << name << "\" used twice!";
// return false;
//}
return true;
}
......
......@@ -235,7 +235,7 @@ bool MQTTPusher::sendMappings() {
else
publishCtr++;
}
LOGM(info) << "Sensor name auto-publish performed for all sensors!";
LOGM(info) << "Sensor name auto-publish performed for all " << publishCtr << " sensors!";
return true;
}
......
......@@ -56,8 +56,8 @@ protected:
const char CLOSE_SQBRKET = ']';
const char DASH = '-';
const std::string SENSOR_PATTERN = "<sensor>";
const std::string GROUP_PATTERN = "<group>";
const std::string SENSOR_PATTERN = "(?i)<sensor>";
const std::string GROUP_PATTERN = "(?i)<group>";
public:
ConfiguratorTemplate() :
......@@ -254,7 +254,8 @@ public:
}
}
//read of config finished. Now we build the mqtt-topic for every sensor
constructSensorNames();
if(!constructSensorNames())
return false;
for(const auto& g : _sensorGroups) {
for(const auto& s : g->getSensors()) {
s->setMqtt(_mqttPrefix + g->getMqttPart() + s->getMqtt());
......@@ -838,15 +839,17 @@ protected:
/**
* Adjusts the names of the sensors in generated groups according to the sensorPattern specified in the global
* settings. Operates in tandem with the auto-publish feature.
*
* @return true if successful, false otherwise
*/
void constructSensorNames() {
bool constructSensorNames() {
boost::regex sensorReg(SENSOR_PATTERN), groupReg(GROUP_PATTERN);
boost::cmatch match;
if(_sensorPattern == "")
return;
return true;
else if (!boost::regex_search(_sensorPattern.c_str(), match, sensorReg)) {
LOG(error) << "Invalid sensor naming pattern " << _sensorPattern << ". You must at least include " << SENSOR_PATTERN << "!";
return;
LOG(error) << "Invalid sensor naming pattern " << _sensorPattern << ". You must at least include <sensor>!";
return false;
}
std::string name;
......@@ -859,7 +862,7 @@ protected:
// Setting the auto-publish name back to the sensor
s->setName(name);
}
return;
return true;
}
std::string _entityName;
......
......@@ -158,7 +158,8 @@ bool MSRConfigurator::readConfig(std::string cfgPath) {
}
}
//read of config finished. Now we build the mqtt-topic for every sensor
constructSensorNames();
if(!constructSensorNames())
return false;
for(const auto& g : _sensorGroups) {
for(const auto& s : g->getSensors()) {
s->setMqtt(_mqttPrefix + g->getMqttPart() + s->getMqtt());
......
......@@ -229,7 +229,8 @@ bool PerfeventConfigurator::readConfig(std::string cfgPath) {
}
}
//read of config finished. Now we build the mqtt-topic for every sensor
constructSensorNames();
if(!constructSensorNames())
return false;
for(const auto& g : _sensorGroups) {
for(const auto& s : g->getSensors()) {
s->setMqtt(_mqttPrefix + g->getMqttPart() + s->getMqtt());
......
......@@ -74,7 +74,8 @@ bool ProcfsConfigurator::readConfig(std::string cfgPath) {
return false;
}
}
constructSensorNames();
if(!constructSensorNames())
return false;
return true;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment