int legacy_id = downtime->GetLegacyId();
+ String config_owner = downtime->GetConfigOwner();
+
+ if (!config_owner.IsEmpty()) {
+ Log(LogWarning, "icinga", "Cannot remove downtime with ID '" + Convert::ToString(legacy_id) + "'. It is owned by scheduled downtime object '" + config_owner + "'");
+ return;
+ }
+
downtimes->Remove(id);
{
}
BOOST_FOREACH(const String& id, ids) {
+ /* override config owner to clear downtimes once */
+ Downtime::Ptr downtime = GetDowntimeByID(id);
+ downtime->SetConfigOwner(Empty);
RemoveDowntime(id, true);
}
}
};
[state] int legacy_id;
[state] bool was_cancelled;
+ [state] String config_owner;
};
}
#include "icinga/scheduleddowntime.h"
#include "icinga/legacytimeperiod.h"
+#include "icinga/downtime.h"
#include "base/timer.h"
#include "base/dynamictype.h"
#include "base/initialize.h"
return;
}
- GetCheckable()->AddDowntime(GetAuthor(), GetComment(),
+ String uid = GetCheckable()->AddDowntime(GetAuthor(), GetComment(),
segment.first, segment.second,
GetFixed(), String(), GetDuration(), GetName());
+
+ Downtime::Ptr downtime = Checkable::GetDowntimeByID(uid);
+ downtime->SetConfigOwner(GetName());
}
--- /dev/null
+
+
+object Host "5980-host" {
+ import "test-generic-host"
+ address = "127.0.0.1"
+}
+
+object Service "5980-service1" {
+ import "test-generic-service"
+ host_name = "5980-host"
+ check_command = "dummy"
+}
+
+object Service "5980-service2" {
+ import "test-generic-service"
+ host_name = "5980-host"
+ check_command = "dummy"
+}
+
+
+template ScheduledDowntime "5980-test-downtime" {
+ author = "icingaadmin"
+ comment = "Scheduled downtime for tests"
+
+ ranges = {
+ monday = "02:00-03:00"
+ tuesday = "02:00-03:00"
+ wednesday = "02:00-03:00"
+ thursday = "02:00-03:00"
+ friday = "02:00-03:00"
+ saturday = "02:00-03:00"
+ sunday = "02:00-03:00"
+ }
+}
+
+
+apply ScheduledDowntime "5980-test-service-downtime" to Host {
+ import "5980-test-downtime"
+ comment = "Scheduled host downtime for tests"
+
+ assign where host.name == "5980-host"
+}
+
+apply ScheduledDowntime "5980-test-service-downtime" to Service {
+ import "5980-test-downtime"
+ comment = "Scheduled service downtime for tests"
+
+ assign where host.name == "5980-host"
+}
+