From: Gunnar Beutner Date: Wed, 11 Mar 2015 15:06:58 +0000 (+0100) Subject: Make sure that 'icinga2 console' serializes temporary attributes (rather than just... X-Git-Tag: v2.4.0~847 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5e39fbbdf5862bcbc880b8d28f7a3864afb962f0;p=icinga2 Make sure that 'icinga2 console' serializes temporary attributes (rather than just config + state) fixes #8690 --- diff --git a/lib/base/type.hpp b/lib/base/type.hpp index fdd76d593..d1b2adb27 100644 --- a/lib/base/type.hpp +++ b/lib/base/type.hpp @@ -30,11 +30,13 @@ namespace icinga { +/* keep this in sync with tools/mkclass/classcompiler.hpp */ enum FieldAttribute { - FAConfig = 1, - FAState = 2, - FAInternal = 32 + FAEphemeral = 1, + FAConfig = 2, + FAState = 4, + FAInternal = 64, }; class Type; diff --git a/lib/livestatus/livestatusquery.cpp b/lib/livestatus/livestatusquery.cpp index 9d904805e..053610bdc 100644 --- a/lib/livestatus/livestatusquery.cpp +++ b/lib/livestatus/livestatusquery.cpp @@ -655,7 +655,7 @@ void LivestatusQuery::ExecuteScriptHelper(const Stream::Ptr& stream) throw; } delete expr; - SendResponse(stream, LivestatusErrorOK, JsonEncode(Serialize(result, FAState | FAConfig), true)); + SendResponse(stream, LivestatusErrorOK, JsonEncode(Serialize(result, FAEphemeral | FAState | FAConfig), true)); } void LivestatusQuery::ExecuteErrorHelper(const Stream::Ptr& stream) diff --git a/tools/mkclass/class_parser.yy b/tools/mkclass/class_parser.yy index 59e9147d3..559a9b2c5 100644 --- a/tools/mkclass/class_parser.yy +++ b/tools/mkclass/class_parser.yy @@ -256,6 +256,9 @@ class_field: field_attribute_list identifier identifier alternative_name_specifi field->Attributes = $1; + if ((field->Attributes & (FAConfig | FAState)) == 0) + field->Attributes |= FAEphemeral; + field->Type = $2; std::free($2); diff --git a/tools/mkclass/classcompiler.hpp b/tools/mkclass/classcompiler.hpp index 28df74c00..bb53c745a 100644 --- a/tools/mkclass/classcompiler.hpp +++ b/tools/mkclass/classcompiler.hpp @@ -55,16 +55,18 @@ struct FieldAccessor { } }; +/* keep this in sync with lib/base/type.hpp */ enum FieldAttribute { - FAConfig = 1, - FAState = 2, - FAEnum = 4, - FAGetProtected = 8, - FASetProtected = 16, - FAInternal = 32, - FANoStorage = 64, - FALoadDependency = 128 + FAEphemeral = 1, + FAConfig = 2, + FAState = 4, + FAEnum = 8, + FAGetProtected = 16, + FASetProtected = 32, + FAInternal = 64, + FANoStorage = 128, + FALoadDependency = 256 }; struct Field