Clean up ClusterListener::Supports{Checks,Notifications}.

Refs #5467
This commit is contained in:
Gunnar Beutner 2014-04-23 11:59:15 +02:00
parent 2b70b282ad
commit 24bfc6d084
1 changed files with 4 additions and 15 deletions

View File

@ -603,8 +603,8 @@ void ClusterListener::ClusterTimerHandler(void)
/* Eww. */ /* Eww. */
Dictionary::Ptr features = make_shared<Dictionary>(); Dictionary::Ptr features = make_shared<Dictionary>();
features->Set("checker", SupportsChecks() ? 1 : 0); features->Set("checker", SupportsChecks());
features->Set("notification", SupportsNotifications() ? 1 : 0); features->Set("notification", SupportsNotifications());
params->Set("features", features); params->Set("features", features);
Dictionary::Ptr message = make_shared<Dictionary>(); Dictionary::Ptr message = make_shared<Dictionary>();
@ -1691,22 +1691,12 @@ void ClusterListener::UpdateAuthority(void)
bool ClusterListener::SupportsChecks(void) bool ClusterListener::SupportsChecks(void)
{ {
DynamicType::Ptr type = DynamicType::GetByName("CheckerComponent"); return SupportsFeature("CheckerComponent") && (IcingaApplication::GetInstance()->GetEnableHostChecks() || IcingaApplication::GetInstance()->GetEnableServiceChecks());
if (!type)
return false;
return std::distance(type->GetObjects().first, type->GetObjects().second) > 0 && (IcingaApplication::GetInstance()->GetEnableHostChecks() || IcingaApplication::GetInstance()->GetEnableServiceChecks());
} }
bool ClusterListener::SupportsNotifications(void) bool ClusterListener::SupportsNotifications(void)
{ {
DynamicType::Ptr type = DynamicType::GetByName("NotificationComponent"); return SupportsFeature("NotificationComponent") && IcingaApplication::GetInstance()->GetEnableNotifications();
if (!type)
return false;
return std::distance(type->GetObjects().first, type->GetObjects().second) > 0 && IcingaApplication::GetInstance()->GetEnableNotifications();
} }
bool ClusterListener::SupportsFeature(const String& name) bool ClusterListener::SupportsFeature(const String& name)
@ -1753,4 +1743,3 @@ std::pair<Dictionary::Ptr, Dictionary::Ptr> ClusterListener::GetClusterStatus(vo
return std::make_pair(status, perfdata); return std::make_pair(status, perfdata);
} }