mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 13:45:04 +02:00
parent
4f44ef13f1
commit
cf2bdecfeb
@ -127,6 +127,13 @@ void Checkable::RemoveDowntime(const String& id, bool cancelled, const String& a
|
|||||||
|
|
||||||
int legacy_id = downtime->GetLegacyId();
|
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);
|
downtimes->Remove(id);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -84,6 +84,9 @@ void Checkable::OnStateLoaded(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
BOOST_FOREACH(const String& id, ids) {
|
BOOST_FOREACH(const String& id, ids) {
|
||||||
|
/* override config owner to clear downtimes once */
|
||||||
|
Downtime::Ptr downtime = GetDowntimeByID(id);
|
||||||
|
downtime->SetConfigOwner(Empty);
|
||||||
RemoveDowntime(id, true);
|
RemoveDowntime(id, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ safe class Downtime
|
|||||||
};
|
};
|
||||||
[state] int legacy_id;
|
[state] int legacy_id;
|
||||||
[state] bool was_cancelled;
|
[state] bool was_cancelled;
|
||||||
|
[state] String config_owner;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "icinga/scheduleddowntime.h"
|
#include "icinga/scheduleddowntime.h"
|
||||||
#include "icinga/legacytimeperiod.h"
|
#include "icinga/legacytimeperiod.h"
|
||||||
|
#include "icinga/downtime.h"
|
||||||
#include "base/timer.h"
|
#include "base/timer.h"
|
||||||
#include "base/dynamictype.h"
|
#include "base/dynamictype.h"
|
||||||
#include "base/initialize.h"
|
#include "base/initialize.h"
|
||||||
@ -153,7 +154,10 @@ void ScheduledDowntime::CreateNextDowntime(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GetCheckable()->AddDowntime(GetAuthor(), GetComment(),
|
String uid = GetCheckable()->AddDowntime(GetAuthor(), GetComment(),
|
||||||
segment.first, segment.second,
|
segment.first, segment.second,
|
||||||
GetFixed(), String(), GetDuration(), GetName());
|
GetFixed(), String(), GetDuration(), GetName());
|
||||||
|
|
||||||
|
Downtime::Ptr downtime = Checkable::GetDowntimeByID(uid);
|
||||||
|
downtime->SetConfigOwner(GetName());
|
||||||
}
|
}
|
||||||
|
50
test/config/5980.conf
Normal file
50
test/config/5980.conf
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
|
||||||
|
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user