diff --git a/lib/config/vmops.hpp b/lib/config/vmops.hpp index ea3098359..6d6e840b6 100644 --- a/lib/config/vmops.hpp +++ b/lib/config/vmops.hpp @@ -11,6 +11,7 @@ #include "base/debuginfo.hpp" #include "base/array.hpp" #include "base/dictionary.hpp" +#include "base/generator.hpp" #include "base/namespace.hpp" #include "base/function.hpp" #include "base/scriptglobal.hpp" @@ -18,6 +19,7 @@ #include "base/convert.hpp" #include "base/objectlock.hpp" #include +#include #include namespace icinga @@ -187,6 +189,18 @@ public: ExpressionResult res = expression->Evaluate(frame); CHECK_RESULT_LOOP(res); } + } else if (value.IsObjectType()) { + if (!fvvar.IsEmpty()) + BOOST_THROW_EXCEPTION(ScriptError("Cannot use dictionary iterator for generator.", debugInfo)); + + Generator::Ptr gen = value; + Value buf; + + while (gen->GetNext(buf)) { + frame.Locals->Set(fkvar, std::move(buf)); + ExpressionResult res = expression->Evaluate(frame); + CHECK_RESULT_LOOP(res); + } } else if (value.IsObjectType()) { if (fvvar.IsEmpty()) BOOST_THROW_EXCEPTION(ScriptError("Cannot use array iterator for dictionary.", debugInfo));