mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 05:34:48 +02:00
livestatus: custom variables return empty arrays instead of strings
livestatus queries for custom variables should return an empty list, ex: [] instead of an empty string if there are no variables. Signed-off-by: Sven Nierlein <sven@nierlein.de> refs #5746
This commit is contained in:
parent
3a7c54c3d1
commit
9ba5f30afa
@ -106,11 +106,11 @@ Value CommandsTable::CustomVariableNamesAccessor(const Value& row)
|
|||||||
vars = CompatUtility::GetCustomAttributeConfig(command);
|
vars = CompatUtility::GetCustomAttributeConfig(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vars)
|
|
||||||
return Empty;
|
|
||||||
|
|
||||||
Array::Ptr cv = new Array();
|
Array::Ptr cv = new Array();
|
||||||
|
|
||||||
|
if (!vars)
|
||||||
|
return cv;
|
||||||
|
|
||||||
{
|
{
|
||||||
ObjectLock xlock(vars);
|
ObjectLock xlock(vars);
|
||||||
for (const auto& kv : vars) {
|
for (const auto& kv : vars) {
|
||||||
@ -135,11 +135,11 @@ Value CommandsTable::CustomVariableValuesAccessor(const Value& row)
|
|||||||
vars = CompatUtility::GetCustomAttributeConfig(command);
|
vars = CompatUtility::GetCustomAttributeConfig(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vars)
|
|
||||||
return Empty;
|
|
||||||
|
|
||||||
Array::Ptr cv = new Array();
|
Array::Ptr cv = new Array();
|
||||||
|
|
||||||
|
if (!vars)
|
||||||
|
return cv;
|
||||||
|
|
||||||
{
|
{
|
||||||
ObjectLock xlock(vars);
|
ObjectLock xlock(vars);
|
||||||
for (const auto& kv : vars) {
|
for (const auto& kv : vars) {
|
||||||
@ -164,11 +164,11 @@ Value CommandsTable::CustomVariablesAccessor(const Value& row)
|
|||||||
vars = CompatUtility::GetCustomAttributeConfig(command);
|
vars = CompatUtility::GetCustomAttributeConfig(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vars)
|
|
||||||
return Empty;
|
|
||||||
|
|
||||||
Array::Ptr cv = new Array();
|
Array::Ptr cv = new Array();
|
||||||
|
|
||||||
|
if (!vars)
|
||||||
|
return cv;
|
||||||
|
|
||||||
{
|
{
|
||||||
ObjectLock xlock(vars);
|
ObjectLock xlock(vars);
|
||||||
for (const auto& kv : vars) {
|
for (const auto& kv : vars) {
|
||||||
|
@ -210,11 +210,11 @@ Value ContactsTable::CustomVariableNamesAccessor(const Value& row)
|
|||||||
vars = CompatUtility::GetCustomAttributeConfig(user);
|
vars = CompatUtility::GetCustomAttributeConfig(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vars)
|
|
||||||
return Empty;
|
|
||||||
|
|
||||||
Array::Ptr cv = new Array();
|
Array::Ptr cv = new Array();
|
||||||
|
|
||||||
|
if (!vars)
|
||||||
|
return cv;
|
||||||
|
|
||||||
ObjectLock olock(vars);
|
ObjectLock olock(vars);
|
||||||
for (const Dictionary::Pair& kv : vars) {
|
for (const Dictionary::Pair& kv : vars) {
|
||||||
cv->Add(kv.first);
|
cv->Add(kv.first);
|
||||||
@ -237,11 +237,11 @@ Value ContactsTable::CustomVariableValuesAccessor(const Value& row)
|
|||||||
vars = CompatUtility::GetCustomAttributeConfig(user);
|
vars = CompatUtility::GetCustomAttributeConfig(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vars)
|
|
||||||
return Empty;
|
|
||||||
|
|
||||||
Array::Ptr cv = new Array();
|
Array::Ptr cv = new Array();
|
||||||
|
|
||||||
|
if (!vars)
|
||||||
|
return cv;
|
||||||
|
|
||||||
ObjectLock olock(vars);
|
ObjectLock olock(vars);
|
||||||
for (const Dictionary::Pair& kv : vars) {
|
for (const Dictionary::Pair& kv : vars) {
|
||||||
if (kv.second.IsObjectType<Array>() || kv.second.IsObjectType<Dictionary>())
|
if (kv.second.IsObjectType<Array>() || kv.second.IsObjectType<Dictionary>())
|
||||||
@ -267,11 +267,11 @@ Value ContactsTable::CustomVariablesAccessor(const Value& row)
|
|||||||
vars = CompatUtility::GetCustomAttributeConfig(user);
|
vars = CompatUtility::GetCustomAttributeConfig(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vars)
|
|
||||||
return Empty;
|
|
||||||
|
|
||||||
Array::Ptr cv = new Array();
|
Array::Ptr cv = new Array();
|
||||||
|
|
||||||
|
if (!vars)
|
||||||
|
return cv;
|
||||||
|
|
||||||
ObjectLock olock(vars);
|
ObjectLock olock(vars);
|
||||||
for (const Dictionary::Pair& kv : vars) {
|
for (const Dictionary::Pair& kv : vars) {
|
||||||
Array::Ptr key_val = new Array();
|
Array::Ptr key_val = new Array();
|
||||||
|
@ -1016,11 +1016,11 @@ Value HostsTable::CustomVariableNamesAccessor(const Value& row)
|
|||||||
vars = CompatUtility::GetCustomAttributeConfig(host);
|
vars = CompatUtility::GetCustomAttributeConfig(host);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vars)
|
|
||||||
return Empty;
|
|
||||||
|
|
||||||
Array::Ptr cv = new Array();
|
Array::Ptr cv = new Array();
|
||||||
|
|
||||||
|
if (!vars)
|
||||||
|
return cv;
|
||||||
|
|
||||||
ObjectLock olock(vars);
|
ObjectLock olock(vars);
|
||||||
for (const Dictionary::Pair& kv : vars) {
|
for (const Dictionary::Pair& kv : vars) {
|
||||||
cv->Add(kv.first);
|
cv->Add(kv.first);
|
||||||
@ -1043,11 +1043,11 @@ Value HostsTable::CustomVariableValuesAccessor(const Value& row)
|
|||||||
vars = CompatUtility::GetCustomAttributeConfig(host);
|
vars = CompatUtility::GetCustomAttributeConfig(host);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vars)
|
|
||||||
return Empty;
|
|
||||||
|
|
||||||
Array::Ptr cv = new Array();
|
Array::Ptr cv = new Array();
|
||||||
|
|
||||||
|
if (!vars)
|
||||||
|
return cv;
|
||||||
|
|
||||||
ObjectLock olock(vars);
|
ObjectLock olock(vars);
|
||||||
for (const Dictionary::Pair& kv : vars) {
|
for (const Dictionary::Pair& kv : vars) {
|
||||||
if (kv.second.IsObjectType<Array>() || kv.second.IsObjectType<Dictionary>())
|
if (kv.second.IsObjectType<Array>() || kv.second.IsObjectType<Dictionary>())
|
||||||
@ -1073,11 +1073,11 @@ Value HostsTable::CustomVariablesAccessor(const Value& row)
|
|||||||
vars = CompatUtility::GetCustomAttributeConfig(host);
|
vars = CompatUtility::GetCustomAttributeConfig(host);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vars)
|
|
||||||
return Empty;
|
|
||||||
|
|
||||||
Array::Ptr cv = new Array();
|
Array::Ptr cv = new Array();
|
||||||
|
|
||||||
|
if (!vars)
|
||||||
|
return cv;
|
||||||
|
|
||||||
ObjectLock olock(vars);
|
ObjectLock olock(vars);
|
||||||
for (const Dictionary::Pair& kv : vars) {
|
for (const Dictionary::Pair& kv : vars) {
|
||||||
Array::Ptr key_val = new Array();
|
Array::Ptr key_val = new Array();
|
||||||
|
@ -1055,11 +1055,11 @@ Value ServicesTable::CustomVariableNamesAccessor(const Value& row)
|
|||||||
vars = CompatUtility::GetCustomAttributeConfig(service);
|
vars = CompatUtility::GetCustomAttributeConfig(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vars)
|
|
||||||
return Empty;
|
|
||||||
|
|
||||||
Array::Ptr cv = new Array();
|
Array::Ptr cv = new Array();
|
||||||
|
|
||||||
|
if (!vars)
|
||||||
|
return cv;
|
||||||
|
|
||||||
ObjectLock olock(vars);
|
ObjectLock olock(vars);
|
||||||
for (const Dictionary::Pair& kv : vars) {
|
for (const Dictionary::Pair& kv : vars) {
|
||||||
cv->Add(kv.first);
|
cv->Add(kv.first);
|
||||||
@ -1082,11 +1082,11 @@ Value ServicesTable::CustomVariableValuesAccessor(const Value& row)
|
|||||||
vars = CompatUtility::GetCustomAttributeConfig(service);
|
vars = CompatUtility::GetCustomAttributeConfig(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vars)
|
|
||||||
return Empty;
|
|
||||||
|
|
||||||
Array::Ptr cv = new Array();
|
Array::Ptr cv = new Array();
|
||||||
|
|
||||||
|
if (!vars)
|
||||||
|
return cv;
|
||||||
|
|
||||||
ObjectLock olock(vars);
|
ObjectLock olock(vars);
|
||||||
for (const Dictionary::Pair& kv : vars) {
|
for (const Dictionary::Pair& kv : vars) {
|
||||||
if (kv.second.IsObjectType<Array>() || kv.second.IsObjectType<Dictionary>())
|
if (kv.second.IsObjectType<Array>() || kv.second.IsObjectType<Dictionary>())
|
||||||
@ -1112,11 +1112,11 @@ Value ServicesTable::CustomVariablesAccessor(const Value& row)
|
|||||||
vars = CompatUtility::GetCustomAttributeConfig(service);
|
vars = CompatUtility::GetCustomAttributeConfig(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!vars)
|
|
||||||
return Empty;
|
|
||||||
|
|
||||||
Array::Ptr cv = new Array();
|
Array::Ptr cv = new Array();
|
||||||
|
|
||||||
|
if (!vars)
|
||||||
|
return cv;
|
||||||
|
|
||||||
ObjectLock olock(vars);
|
ObjectLock olock(vars);
|
||||||
for (const Dictionary::Pair& kv : vars) {
|
for (const Dictionary::Pair& kv : vars) {
|
||||||
Array::Ptr key_val = new Array();
|
Array::Ptr key_val = new Array();
|
||||||
|
@ -233,11 +233,11 @@ Value StatusTable::CustomVariableNamesAccessor(const Value&)
|
|||||||
{
|
{
|
||||||
Dictionary::Ptr vars = IcingaApplication::GetInstance()->GetVars();
|
Dictionary::Ptr vars = IcingaApplication::GetInstance()->GetVars();
|
||||||
|
|
||||||
if (!vars)
|
|
||||||
return Empty;
|
|
||||||
|
|
||||||
Array::Ptr cv = new Array();
|
Array::Ptr cv = new Array();
|
||||||
|
|
||||||
|
if (!vars)
|
||||||
|
return cv;
|
||||||
|
|
||||||
{
|
{
|
||||||
ObjectLock olock(vars);
|
ObjectLock olock(vars);
|
||||||
for (const auto& kv : vars) {
|
for (const auto& kv : vars) {
|
||||||
@ -252,11 +252,11 @@ Value StatusTable::CustomVariableValuesAccessor(const Value&)
|
|||||||
{
|
{
|
||||||
Dictionary::Ptr vars = IcingaApplication::GetInstance()->GetVars();
|
Dictionary::Ptr vars = IcingaApplication::GetInstance()->GetVars();
|
||||||
|
|
||||||
if (!vars)
|
|
||||||
return Empty;
|
|
||||||
|
|
||||||
Array::Ptr cv = new Array();
|
Array::Ptr cv = new Array();
|
||||||
|
|
||||||
|
if (!vars)
|
||||||
|
return cv;
|
||||||
|
|
||||||
{
|
{
|
||||||
ObjectLock olock(vars);
|
ObjectLock olock(vars);
|
||||||
for (const auto& kv : vars) {
|
for (const auto& kv : vars) {
|
||||||
@ -271,11 +271,11 @@ Value StatusTable::CustomVariablesAccessor(const Value&)
|
|||||||
{
|
{
|
||||||
Dictionary::Ptr vars = IcingaApplication::GetInstance()->GetVars();
|
Dictionary::Ptr vars = IcingaApplication::GetInstance()->GetVars();
|
||||||
|
|
||||||
if (!vars)
|
|
||||||
return Empty;
|
|
||||||
|
|
||||||
Array::Ptr cv = new Array();
|
Array::Ptr cv = new Array();
|
||||||
|
|
||||||
|
if (!vars)
|
||||||
|
return cv;
|
||||||
|
|
||||||
{
|
{
|
||||||
ObjectLock olock(vars);
|
ObjectLock olock(vars);
|
||||||
for (const auto& kv : vars) {
|
for (const auto& kv : vars) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user