mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-20 12:14:44 +02:00
parent
749863bee7
commit
a57ebbf953
@ -126,12 +126,6 @@ void ApiListener::SyncZoneDir(const Zone::Ptr& zone) const
|
|||||||
void ApiListener::SyncZoneDirs(void) const
|
void ApiListener::SyncZoneDirs(void) const
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(const Zone::Ptr& zone, DynamicType::GetObjects<Zone>()) {
|
BOOST_FOREACH(const Zone::Ptr& zone, DynamicType::GetObjects<Zone>()) {
|
||||||
/* always sync global zone dirs */
|
|
||||||
if (zone->GetGlobal()) {
|
|
||||||
SyncZoneDir(zone);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!IsConfigMaster(zone))
|
if (!IsConfigMaster(zone))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -158,8 +152,17 @@ void ApiListener::SendConfigUpdate(const ApiClient::Ptr& aclient)
|
|||||||
BOOST_FOREACH(const Zone::Ptr& zone, DynamicType::GetObjects<Zone>()) {
|
BOOST_FOREACH(const Zone::Ptr& zone, DynamicType::GetObjects<Zone>()) {
|
||||||
String zoneDir = zonesDir + "/" + zone->GetName();
|
String zoneDir = zonesDir + "/" + zone->GetName();
|
||||||
|
|
||||||
if (!zone->IsChildOf(azone) || !Utility::PathExists(zoneDir))
|
if (!zone->IsChildOf(azone) && !zone->IsGlobal()) {
|
||||||
|
Log(LogNotice, "ApiListener", "Skipping sync for '" + zone->GetName() + "'. Not a child of zone '" + azone->GetName() + "'.");
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
if (!Utility::PathExists(zoneDir)) {
|
||||||
|
Log(LogNotice, "ApiListener", "Ignoring sync for '" + zone->GetName() + "'. Zone directory '" + zoneDir + "' does not exist.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (zone->IsGlobal())
|
||||||
|
Log(LogInformation, "ApiListener", "Syncing global zone '" + zone->GetName() + "'.");
|
||||||
|
|
||||||
configUpdate->Set(zone->GetName(), LoadConfigDir(zonesDir + "/" + zone->GetName()));
|
configUpdate->Set(zone->GetName(), LoadConfigDir(zonesDir + "/" + zone->GetName()));
|
||||||
}
|
}
|
||||||
@ -182,8 +185,15 @@ Value ApiListener::ConfigUpdateHandler(const MessageOrigin& origin, const Dictio
|
|||||||
|
|
||||||
ApiListener::Ptr listener = ApiListener::GetInstance();
|
ApiListener::Ptr listener = ApiListener::GetInstance();
|
||||||
|
|
||||||
if (!listener || !listener->GetAcceptConfig())
|
if (!listener) {
|
||||||
|
Log(LogCritical, "ApiListener", "No instance available.");
|
||||||
return Empty;
|
return Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!listener->GetAcceptConfig()) {
|
||||||
|
Log(LogWarning, "ApiListener", "Ignoring config update. '" + listener->GetName() + "' does not accept config.");
|
||||||
|
return Empty;
|
||||||
|
}
|
||||||
|
|
||||||
Dictionary::Ptr update = params->Get("update");
|
Dictionary::Ptr update = params->Get("update");
|
||||||
|
|
||||||
|
@ -81,6 +81,16 @@ bool Zone::IsChildOf(const Zone::Ptr& zone)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Zone::IsGlobal(void)
|
||||||
|
{
|
||||||
|
Zone::Ptr zone = GetSelf();
|
||||||
|
|
||||||
|
if (!zone)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return zone->GetGlobal();
|
||||||
|
}
|
||||||
|
|
||||||
Zone::Ptr Zone::GetLocalZone(void)
|
Zone::Ptr Zone::GetLocalZone(void)
|
||||||
{
|
{
|
||||||
Endpoint::Ptr local = Endpoint::GetLocalEndpoint();
|
Endpoint::Ptr local = Endpoint::GetLocalEndpoint();
|
||||||
|
@ -41,6 +41,7 @@ public:
|
|||||||
|
|
||||||
bool CanAccessObject(const DynamicObject::Ptr& object);
|
bool CanAccessObject(const DynamicObject::Ptr& object);
|
||||||
bool IsChildOf(const Zone::Ptr& zone);
|
bool IsChildOf(const Zone::Ptr& zone);
|
||||||
|
bool IsGlobal(void);
|
||||||
|
|
||||||
static Zone::Ptr GetLocalZone(void);
|
static Zone::Ptr GetLocalZone(void);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user