mirror of https://github.com/Icinga/icinga2.git
parent
876587d727
commit
fcec5c61a0
|
@ -276,8 +276,6 @@ void HostDbObject::OnConfigUpdate(void)
|
|||
}
|
||||
|
||||
/* custom variables */
|
||||
Log(LogDebug, "ido", "host customvars for '" + host->GetName() + "'");
|
||||
|
||||
Dictionary::Ptr customvars;
|
||||
{
|
||||
ObjectLock olock(host);
|
||||
|
@ -285,25 +283,29 @@ void HostDbObject::OnConfigUpdate(void)
|
|||
}
|
||||
|
||||
if (customvars) {
|
||||
Log(LogDebug, "ido", "Dumping host customvars for '" + host->GetName() + "'");
|
||||
|
||||
ObjectLock olock (customvars);
|
||||
|
||||
BOOST_FOREACH(const Dictionary::Pair& kv, customvars) {
|
||||
Log(LogDebug, "db_ido", "host customvar key: '" + kv.first + "' value: '" + Convert::ToString(kv.second) + "'");
|
||||
if (!kv.first.IsEmpty()) {
|
||||
Log(LogDebug, "db_ido", "host customvar key: '" + kv.first + "' value: '" + Convert::ToString(kv.second) + "'");
|
||||
|
||||
Dictionary::Ptr fields3 = make_shared<Dictionary>();
|
||||
fields3->Set("varname", Convert::ToString(kv.first));
|
||||
fields3->Set("varvalue", Convert::ToString(kv.second));
|
||||
fields3->Set("config_type", 1);
|
||||
fields3->Set("has_been_modified", 0);
|
||||
fields3->Set("object_id", host);
|
||||
fields3->Set("instance_id", 0); /* DbConnection class fills in real ID */
|
||||
Dictionary::Ptr fields3 = make_shared<Dictionary>();
|
||||
fields3->Set("varname", Convert::ToString(kv.first));
|
||||
fields3->Set("varvalue", Convert::ToString(kv.second));
|
||||
fields3->Set("config_type", 1);
|
||||
fields3->Set("has_been_modified", 0);
|
||||
fields3->Set("object_id", host);
|
||||
fields3->Set("instance_id", 0); /* DbConnection class fills in real ID */
|
||||
|
||||
DbQuery query3;
|
||||
query3.Table = "customvariables";
|
||||
query3.Type = DbQueryInsert;
|
||||
query3.Category = DbCatConfig;
|
||||
query3.Fields = fields3;
|
||||
OnQuery(query3);
|
||||
DbQuery query3;
|
||||
query3.Table = "customvariables";
|
||||
query3.Type = DbQueryInsert;
|
||||
query3.Category = DbCatConfig;
|
||||
query3.Fields = fields3;
|
||||
OnQuery(query3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -262,8 +262,6 @@ void ServiceDbObject::OnConfigUpdate(void)
|
|||
}
|
||||
|
||||
/* custom variables */
|
||||
Log(LogDebug, "db_ido", "service customvars for '" + service->GetName() + "'");
|
||||
|
||||
Dictionary::Ptr customvars;
|
||||
|
||||
{
|
||||
|
@ -272,25 +270,29 @@ void ServiceDbObject::OnConfigUpdate(void)
|
|||
}
|
||||
|
||||
if (customvars) {
|
||||
Log(LogDebug, "db_ido", "Dumping service customvars for '" + service->GetName() + "'");
|
||||
|
||||
ObjectLock olock(customvars);
|
||||
|
||||
BOOST_FOREACH(const Dictionary::Pair& kv, customvars) {
|
||||
Log(LogDebug, "db_ido", "service customvar key: '" + kv.first + "' value: '" + Convert::ToString(kv.second) + "'");
|
||||
if (!kv.first.IsEmpty()) {
|
||||
Log(LogDebug, "db_ido", "service customvar key: '" + kv.first + "' value: '" + Convert::ToString(kv.second) + "'");
|
||||
|
||||
Dictionary::Ptr fields2 = make_shared<Dictionary>();
|
||||
fields2->Set("varname", Convert::ToString(kv.first));
|
||||
fields2->Set("varvalue", Convert::ToString(kv.second));
|
||||
fields2->Set("config_type", 1);
|
||||
fields2->Set("has_been_modified", 0);
|
||||
fields2->Set("object_id", service);
|
||||
fields2->Set("instance_id", 0); /* DbConnection class fills in real ID */
|
||||
Dictionary::Ptr fields2 = make_shared<Dictionary>();
|
||||
fields2->Set("varname", Convert::ToString(kv.first));
|
||||
fields2->Set("varvalue", Convert::ToString(kv.second));
|
||||
fields2->Set("config_type", 1);
|
||||
fields2->Set("has_been_modified", 0);
|
||||
fields2->Set("object_id", service);
|
||||
fields2->Set("instance_id", 0); /* DbConnection class fills in real ID */
|
||||
|
||||
DbQuery query2;
|
||||
query2.Table = "customvariables";
|
||||
query2.Type = DbQueryInsert;
|
||||
query2.Category = DbCatConfig;
|
||||
query2.Fields = fields2;
|
||||
OnQuery(query2);
|
||||
DbQuery query2;
|
||||
query2.Table = "customvariables";
|
||||
query2.Type = DbQueryInsert;
|
||||
query2.Category = DbCatConfig;
|
||||
query2.Fields = fields2;
|
||||
OnQuery(query2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -425,19 +425,17 @@ Dictionary::Ptr CompatUtility::GetCustomVariableConfig(const DynamicObject::Ptr&
|
|||
return Dictionary::Ptr();
|
||||
|
||||
ObjectLock olock(custom);
|
||||
String key;
|
||||
Value value;
|
||||
BOOST_FOREACH(const Dictionary::Pair& kv, custom) {
|
||||
if (kv.first == "notes" ||
|
||||
kv.first == "action_url" ||
|
||||
kv.first == "notes_url" ||
|
||||
kv.first == "icon_image" ||
|
||||
kv.first == "icon_image_alt" ||
|
||||
kv.first == "statusmap_image" ||
|
||||
kv.first == "2d_coords")
|
||||
continue;
|
||||
|
||||
customvars->Set(key, value);
|
||||
if (!kv.first.IsEmpty()) {
|
||||
if (kv.first != "notes" &&
|
||||
kv.first != "action_url" &&
|
||||
kv.first != "notes_url" &&
|
||||
kv.first != "icon_image" &&
|
||||
kv.first != "icon_image_alt" &&
|
||||
kv.first != "statusmap_image" &&
|
||||
kv.first != "2d_coords")
|
||||
customvars->Set(kv.first, kv.second);
|
||||
}
|
||||
}
|
||||
|
||||
return customvars;
|
||||
|
|
Loading…
Reference in New Issue