mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 21:55:03 +02:00
Refactor authority checks a bit.
This commit is contained in:
parent
95909d82fe
commit
3b1b9d1274
@ -458,8 +458,8 @@ void ClusterComponent::ClusterTimerHandler(void)
|
|||||||
|
|
||||||
/* Eww. */
|
/* Eww. */
|
||||||
Dictionary::Ptr features = boost::make_shared<Dictionary>();
|
Dictionary::Ptr features = boost::make_shared<Dictionary>();
|
||||||
features->Set("checker", DynamicType::GetByName("CheckerComponent") ? 1 : 0);
|
features->Set("checker", SupportsChecks() ? 1 : 0);
|
||||||
features->Set("notification", DynamicType::GetByName("NotificationComponent") ? 1 : 0);
|
features->Set("notification", SupportsNotifications() ? 1 : 0);
|
||||||
params->Set("features", features);
|
params->Set("features", features);
|
||||||
|
|
||||||
Dictionary::Ptr message = boost::make_shared<Dictionary>();
|
Dictionary::Ptr message = boost::make_shared<Dictionary>();
|
||||||
@ -1126,14 +1126,14 @@ void ClusterComponent::CheckAuthorityHandler(const DynamicObject::Ptr& object, c
|
|||||||
Array::Ptr authorities = object->GetAuthorities();
|
Array::Ptr authorities = object->GetAuthorities();
|
||||||
std::vector<String> endpoints;
|
std::vector<String> endpoints;
|
||||||
|
|
||||||
if ((type == "checker" && DynamicType::GetByName("CheckerComponent")) ||
|
if ((type == "checker" && SupportsChecks()) ||
|
||||||
(type == "notification" && DynamicType::GetByName("NotificationComponent")))
|
(type == "notification" && SupportsNotifications()))
|
||||||
endpoints.push_back(GetIdentity());
|
endpoints.push_back(GetIdentity());
|
||||||
|
|
||||||
BOOST_FOREACH(const Endpoint::Ptr& endpoint, DynamicType::GetObjects<Endpoint>()) {
|
BOOST_FOREACH(const Endpoint::Ptr& endpoint, DynamicType::GetObjects<Endpoint>()) {
|
||||||
bool match = false;
|
bool match = false;
|
||||||
|
|
||||||
if (!endpoint->IsConnected())
|
if (!endpoint->IsConnected() || !endpoint->HasFeature(type))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (authorities) {
|
if (authorities) {
|
||||||
@ -1163,6 +1163,16 @@ void ClusterComponent::CheckAuthorityHandler(const DynamicObject::Ptr& object, c
|
|||||||
result = (endpoints[index] == GetIdentity());
|
result = (endpoints[index] == GetIdentity());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ClusterComponent::SupportsChecks(void)
|
||||||
|
{
|
||||||
|
return DynamicType::GetByName("CheckerComponent");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ClusterComponent::SupportsNotifications(void)
|
||||||
|
{
|
||||||
|
return DynamicType::GetByName("NotificationComponent");
|
||||||
|
}
|
||||||
|
|
||||||
void ClusterComponent::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
|
void ClusterComponent::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
|
||||||
{
|
{
|
||||||
DynamicObject::InternalSerialize(bag, attributeTypes);
|
DynamicObject::InternalSerialize(bag, attributeTypes);
|
||||||
|
@ -112,6 +112,9 @@ private:
|
|||||||
void AcknowledgementClearedHandler(const Service::Ptr& service, const String& authority);
|
void AcknowledgementClearedHandler(const Service::Ptr& service, const String& authority);
|
||||||
void MessageHandler(const Endpoint::Ptr& sender, const Dictionary::Ptr& message);
|
void MessageHandler(const Endpoint::Ptr& sender, const Dictionary::Ptr& message);
|
||||||
void CheckAuthorityHandler(const DynamicObject::Ptr& object, const String& type, bool& result);
|
void CheckAuthorityHandler(const DynamicObject::Ptr& object, const String& type, bool& result);
|
||||||
|
|
||||||
|
static bool SupportsChecks(void);
|
||||||
|
static bool SupportsNotifications(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user