mirror of
https://github.com/Icinga/icinga2.git
synced 2025-09-25 10:48:20 +02:00
Load modified-attributes.conf before committing config items
refs #5235
This commit is contained in:
parent
9c00ae53b3
commit
22640444dd
@ -254,7 +254,7 @@ bool DaemonUtility::LoadConfigFiles(const std::vector<std::string>& configs,
|
|||||||
|
|
||||||
WorkQueue upq(25000, Configuration::Concurrency);
|
WorkQueue upq(25000, Configuration::Concurrency);
|
||||||
upq.SetName("DaemonUtility::LoadConfigFiles");
|
upq.SetName("DaemonUtility::LoadConfigFiles");
|
||||||
bool result = ConfigItem::CommitItems(ascope.GetContext(), upq, newItems);
|
bool result = ConfigItem::CommitItems(ascope.GetContext(), upq, newItems, false, true);
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
ConfigCompilerContext::GetInstance()->CancelObjectsFile();
|
ConfigCompilerContext::GetInstance()->CancelObjectsFile();
|
||||||
|
@ -592,11 +592,28 @@ bool ConfigItem::CommitNewItems(const ActivationContext::Ptr& context, WorkQueue
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConfigItem::CommitItems(const ActivationContext::Ptr& context, WorkQueue& upq, std::vector<ConfigItem::Ptr>& newItems, bool silent)
|
bool ConfigItem::CommitItems(const ActivationContext::Ptr& context, WorkQueue& upq, std::vector<ConfigItem::Ptr>& newItems,
|
||||||
|
bool silent, bool withModAttrs)
|
||||||
{
|
{
|
||||||
if (!silent)
|
if (!silent)
|
||||||
Log(LogInformation, "ConfigItem", "Committing config item(s).");
|
Log(LogInformation, "ConfigItem", "Committing config item(s).");
|
||||||
|
|
||||||
|
if (withModAttrs) {
|
||||||
|
/* restore modified attributes */
|
||||||
|
if (Utility::PathExists(Configuration::ModAttrPath)) {
|
||||||
|
std::unique_ptr<Expression> expression = ConfigCompiler::CompileFile(Configuration::ModAttrPath);
|
||||||
|
|
||||||
|
if (expression) {
|
||||||
|
try {
|
||||||
|
ScriptFrame frame(true);
|
||||||
|
expression->Evaluate(frame);
|
||||||
|
} catch (const std::exception& ex) {
|
||||||
|
Log(LogCritical, "config", DiagnosticInformation(ex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!CommitNewItems(context, upq, newItems)) {
|
if (!CommitNewItems(context, upq, newItems)) {
|
||||||
upq.ReportExceptions("config");
|
upq.ReportExceptions("config");
|
||||||
|
|
||||||
|
@ -52,7 +52,8 @@ public:
|
|||||||
static ConfigItem::Ptr GetByTypeAndName(const Type::Ptr& type,
|
static ConfigItem::Ptr GetByTypeAndName(const Type::Ptr& type,
|
||||||
const String& name);
|
const String& name);
|
||||||
|
|
||||||
static bool CommitItems(const ActivationContext::Ptr& context, WorkQueue& upq, std::vector<ConfigItem::Ptr>& newItems, bool silent = false);
|
static bool CommitItems(const ActivationContext::Ptr& context, WorkQueue& upq, std::vector<ConfigItem::Ptr>& newItems,
|
||||||
|
bool silent = false, bool withModAttrs = false);
|
||||||
static bool ActivateItems(const std::vector<ConfigItem::Ptr>& newItems, bool runtimeCreated = false,
|
static bool ActivateItems(const std::vector<ConfigItem::Ptr>& newItems, bool runtimeCreated = false,
|
||||||
bool mainConfigActivation = false, bool withModAttrs = false, const Value& cookie = Empty);
|
bool mainConfigActivation = false, bool withModAttrs = false, const Value& cookie = Empty);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user