mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 05:34:48 +02:00
parent
14fa3ceaee
commit
a552e917b3
@ -289,11 +289,7 @@ void LegacyTimePeriod::ParseTimeRange(const String& timerange, tm *begin, tm *en
|
|||||||
String second = def.SubStr(pos + 1);
|
String second = def.SubStr(pos + 1);
|
||||||
second.Trim();
|
second.Trim();
|
||||||
|
|
||||||
try {
|
ParseTimeSpec(first, begin, NULL, reference);
|
||||||
ParseTimeSpec(first, begin, NULL, reference);
|
|
||||||
} catch (std::exception&) {
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If the second definition starts with a number we need
|
/* If the second definition starts with a number we need
|
||||||
* to add the first word from the first definition, e.g.:
|
* to add the first word from the first definition, e.g.:
|
||||||
@ -314,17 +310,9 @@ void LegacyTimePeriod::ParseTimeRange(const String& timerange, tm *begin, tm *en
|
|||||||
second = first.SubStr(0, xpos + 1) + second;
|
second = first.SubStr(0, xpos + 1) + second;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
ParseTimeSpec(second, NULL, end, reference);
|
||||||
ParseTimeSpec(second, NULL, end, reference);
|
|
||||||
} catch (std::exception&) {
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
try {
|
ParseTimeSpec(def, begin, end, reference);
|
||||||
ParseTimeSpec(def, begin, end, reference);
|
|
||||||
} catch (std::exception&) {
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,11 +369,7 @@ Dictionary::Ptr LegacyTimePeriod::ProcessTimeRange(const String& timestamp, tm *
|
|||||||
{
|
{
|
||||||
tm begin, end;
|
tm begin, end;
|
||||||
|
|
||||||
try {
|
ProcessTimeRangeRaw(timestamp, reference, &begin, &end);
|
||||||
ProcessTimeRangeRaw(timestamp, reference, &begin, &end);
|
|
||||||
} catch (std::exception&) {
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
|
|
||||||
Dictionary::Ptr segment = new Dictionary();
|
Dictionary::Ptr segment = new Dictionary();
|
||||||
segment->Set("begin", (long)mktime(&begin));
|
segment->Set("begin", (long)mktime(&begin));
|
||||||
@ -400,12 +384,7 @@ void LegacyTimePeriod::ProcessTimeRanges(const String& timeranges, tm *reference
|
|||||||
boost::algorithm::split(ranges, timeranges, boost::is_any_of(","));
|
boost::algorithm::split(ranges, timeranges, boost::is_any_of(","));
|
||||||
|
|
||||||
BOOST_FOREACH(const String& range, ranges) {
|
BOOST_FOREACH(const String& range, ranges) {
|
||||||
Dictionary::Ptr segment;
|
Dictionary::Ptr segment = ProcessTimeRange(range, reference);
|
||||||
try {
|
|
||||||
segment = ProcessTimeRange(range, reference);
|
|
||||||
} catch (std::exception&) {
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (segment->Get("begin") >= segment->Get("end"))
|
if (segment->Get("begin") >= segment->Get("end"))
|
||||||
continue;
|
continue;
|
||||||
|
@ -199,16 +199,16 @@ void ScheduledDowntime::ValidateRanges(const String& location, const ScheduledDo
|
|||||||
tm begin_tm, end_tm;
|
tm begin_tm, end_tm;
|
||||||
int stride;
|
int stride;
|
||||||
LegacyTimePeriod::ParseTimeRange(kv.first, &begin_tm, &end_tm, &stride, &reference);
|
LegacyTimePeriod::ParseTimeRange(kv.first, &begin_tm, &end_tm, &stride, &reference);
|
||||||
} catch (std::exception&) {
|
} catch (const std::exception& ex) {
|
||||||
BOOST_THROW_EXCEPTION(ScriptError("Validation failed for " +
|
BOOST_THROW_EXCEPTION(ScriptError("Validation failed for " +
|
||||||
location + ": Invalid time specification.", object->GetDebugInfo()));
|
location + ": Invalid time specification '" + kv.first + "': " + ex.what(), object->GetDebugInfo()));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
LegacyTimePeriod::ProcessTimeRanges(kv.second, &reference, segments);
|
LegacyTimePeriod::ProcessTimeRanges(kv.second, &reference, segments);
|
||||||
} catch (std::exception&) {
|
} catch (const std::exception& ex) {
|
||||||
BOOST_THROW_EXCEPTION(ScriptError("Validation failed for " +
|
BOOST_THROW_EXCEPTION(ScriptError("Validation failed for " +
|
||||||
location + ": Invalid time range definition.", object->GetDebugInfo()));
|
location + ": Invalid time range definition '" + kv.second + "': " + ex.what(), object->GetDebugInfo()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -324,16 +324,16 @@ void TimePeriod::ValidateRanges(const String& location, const TimePeriod::Ptr& o
|
|||||||
tm begin_tm, end_tm;
|
tm begin_tm, end_tm;
|
||||||
int stride;
|
int stride;
|
||||||
LegacyTimePeriod::ParseTimeRange(kv.first, &begin_tm, &end_tm, &stride, &reference);
|
LegacyTimePeriod::ParseTimeRange(kv.first, &begin_tm, &end_tm, &stride, &reference);
|
||||||
} catch (std::exception&) {
|
} catch (const std::exception& ex) {
|
||||||
BOOST_THROW_EXCEPTION(ScriptError("Validation failed for " +
|
BOOST_THROW_EXCEPTION(ScriptError("Validation failed for " +
|
||||||
location + ": Invalid time specification.", object->GetDebugInfo()));
|
location + ": Invalid time specification '" + kv.first + "': " + ex.what(), object->GetDebugInfo()));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
LegacyTimePeriod::ProcessTimeRanges(kv.second, &reference, segments);
|
LegacyTimePeriod::ProcessTimeRanges(kv.second, &reference, segments);
|
||||||
} catch (std::exception&) {
|
} catch (const std::exception& ex) {
|
||||||
BOOST_THROW_EXCEPTION(ScriptError("Validation failed for " +
|
BOOST_THROW_EXCEPTION(ScriptError("Validation failed for " +
|
||||||
location + ": Invalid time range definition.", object->GetDebugInfo()));
|
location + ": Invalid time range definition '" + kv.second + "': " + ex.what(), object->GetDebugInfo()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user