mirror of https://github.com/Icinga/icinga2.git
Undelegate services when their config objects are removed.
This commit is contained in:
parent
4bad5f11c8
commit
8955f17c41
|
@ -30,7 +30,8 @@ string DelegationComponent::GetName(void) const
|
|||
void DelegationComponent::Start(void)
|
||||
{
|
||||
m_AllServices = boost::make_shared<ConfigObject::Set>(ConfigObject::GetAllObjects(), ConfigObject::MakeTypePredicate("service"));
|
||||
m_AllServices->OnObjectCommitted.connect(boost::bind(&DelegationComponent::ObjectCommittedHandler, this, _2));
|
||||
m_AllServices->OnObjectCommitted.connect(boost::bind(&DelegationComponent::ServiceCommittedHandler, this, _2));
|
||||
m_AllServices->OnObjectRemoved.connect(boost::bind(&DelegationComponent::ServiceRemovedHandler, this, _2));
|
||||
m_AllServices->Start();
|
||||
|
||||
m_DelegationTimer = boost::make_shared<Timer>();
|
||||
|
@ -60,10 +61,8 @@ void DelegationComponent::Stop(void)
|
|||
mgr->UnregisterEndpoint(m_Endpoint);
|
||||
}
|
||||
|
||||
void DelegationComponent::ObjectCommittedHandler(const ConfigObject::Ptr& object)
|
||||
void DelegationComponent::ServiceCommittedHandler(Service service)
|
||||
{
|
||||
Service service(object);
|
||||
|
||||
string checker = service.GetChecker();
|
||||
|
||||
if (!checker.empty()) {
|
||||
|
@ -78,6 +77,19 @@ void DelegationComponent::ObjectCommittedHandler(const ConfigObject::Ptr& object
|
|||
}
|
||||
}
|
||||
|
||||
void DelegationComponent::ServiceRemovedHandler(Service service)
|
||||
{
|
||||
string checker = service.GetChecker();
|
||||
|
||||
if (!checker.empty()) {
|
||||
/* TODO: figure out a better way to clear individual services */
|
||||
Endpoint::Ptr endpoint = EndpointManager::GetInstance()->GetEndpointByIdentity(checker);
|
||||
|
||||
if (endpoint)
|
||||
ClearServices(endpoint);
|
||||
}
|
||||
}
|
||||
|
||||
void DelegationComponent::AssignService(const Endpoint::Ptr& checker, const Service& service)
|
||||
{
|
||||
RequestMessage request;
|
||||
|
|
|
@ -41,7 +41,8 @@ private:
|
|||
void NewEndpointHandler(const Endpoint::Ptr& endpoint);
|
||||
void SessionEstablishedHandler(const Endpoint::Ptr& endpoint);
|
||||
|
||||
void ObjectCommittedHandler(const ConfigObject::Ptr& object);
|
||||
void ServiceCommittedHandler(Service service);
|
||||
void ServiceRemovedHandler(Service service);
|
||||
void DelegationTimerHandler(void);
|
||||
|
||||
vector<Endpoint::Ptr> GetCheckerCandidates(const Service& service) const;
|
||||
|
|
Loading…
Reference in New Issue