Raise a config error for "Checkable" objects in global zones

fixes #10807
This commit is contained in:
Michael Friedrich 2016-01-14 15:33:28 +01:00 committed by Gunnar Beutner
parent e69fe8dcd0
commit f5fda9ebf0
2 changed files with 18 additions and 0 deletions

View File

@ -38,6 +38,15 @@ void Host::OnAllConfigLoaded(void)
{
ObjectImpl<Host>::OnAllConfigLoaded();
String zoneName = GetZoneName();
if (!zoneName.IsEmpty()) {
Zone::Ptr zone = Zone::GetByName(zoneName);
if (zone && zone->IsGlobal())
BOOST_THROW_EXCEPTION(std::invalid_argument("Host '" + GetName() + "' cannot be put into global zone '" + zone->GetName() + "'."));
}
HostGroup::EvaluateObjectRules(this);
Array::Ptr groups = GetGroups();

View File

@ -63,6 +63,15 @@ void Service::OnAllConfigLoaded(void)
{
ObjectImpl<Service>::OnAllConfigLoaded();
String zoneName = GetZoneName();
if (!zoneName.IsEmpty()) {
Zone::Ptr zone = Zone::GetByName(zoneName);
if (zone && zone->IsGlobal())
BOOST_THROW_EXCEPTION(std::invalid_argument("Service '" + GetName() + "' cannot be put into global zone '" + zone->GetName() + "'."));
}
m_Host = Host::GetByName(GetHostName());
if (m_Host)