Skip to content

Commit

Permalink
parent_affecting_logging: a config object affects everything function…
Browse files Browse the repository at this point in the history
…ally depending on it
  • Loading branch information
Al2Klimov committed Aug 15, 2023
1 parent 67fb214 commit d98bb31
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/icinga/comment.ti
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ class Comment : ConfigObject < CommentNameComposer
load_after Host;
load_after Service;

[config, no_user_modify, protected, required, navigation(host)] name(Host) host_name {
[config, no_user_modify, protected, required, navigation(host), parent_affecting_logging] name(Host) host_name {
navigate {{{
return Host::GetByName(GetHostName());
}}}
};
[config, no_user_modify, protected, navigation(service)] String service_name {
[config, no_user_modify, protected, navigation(service), parent_affecting_logging] String service_name {
track {{{
if (!oldValue.IsEmpty()) {
Service::Ptr service = Service::GetByNamePair(GetHostName(), oldValue);
Expand Down
4 changes: 2 additions & 2 deletions lib/icinga/dependency.ti
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ class Dependency : CustomVarObject < DependencyNameComposer
}}}
};

[config, no_user_modify, required, navigation(parent_host)] name(Host) parent_host_name {
[config, no_user_modify, required, navigation(parent_host), parent_affecting_logging] name(Host) parent_host_name {
navigate {{{
return Host::GetByName(GetParentHostName());
}}}
};

[config, no_user_modify, navigation(parent_service)] String parent_service_name {
[config, no_user_modify, navigation(parent_service), parent_affecting_logging] String parent_service_name {
track {{{
if (!oldValue.IsEmpty()) {
Service::Ptr service = Service::GetByNamePair(GetParentHostName(), oldValue);
Expand Down
11 changes: 11 additions & 0 deletions lib/icinga/downtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,17 @@ void Downtime::Stop(bool runtimeRemoved)
ObjectImpl<Downtime>::Stop(runtimeRemoved);
}

void Downtime::GetParentsAffectingLogging(std::vector<ConfigObject::Ptr>& output) const
{
ObjectImpl<Downtime>::GetParentsAffectingLogging(output);

auto object (ConfigObject::GetObject<ScheduledDowntime>(GetConfigOwner()));

if (object) {
output.emplace_back(std::move(object));
}
}

void Downtime::Pause()
{
if (m_CleanupTimer) {
Expand Down
1 change: 1 addition & 0 deletions lib/icinga/downtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class Downtime final : public ObjectImpl<Downtime>
protected:
void Start(bool runtimeCreated) override;
void Stop(bool runtimeRemoved) override;
void GetParentsAffectingLogging(std::vector<ConfigObject::Ptr>& output) const override;

void Pause() override;
void Resume() override;
Expand Down
4 changes: 2 additions & 2 deletions lib/icinga/downtime.ti
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ class Downtime : ConfigObject < DowntimeNameComposer
load_after Host;
load_after Service;

[config, no_user_modify, required, navigation(host)] name(Host) host_name {
[config, no_user_modify, required, navigation(host), parent_affecting_logging] name(Host) host_name {
navigate {{{
return Host::GetByName(GetHostName());
}}}
};
[config, no_user_modify, navigation(service)] String service_name {
[config, no_user_modify, navigation(service), parent_affecting_logging] String service_name {
track {{{
if (!oldValue.IsEmpty()) {
Service::Ptr service = Service::GetByNamePair(GetHostName(), oldValue);
Expand Down

0 comments on commit d98bb31

Please sign in to comment.