MCPcopy Create free account
hub / github.com/Icinga/icinga2 / ForceNextNotificationChangedAPIHandler

Method ForceNextNotificationChangedAPIHandler

lib/icinga/clusterevents.cpp:733–768  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

731}
732
733Value ClusterEvents::ForceNextNotificationChangedAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params)
734{
735 Endpoint::Ptr endpoint = origin->FromClient->GetEndpoint();
736
737 if (!endpoint) {
738 Log(LogNotice, "ClusterEvents")
739 << "Discarding 'force next notification changed' message from '" << origin->FromClient->GetIdentity() << "': Invalid endpoint origin (client not allowed).";
740 return Empty;
741 }
742
743 Host::Ptr host = Host::GetByName(params->Get("host"));
744
745 if (!host)
746 return Empty;
747
748 Checkable::Ptr checkable;
749
750 if (params->Contains("service"))
751 checkable = host->GetServiceByShortName(params->Get("service"));
752 else
753 checkable = host;
754
755 if (!checkable)
756 return Empty;
757
758 if (origin->FromZone && !origin->FromZone->CanAccessObject(checkable)) {
759 Log(LogNotice, "ClusterEvents")
760 << "Discarding 'force next notification' message for checkable '" << checkable->GetName()
761 << "' from '" << origin->FromClient->GetIdentity() << "': Unauthorized access.";
762 return Empty;
763 }
764
765 checkable->SetForceNextNotification(params->Get("forced"), false, origin);
766
767 return Empty;
768}
769
770void ClusterEvents::AcknowledgementSetHandler(const Checkable::Ptr& checkable,
771 const String& author, const String& comment, AcknowledgementType type,

Callers

nothing calls this directly

Calls 8

LogClass · 0.85
GetEndpointMethod · 0.80
GetIdentityMethod · 0.80
GetServiceByShortNameMethod · 0.80
CanAccessObjectMethod · 0.80
GetMethod · 0.45
ContainsMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected