mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-26 15:14:07 +02:00
parent
8958d2f69f
commit
de81baf515
@ -53,66 +53,6 @@ Value AExpression::Evaluate(const Dictionary::Ptr& locals) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AExpression::ExtractPath(const std::vector<String>& path, const Array::Ptr& result) const
|
|
||||||
{
|
|
||||||
ASSERT(!path.empty());
|
|
||||||
|
|
||||||
if (m_Operator == &AExpression::OpDict) {
|
|
||||||
Array::Ptr exprl = m_Operand1;
|
|
||||||
ObjectLock olock(exprl);
|
|
||||||
BOOST_FOREACH(const AExpression::Ptr& expr, exprl) {
|
|
||||||
expr->ExtractPath(path, result);
|
|
||||||
}
|
|
||||||
} else if ((m_Operator == &AExpression::OpSet || m_Operator == &AExpression::OpSetPlus ||
|
|
||||||
m_Operator == &AExpression::OpSetMinus || m_Operator == &AExpression::OpSetMultiply ||
|
|
||||||
m_Operator == &AExpression::OpSetDivide) && path[0] == m_Operand1) {
|
|
||||||
AExpression::Ptr exprl = m_Operand2;
|
|
||||||
|
|
||||||
if (path.size() == 1) {
|
|
||||||
if (m_Operator == &AExpression::OpSet)
|
|
||||||
result->Clear();
|
|
||||||
|
|
||||||
if (exprl->m_Operator != &AExpression::OpDict)
|
|
||||||
BOOST_THROW_EXCEPTION(ConfigError("The '" + path[0] + "' attribute must be a dictionary.") << errinfo_debuginfo(m_DebugInfo));
|
|
||||||
|
|
||||||
Array::Ptr subexprl = exprl->m_Operand1;
|
|
||||||
ObjectLock olock(subexprl);
|
|
||||||
BOOST_FOREACH(const AExpression::Ptr& expr, subexprl) {
|
|
||||||
result->Add(expr);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<String> sub_path(path.begin() + 1, path.end());
|
|
||||||
exprl->ExtractPath(sub_path, result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AExpression::FindDebugInfoPath(const std::vector<String>& path, DebugInfo& result) const
|
|
||||||
{
|
|
||||||
ASSERT(!path.empty());
|
|
||||||
|
|
||||||
if (m_Operator == &AExpression::OpDict) {
|
|
||||||
Array::Ptr exprl = m_Operand1;
|
|
||||||
ObjectLock olock(exprl);
|
|
||||||
BOOST_FOREACH(const AExpression::Ptr& expr, exprl) {
|
|
||||||
expr->FindDebugInfoPath(path, result);
|
|
||||||
}
|
|
||||||
} else if ((m_Operator == &AExpression::OpSet || m_Operator == &AExpression::OpSetPlus ||
|
|
||||||
m_Operator == &AExpression::OpSetMinus || m_Operator == &AExpression::OpSetMultiply ||
|
|
||||||
m_Operator == &AExpression::OpSetDivide) && path[0] == m_Operand1) {
|
|
||||||
AExpression::Ptr exprl = m_Operand2;
|
|
||||||
|
|
||||||
if (path.size() == 1) {
|
|
||||||
result = m_DebugInfo;
|
|
||||||
} else {
|
|
||||||
std::vector<String> sub_path(path.begin() + 1, path.end());
|
|
||||||
exprl->FindDebugInfoPath(sub_path, result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AExpression::MakeInline(void)
|
void AExpression::MakeInline(void)
|
||||||
{
|
{
|
||||||
if (m_Operator == &AExpression::OpDict)
|
if (m_Operator == &AExpression::OpDict)
|
||||||
|
@ -42,8 +42,6 @@ public:
|
|||||||
AExpression(OpCallback op, const Value& operand1, const Value& operand2, const DebugInfo& di);
|
AExpression(OpCallback op, const Value& operand1, const Value& operand2, const DebugInfo& di);
|
||||||
|
|
||||||
Value Evaluate(const Dictionary::Ptr& locals) const;
|
Value Evaluate(const Dictionary::Ptr& locals) const;
|
||||||
void ExtractPath(const std::vector<String>& path, const Array::Ptr& result) const;
|
|
||||||
void FindDebugInfoPath(const std::vector<String>& path, DebugInfo& result) const;
|
|
||||||
|
|
||||||
void MakeInline(void);
|
void MakeInline(void);
|
||||||
|
|
||||||
|
@ -57,8 +57,6 @@ void Host::OnConfigLoaded(void)
|
|||||||
hg->AddMember(GetSelf());
|
hg->AddMember(GetSelf());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateSlaveServices();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Host::Stop(void)
|
void Host::Stop(void)
|
||||||
@ -92,81 +90,6 @@ bool Host::IsReachable(DependencyType dt, shared_ptr<Dependency> *failedDependen
|
|||||||
return hc->IsReachable(dt, failedDependency);
|
return hc->IsReachable(dt, failedDependency);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Host::UpdateSlaveServices(void)
|
|
||||||
{
|
|
||||||
ASSERT(!OwnsLock());
|
|
||||||
|
|
||||||
Dictionary::Ptr service_descriptions = GetServiceDescriptions();
|
|
||||||
|
|
||||||
if (!service_descriptions ||service_descriptions->GetLength() == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ConfigItem::Ptr item = ConfigItem::GetObject("Host", GetName());
|
|
||||||
|
|
||||||
ObjectLock olock(service_descriptions);
|
|
||||||
BOOST_FOREACH(const Dictionary::Pair& kv, service_descriptions) {
|
|
||||||
std::ostringstream namebuf;
|
|
||||||
namebuf << GetName() << "!" << kv.first;
|
|
||||||
String name = namebuf.str();
|
|
||||||
|
|
||||||
std::vector<String> path;
|
|
||||||
path.push_back("services");
|
|
||||||
path.push_back(kv.first);
|
|
||||||
|
|
||||||
AExpression::Ptr exprl;
|
|
||||||
|
|
||||||
{
|
|
||||||
ObjectLock ilock(item);
|
|
||||||
|
|
||||||
exprl = item->GetExpressionList();
|
|
||||||
}
|
|
||||||
|
|
||||||
DebugInfo di;
|
|
||||||
exprl->FindDebugInfoPath(path, di);
|
|
||||||
|
|
||||||
if (di.Path.IsEmpty())
|
|
||||||
di = item->GetDebugInfo();
|
|
||||||
|
|
||||||
ConfigItemBuilder::Ptr builder = make_shared<ConfigItemBuilder>(di);
|
|
||||||
builder->SetType("Service");
|
|
||||||
builder->SetName(name);
|
|
||||||
|
|
||||||
Dictionary::Ptr service = kv.second;
|
|
||||||
|
|
||||||
Array::Ptr templates = service->Get("templates");
|
|
||||||
|
|
||||||
if (templates) {
|
|
||||||
ObjectLock olock(templates);
|
|
||||||
|
|
||||||
BOOST_FOREACH(const Value& tmpl, templates) {
|
|
||||||
AExpression::Ptr atype = make_shared<AExpression>(&AExpression::OpLiteral, "Service", di);
|
|
||||||
AExpression::Ptr atmpl = make_shared<AExpression>(&AExpression::OpLiteral, tmpl, di);
|
|
||||||
builder->AddExpression(make_shared<AExpression>(&AExpression::OpImport, atype, atmpl, di));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
builder->AddExpression(make_shared<AExpression>(&AExpression::OpSet, "host", make_shared<AExpression>(&AExpression::OpLiteral, GetName(), di), di));
|
|
||||||
builder->AddExpression(make_shared<AExpression>(&AExpression::OpSet, "display_name", make_shared<AExpression>(&AExpression::OpLiteral, kv.first, di), di));
|
|
||||||
builder->AddExpression(make_shared<AExpression>(&AExpression::OpSet, "short_name", make_shared<AExpression>(&AExpression::OpLiteral, kv.first, di), di));
|
|
||||||
|
|
||||||
if (!kv.second.IsObjectType<Dictionary>())
|
|
||||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Service description must be either a string or a dictionary."));
|
|
||||||
|
|
||||||
/* Clone attributes from the service expression list. */
|
|
||||||
Array::Ptr svc_exprl = make_shared<Array>();
|
|
||||||
exprl->ExtractPath(path, svc_exprl);
|
|
||||||
|
|
||||||
builder->AddExpression(make_shared<AExpression>(&AExpression::OpDict, svc_exprl, true, di));
|
|
||||||
|
|
||||||
builder->SetScope(item->GetScope());
|
|
||||||
|
|
||||||
ConfigItem::Ptr serviceItem = builder->Compile();
|
|
||||||
serviceItem->Register();
|
|
||||||
DynamicObject::Ptr dobj = serviceItem->Commit();
|
|
||||||
dobj->OnConfigLoaded();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::set<Service::Ptr> Host::GetServices(void) const
|
std::set<Service::Ptr> Host::GetServices(void) const
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(m_ServicesMutex);
|
boost::mutex::scoped_lock lock(m_ServicesMutex);
|
||||||
|
@ -114,8 +114,6 @@ private:
|
|||||||
mutable boost::mutex m_ServicesMutex;
|
mutable boost::mutex m_ServicesMutex;
|
||||||
std::map<String, shared_ptr<Service> > m_Services;
|
std::map<String, shared_ptr<Service> > m_Services;
|
||||||
|
|
||||||
void UpdateSlaveServices(void);
|
|
||||||
|
|
||||||
static void RefreshServicesCache(void);
|
static void RefreshServicesCache(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,25 +23,6 @@ type Host {
|
|||||||
%attribute array "groups" {
|
%attribute array "groups" {
|
||||||
%attribute name(HostGroup) "*"
|
%attribute name(HostGroup) "*"
|
||||||
},
|
},
|
||||||
%attribute dictionary "services" {
|
|
||||||
%attribute dictionary "*" {
|
|
||||||
%attribute array "templates" {
|
|
||||||
%attribute name(Service) "*"
|
|
||||||
},
|
|
||||||
|
|
||||||
%attribute any "*"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
%attribute dictionary "dependencies" {
|
|
||||||
%attribute dictionary "*" {
|
|
||||||
%attribute array "templates" {
|
|
||||||
%attribute name(Dependency) "*"
|
|
||||||
},
|
|
||||||
|
|
||||||
%attribute any "*"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
%attribute dictionary "macros" {
|
%attribute dictionary "macros" {
|
||||||
%attribute string "*"
|
%attribute string "*"
|
||||||
@ -93,42 +74,10 @@ type Service {
|
|||||||
|
|
||||||
%attribute number "volatile",
|
%attribute number "volatile",
|
||||||
|
|
||||||
%attribute dictionary "dependencies" {
|
|
||||||
%attribute dictionary "*" {
|
|
||||||
%attribute array "templates" {
|
|
||||||
%attribute name(Dependency) "*"
|
|
||||||
},
|
|
||||||
|
|
||||||
%attribute any "*"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
%attribute array "groups" {
|
%attribute array "groups" {
|
||||||
%attribute name(ServiceGroup) "*"
|
%attribute name(ServiceGroup) "*"
|
||||||
},
|
},
|
||||||
|
|
||||||
%attribute dictionary "notifications" {
|
|
||||||
%attribute dictionary "*" {
|
|
||||||
%attribute array "templates" {
|
|
||||||
%attribute name(Notification) "*"
|
|
||||||
},
|
|
||||||
|
|
||||||
%attribute any "*"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
%attribute dictionary "scheduled_downtimes" {
|
|
||||||
%attribute dictionary "*" {
|
|
||||||
%attribute array "templates" {
|
|
||||||
%attribute name(ScheduledDowntime) "*"
|
|
||||||
},
|
|
||||||
|
|
||||||
%attribute any "*"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
%attribute any "templates",
|
|
||||||
|
|
||||||
%attribute array "authorities" {
|
%attribute array "authorities" {
|
||||||
%attribute name(Endpoint) "*"
|
%attribute name(Endpoint) "*"
|
||||||
},
|
},
|
||||||
@ -170,8 +119,6 @@ type Notification {
|
|||||||
%attribute number "notification_type_filter",
|
%attribute number "notification_type_filter",
|
||||||
%attribute number "notification_state_filter",
|
%attribute number "notification_state_filter",
|
||||||
|
|
||||||
%attribute any "templates",
|
|
||||||
|
|
||||||
%attribute array "authorities" {
|
%attribute array "authorities" {
|
||||||
%attribute name(Endpoint) "*"
|
%attribute name(Endpoint) "*"
|
||||||
},
|
},
|
||||||
@ -278,8 +225,6 @@ type ScheduledDowntime {
|
|||||||
%attribute dictionary "ranges" {
|
%attribute dictionary "ranges" {
|
||||||
%attribute string "*"
|
%attribute string "*"
|
||||||
},
|
},
|
||||||
|
|
||||||
%attribute any "templates"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Dependency {
|
type Dependency {
|
||||||
|
@ -154,93 +154,3 @@ std::set<Service::Ptr> Service::GetChildServices(void) const
|
|||||||
return parents;
|
return parents;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Service::UpdateSlaveDependencies(void)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* pass == 0 -> steal host's dependency definitions
|
|
||||||
* pass == 1 -> service's dependencies
|
|
||||||
*/
|
|
||||||
for (int pass = 0; pass < 2; pass++) {
|
|
||||||
/* Service dependency descs */
|
|
||||||
Dictionary::Ptr descs;
|
|
||||||
|
|
||||||
if (pass == 0 && !IsHostCheck())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (pass == 0)
|
|
||||||
descs = GetHost()->GetDependencyDescriptions();
|
|
||||||
else
|
|
||||||
descs = GetDependencyDescriptions();
|
|
||||||
|
|
||||||
if (!descs || descs->GetLength() == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
ConfigItem::Ptr item;
|
|
||||||
|
|
||||||
if (pass == 0)
|
|
||||||
item = ConfigItem::GetObject("Host", GetHost()->GetName());
|
|
||||||
else
|
|
||||||
item = ConfigItem::GetObject("Service", GetName());
|
|
||||||
|
|
||||||
ObjectLock olock(descs);
|
|
||||||
|
|
||||||
BOOST_FOREACH(const Dictionary::Pair& kv, descs) {
|
|
||||||
std::ostringstream namebuf;
|
|
||||||
namebuf << GetName() << "!" << kv.first;
|
|
||||||
String name = namebuf.str();
|
|
||||||
|
|
||||||
std::vector<String> path;
|
|
||||||
path.push_back("dependencies");
|
|
||||||
path.push_back(kv.first);
|
|
||||||
|
|
||||||
AExpression::Ptr exprl;
|
|
||||||
|
|
||||||
{
|
|
||||||
ObjectLock ilock(item);
|
|
||||||
|
|
||||||
exprl = item->GetExpressionList();
|
|
||||||
}
|
|
||||||
|
|
||||||
DebugInfo di;
|
|
||||||
exprl->FindDebugInfoPath(path, di);
|
|
||||||
|
|
||||||
if (di.Path.IsEmpty())
|
|
||||||
di = item->GetDebugInfo();
|
|
||||||
|
|
||||||
ConfigItemBuilder::Ptr builder = make_shared<ConfigItemBuilder>(di);
|
|
||||||
builder->SetType("Dependency");
|
|
||||||
builder->SetName(name);
|
|
||||||
|
|
||||||
|
|
||||||
Dictionary::Ptr dependency = kv.second;
|
|
||||||
|
|
||||||
Array::Ptr templates = dependency->Get("templates");
|
|
||||||
|
|
||||||
if (templates) {
|
|
||||||
ObjectLock tlock(templates);
|
|
||||||
|
|
||||||
BOOST_FOREACH(const Value& tmpl, templates) {
|
|
||||||
AExpression::Ptr atype = make_shared<AExpression>(&AExpression::OpLiteral, "Dependency", di);
|
|
||||||
AExpression::Ptr atmpl = make_shared<AExpression>(&AExpression::OpLiteral, tmpl, di);
|
|
||||||
builder->AddExpression(make_shared<AExpression>(&AExpression::OpImport, atype, atmpl, di));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
builder->AddExpression(make_shared<AExpression>(&AExpression::OpSet, "child_host", make_shared<AExpression>(&AExpression::OpLiteral, GetHost()->GetName(), di), di));
|
|
||||||
builder->AddExpression(make_shared<AExpression>(&AExpression::OpSet, "child_service", make_shared<AExpression>(&AExpression::OpLiteral, GetShortName(), di), di));
|
|
||||||
|
|
||||||
/* Clone attributes from the scheduled downtime expression list. */
|
|
||||||
Array::Ptr sd_exprl = make_shared<Array>();
|
|
||||||
exprl->ExtractPath(path, sd_exprl);
|
|
||||||
|
|
||||||
builder->AddExpression(make_shared<AExpression>(&AExpression::OpDict, sd_exprl, true, di));
|
|
||||||
|
|
||||||
builder->SetScope(item->GetScope());
|
|
||||||
|
|
||||||
ConfigItem::Ptr dependencyItem = builder->Compile();
|
|
||||||
dependencyItem->Register();
|
|
||||||
DynamicObject::Ptr dobj = dependencyItem->Commit();
|
|
||||||
dobj->OnConfigLoaded();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -321,73 +321,3 @@ int Service::GetDowntimeDepth(void) const
|
|||||||
return downtime_depth;
|
return downtime_depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Service::UpdateSlaveScheduledDowntimes(void)
|
|
||||||
{
|
|
||||||
/* Service scheduled downtime descs */
|
|
||||||
Dictionary::Ptr descs = GetScheduledDowntimeDescriptions();
|
|
||||||
|
|
||||||
if (!descs || descs->GetLength() == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ConfigItem::Ptr item = ConfigItem::GetObject("Service", GetName());
|
|
||||||
|
|
||||||
ObjectLock olock(descs);
|
|
||||||
|
|
||||||
BOOST_FOREACH(const Dictionary::Pair& kv, descs) {
|
|
||||||
std::ostringstream namebuf;
|
|
||||||
namebuf << GetName() << "!" << kv.first;
|
|
||||||
String name = namebuf.str();
|
|
||||||
|
|
||||||
std::vector<String> path;
|
|
||||||
path.push_back("scheduled_downtimes");
|
|
||||||
path.push_back(kv.first);
|
|
||||||
|
|
||||||
AExpression::Ptr exprl;
|
|
||||||
|
|
||||||
{
|
|
||||||
ObjectLock ilock(item);
|
|
||||||
|
|
||||||
exprl = item->GetExpressionList();
|
|
||||||
}
|
|
||||||
|
|
||||||
DebugInfo di;
|
|
||||||
exprl->FindDebugInfoPath(path, di);
|
|
||||||
|
|
||||||
if (di.Path.IsEmpty())
|
|
||||||
di = item->GetDebugInfo();
|
|
||||||
|
|
||||||
ConfigItemBuilder::Ptr builder = make_shared<ConfigItemBuilder>(di);
|
|
||||||
builder->SetType("ScheduledDowntime");
|
|
||||||
builder->SetName(name);
|
|
||||||
|
|
||||||
Dictionary::Ptr scheduledDowntime = kv.second;
|
|
||||||
|
|
||||||
Array::Ptr templates = scheduledDowntime->Get("templates");
|
|
||||||
|
|
||||||
if (templates) {
|
|
||||||
ObjectLock tlock(templates);
|
|
||||||
|
|
||||||
BOOST_FOREACH(const Value& tmpl, templates) {
|
|
||||||
AExpression::Ptr atype = make_shared<AExpression>(&AExpression::OpLiteral, "ScheduledDowntime", di);
|
|
||||||
AExpression::Ptr atmpl = make_shared<AExpression>(&AExpression::OpLiteral, tmpl, di);
|
|
||||||
builder->AddExpression(make_shared<AExpression>(&AExpression::OpImport, atype, atmpl, di));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
builder->AddExpression(make_shared<AExpression>(&AExpression::OpSet, "host", make_shared<AExpression>(&AExpression::OpLiteral, GetHost()->GetName(), di), di));
|
|
||||||
builder->AddExpression(make_shared<AExpression>(&AExpression::OpSet, "service", make_shared<AExpression>(&AExpression::OpLiteral, GetShortName(), di), di));
|
|
||||||
|
|
||||||
/* Clone attributes from the scheduled downtime expression list. */
|
|
||||||
Array::Ptr sd_exprl = make_shared<Array>();
|
|
||||||
exprl->ExtractPath(path, sd_exprl);
|
|
||||||
|
|
||||||
builder->AddExpression(make_shared<AExpression>(&AExpression::OpDict, sd_exprl, true, di));
|
|
||||||
|
|
||||||
builder->SetScope(item->GetScope());
|
|
||||||
|
|
||||||
ConfigItem::Ptr scheduledDowntimeItem = builder->Compile();
|
|
||||||
scheduledDowntimeItem->Register();
|
|
||||||
DynamicObject::Ptr dobj = scheduledDowntimeItem->Commit();
|
|
||||||
dobj->OnConfigLoaded();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -100,77 +100,6 @@ void Service::RemoveNotification(const Notification::Ptr& notification)
|
|||||||
m_Notifications.erase(notification);
|
m_Notifications.erase(notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Service::UpdateSlaveNotifications(void)
|
|
||||||
{
|
|
||||||
/* Service notification descs */
|
|
||||||
Dictionary::Ptr descs = GetNotificationDescriptions();
|
|
||||||
|
|
||||||
if (!descs || descs->GetLength() == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ConfigItem::Ptr item = ConfigItem::GetObject("Service", GetName());
|
|
||||||
|
|
||||||
ObjectLock olock(descs);
|
|
||||||
|
|
||||||
BOOST_FOREACH(const Dictionary::Pair& kv, descs) {
|
|
||||||
std::ostringstream namebuf;
|
|
||||||
namebuf << GetName() << "!" << kv.first;
|
|
||||||
String name = namebuf.str();
|
|
||||||
|
|
||||||
std::vector<String> path;
|
|
||||||
path.push_back("notifications");
|
|
||||||
path.push_back(kv.first);
|
|
||||||
|
|
||||||
AExpression::Ptr exprl;
|
|
||||||
|
|
||||||
{
|
|
||||||
ObjectLock ilock(item);
|
|
||||||
|
|
||||||
exprl = item->GetExpressionList();
|
|
||||||
}
|
|
||||||
|
|
||||||
DebugInfo di;
|
|
||||||
exprl->FindDebugInfoPath(path, di);
|
|
||||||
|
|
||||||
if (di.Path.IsEmpty())
|
|
||||||
di = item->GetDebugInfo();
|
|
||||||
|
|
||||||
ConfigItemBuilder::Ptr builder = make_shared<ConfigItemBuilder>(di);
|
|
||||||
builder->SetType("Notification");
|
|
||||||
builder->SetName(name);
|
|
||||||
|
|
||||||
Dictionary::Ptr notification = kv.second;
|
|
||||||
|
|
||||||
Array::Ptr templates = notification->Get("templates");
|
|
||||||
|
|
||||||
if (templates) {
|
|
||||||
ObjectLock tlock(templates);
|
|
||||||
|
|
||||||
BOOST_FOREACH(const Value& tmpl, templates) {
|
|
||||||
AExpression::Ptr atype = make_shared<AExpression>(&AExpression::OpLiteral, "Notification", di);
|
|
||||||
AExpression::Ptr atmpl = make_shared<AExpression>(&AExpression::OpLiteral, tmpl, di);
|
|
||||||
builder->AddExpression(make_shared<AExpression>(&AExpression::OpImport, atype, atmpl, di));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
builder->AddExpression(make_shared<AExpression>(&AExpression::OpSet, "host", make_shared<AExpression>(&AExpression::OpLiteral, GetHost()->GetName(), di), di));
|
|
||||||
builder->AddExpression(make_shared<AExpression>(&AExpression::OpSet, "service", make_shared<AExpression>(&AExpression::OpLiteral, GetShortName(), di), di));
|
|
||||||
|
|
||||||
/* Clone attributes from the notification expression list. */
|
|
||||||
Array::Ptr nfc_exprl = make_shared<Array>();
|
|
||||||
exprl->ExtractPath(path, nfc_exprl);
|
|
||||||
|
|
||||||
builder->AddExpression(make_shared<AExpression>(&AExpression::OpDict, nfc_exprl, true, di));
|
|
||||||
|
|
||||||
builder->SetScope(item->GetScope());
|
|
||||||
|
|
||||||
ConfigItem::Ptr notificationItem = builder->Compile();
|
|
||||||
notificationItem->Register();
|
|
||||||
DynamicObject::Ptr dobj = notificationItem->Commit();
|
|
||||||
dobj->OnConfigLoaded();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Service::GetEnableNotifications(void) const
|
bool Service::GetEnableNotifications(void) const
|
||||||
{
|
{
|
||||||
if (!GetOverrideEnableNotifications().IsEmpty())
|
if (!GetOverrideEnableNotifications().IsEmpty())
|
||||||
|
@ -76,10 +76,6 @@ void Service::OnConfigLoaded(void)
|
|||||||
if (m_Host)
|
if (m_Host)
|
||||||
m_Host->AddService(GetSelf());
|
m_Host->AddService(GetSelf());
|
||||||
|
|
||||||
UpdateSlaveNotifications();
|
|
||||||
UpdateSlaveScheduledDowntimes();
|
|
||||||
UpdateSlaveDependencies();
|
|
||||||
|
|
||||||
SetSchedulingOffset(Utility::Random());
|
SetSchedulingOffset(Utility::Random());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,8 +220,6 @@ public:
|
|||||||
bool IsInDowntime(void) const;
|
bool IsInDowntime(void) const;
|
||||||
bool IsAcknowledged(void);
|
bool IsAcknowledged(void);
|
||||||
|
|
||||||
void UpdateSlaveScheduledDowntimes(void);
|
|
||||||
|
|
||||||
/* Comments */
|
/* Comments */
|
||||||
static int GetNextCommentID(void);
|
static int GetNextCommentID(void);
|
||||||
|
|
||||||
@ -251,8 +249,6 @@ public:
|
|||||||
|
|
||||||
void ResetNotificationNumbers(void);
|
void ResetNotificationNumbers(void);
|
||||||
|
|
||||||
void UpdateSlaveNotifications(void);
|
|
||||||
|
|
||||||
/* Event Handler */
|
/* Event Handler */
|
||||||
void ExecuteEventHandler(void);
|
void ExecuteEventHandler(void);
|
||||||
|
|
||||||
@ -284,8 +280,6 @@ public:
|
|||||||
void RemoveReverseDependency(const shared_ptr<Dependency>& dep);
|
void RemoveReverseDependency(const shared_ptr<Dependency>& dep);
|
||||||
std::set<shared_ptr<Dependency> > GetReverseDependencies(void) const;
|
std::set<shared_ptr<Dependency> > GetReverseDependencies(void) const;
|
||||||
|
|
||||||
void UpdateSlaveDependencies(void);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Start(void);
|
virtual void Start(void);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user