CompatUtility: Fix broken custom variable dump.

Fixes #5547
This commit is contained in:
Michael Friedrich 2014-01-21 16:13:27 +01:00
parent 876587d727
commit fcec5c61a0
3 changed files with 46 additions and 44 deletions

View File

@ -276,8 +276,6 @@ void HostDbObject::OnConfigUpdate(void)
} }
/* custom variables */ /* custom variables */
Log(LogDebug, "ido", "host customvars for '" + host->GetName() + "'");
Dictionary::Ptr customvars; Dictionary::Ptr customvars;
{ {
ObjectLock olock(host); ObjectLock olock(host);
@ -285,9 +283,12 @@ void HostDbObject::OnConfigUpdate(void)
} }
if (customvars) { if (customvars) {
Log(LogDebug, "ido", "Dumping host customvars for '" + host->GetName() + "'");
ObjectLock olock (customvars); ObjectLock olock (customvars);
BOOST_FOREACH(const Dictionary::Pair& kv, customvars) { BOOST_FOREACH(const Dictionary::Pair& kv, customvars) {
if (!kv.first.IsEmpty()) {
Log(LogDebug, "db_ido", "host customvar key: '" + kv.first + "' value: '" + Convert::ToString(kv.second) + "'"); Log(LogDebug, "db_ido", "host customvar key: '" + kv.first + "' value: '" + Convert::ToString(kv.second) + "'");
Dictionary::Ptr fields3 = make_shared<Dictionary>(); Dictionary::Ptr fields3 = make_shared<Dictionary>();
@ -306,6 +307,7 @@ void HostDbObject::OnConfigUpdate(void)
OnQuery(query3); OnQuery(query3);
} }
} }
}
} }
void HostDbObject::OnStatusUpdate(void) void HostDbObject::OnStatusUpdate(void)

View File

@ -262,8 +262,6 @@ void ServiceDbObject::OnConfigUpdate(void)
} }
/* custom variables */ /* custom variables */
Log(LogDebug, "db_ido", "service customvars for '" + service->GetName() + "'");
Dictionary::Ptr customvars; Dictionary::Ptr customvars;
{ {
@ -272,9 +270,12 @@ void ServiceDbObject::OnConfigUpdate(void)
} }
if (customvars) { if (customvars) {
Log(LogDebug, "db_ido", "Dumping service customvars for '" + service->GetName() + "'");
ObjectLock olock(customvars); ObjectLock olock(customvars);
BOOST_FOREACH(const Dictionary::Pair& kv, customvars) { BOOST_FOREACH(const Dictionary::Pair& kv, customvars) {
if (!kv.first.IsEmpty()) {
Log(LogDebug, "db_ido", "service customvar key: '" + kv.first + "' value: '" + Convert::ToString(kv.second) + "'"); Log(LogDebug, "db_ido", "service customvar key: '" + kv.first + "' value: '" + Convert::ToString(kv.second) + "'");
Dictionary::Ptr fields2 = make_shared<Dictionary>(); Dictionary::Ptr fields2 = make_shared<Dictionary>();
@ -293,6 +294,7 @@ void ServiceDbObject::OnConfigUpdate(void)
OnQuery(query2); OnQuery(query2);
} }
} }
}
/* update comments and downtimes on config change */ /* update comments and downtimes on config change */
AddComments(service); AddComments(service);

View File

@ -425,19 +425,17 @@ Dictionary::Ptr CompatUtility::GetCustomVariableConfig(const DynamicObject::Ptr&
return Dictionary::Ptr(); return Dictionary::Ptr();
ObjectLock olock(custom); ObjectLock olock(custom);
String key;
Value value;
BOOST_FOREACH(const Dictionary::Pair& kv, custom) { BOOST_FOREACH(const Dictionary::Pair& kv, custom) {
if (kv.first == "notes" || if (!kv.first.IsEmpty()) {
kv.first == "action_url" || if (kv.first != "notes" &&
kv.first == "notes_url" || kv.first != "action_url" &&
kv.first == "icon_image" || kv.first != "notes_url" &&
kv.first == "icon_image_alt" || kv.first != "icon_image" &&
kv.first == "statusmap_image" || kv.first != "icon_image_alt" &&
kv.first == "2d_coords") kv.first != "statusmap_image" &&
continue; kv.first != "2d_coords")
customvars->Set(kv.first, kv.second);
customvars->Set(key, value); }
} }
return customvars; return customvars;