]> granicus.if.org Git - icinga2/commitdiff
Add module attribute for ConfigObject and set its origin
authorMichael Friedrich <michael.friedrich@netways.de>
Mon, 17 Aug 2015 14:08:57 +0000 (16:08 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Mon, 17 Aug 2015 14:08:57 +0000 (16:08 +0200)
fixes #9852

18 files changed:
lib/base/configobject.ti
lib/cli/daemonutility.cpp
lib/config/applyrule.cpp
lib/config/applyrule.hpp
lib/config/config_parser.yy
lib/config/configcompiler.cpp
lib/config/configcompiler.hpp
lib/config/configitem.cpp
lib/config/configitem.hpp
lib/config/configitembuilder.cpp
lib/config/configitembuilder.hpp
lib/config/expression.cpp
lib/config/expression.hpp
lib/config/vmops.hpp
lib/icinga/dependency-apply.cpp
lib/icinga/notification-apply.cpp
lib/icinga/scheduleddowntime-apply.cpp
lib/icinga/service-apply.cpp

index 20980762945f8f07a8d9bc2bd05923608dd9ed3e..3aa6cc79c9d05097b2267b0e73d12851813a6f5a 100644 (file)
@@ -73,6 +73,7 @@ abstract class ConfigObject : ConfigObjectBase
        };
        [config, internal, get_protected] String type (TypeNameV);
        [config] name(Zone) zone (ZoneName);
+       [config] String module;
        [config, internal, get_protected] Array::Ptr templates;
        [get_protected] bool active;
        [get_protected] bool paused {
index 49cf2c528ffa6f211b31480e28fbdba28cd3f19a..e98133387a122bd1f388ed5ca3caaf12d86bf458 100644 (file)
@@ -28,7 +28,7 @@
 
 using namespace icinga;
 
-bool ExecuteExpression(Expression *expression)
+static bool ExecuteExpression(Expression *expression)
 {
        if (!expression)
                return false;
@@ -44,7 +44,7 @@ bool ExecuteExpression(Expression *expression)
        return true;
 }
 
-void IncludeZoneDirRecursive(const String& path, bool& success)
+static void IncludeZoneDirRecursive(const String& path, const String& module, bool& success)
 {
        String zoneName = Utility::BaseName(path);
 
@@ -52,20 +52,35 @@ void IncludeZoneDirRecursive(const String& path, bool& success)
        ConfigCompiler::RegisterZoneDir("_etc", path, zoneName);
 
        std::vector<Expression *> expressions;
-       Utility::GlobRecursive(path, "*.conf", boost::bind(&ConfigCompiler::CollectIncludes, boost::ref(expressions), _1, zoneName), GlobFile);
+       Utility::GlobRecursive(path, "*.conf", boost::bind(&ConfigCompiler::CollectIncludes, boost::ref(expressions), _1, zoneName, module), GlobFile);
        DictExpression expr(expressions);
        if (!ExecuteExpression(&expr))
                success = false;
 }
 
-void IncludeNonLocalZone(const String& zonePath, bool& success)
+static void IncludeNonLocalZone(const String& zonePath, const String& module, bool& success)
 {
        String etcPath = Application::GetZonesDir() + "/" + Utility::BaseName(zonePath);
 
        if (Utility::PathExists(etcPath) || Utility::PathExists(zonePath + "/.authoritative"))
                return;
 
-       IncludeZoneDirRecursive(zonePath, success);
+       IncludeZoneDirRecursive(zonePath, module, success);
+}
+
+static void IncludeModule(const String& modulePath, bool& success)
+{
+       String moduleName = Utility::BaseName(modulePath);
+       
+       if (Utility::PathExists(modulePath + "/include.conf")) {
+               Expression *expr = ConfigCompiler::CompileFile(modulePath + "/include.conf",
+                   true, String(), moduleName);
+               
+               if (!ExecuteExpression(expr))
+                       success = false;
+                       
+               delete expr;
+       }
 }
 
 bool DaemonUtility::ValidateConfigFiles(const std::vector<std::string>& configs, const String& objectsFile)
@@ -76,7 +91,7 @@ bool DaemonUtility::ValidateConfigFiles(const std::vector<std::string>& configs,
 
        if (!configs.empty()) {
                BOOST_FOREACH(const String& configPath, configs) {
-                       Expression *expression = ConfigCompiler::CompileFile(configPath);
+                       Expression *expression = ConfigCompiler::CompileFile(configPath, true, String(), "_etc");
                        success = ExecuteExpression(expression);
                        delete expression;
                        if (!success)
@@ -90,26 +105,21 @@ bool DaemonUtility::ValidateConfigFiles(const std::vector<std::string>& configs,
 
        String zonesEtcDir = Application::GetZonesDir();
        if (!zonesEtcDir.IsEmpty() && Utility::PathExists(zonesEtcDir))
-               Utility::Glob(zonesEtcDir + "/*", boost::bind(&IncludeZoneDirRecursive, _1, boost::ref(success)), GlobDirectory);
+               Utility::Glob(zonesEtcDir + "/*", boost::bind(&IncludeZoneDirRecursive, _1, "_etc", boost::ref(success)), GlobDirectory);
 
        if (!success)
                return false;
 
        String zonesVarDir = Application::GetLocalStateDir() + "/lib/icinga2/api/zones";
        if (Utility::PathExists(zonesVarDir))
-               Utility::Glob(zonesVarDir + "/*", boost::bind(&IncludeNonLocalZone, _1, boost::ref(success)), GlobDirectory);
+               Utility::Glob(zonesVarDir + "/*", boost::bind(&IncludeNonLocalZone, _1, "_cluster", boost::ref(success)), GlobDirectory);
 
        if (!success)
                return false;
 
        String modulesVarDir = Application::GetLocalStateDir() + "/lib/icinga2/api/modules";
-       if (Utility::PathExists(modulesVarDir)) {
-               std::vector<Expression *> expressions;
-               Utility::Glob(modulesVarDir + "/*/include.conf", boost::bind(&ConfigCompiler::CollectIncludes, boost::ref(expressions), _1, ""), GlobFile);
-               DictExpression expr(expressions);
-               if (!ExecuteExpression(&expr))
-                       success = false;
-       }
+       if (Utility::PathExists(modulesVarDir))
+               Utility::Glob(modulesVarDir + "/*", boost::bind(&IncludeModule, _1, boost::ref(success)), GlobDirectory);
 
        if (!success)
                return false;
index 9909791f6958bdc2cc0db81f49e1781d385a9ebd..a0b7e5c8e9a1f978794bba920323a3f702c26902 100644 (file)
@@ -28,9 +28,9 @@ ApplyRule::RuleMap ApplyRule::m_Rules;
 ApplyRule::TypeMap ApplyRule::m_Types;
 
 ApplyRule::ApplyRule(const String& targetType, const String& name, const boost::shared_ptr<Expression>& expression,
-    const boost::shared_ptr<Expression>& filter, const String& fkvar, const String& fvvar, const boost::shared_ptr<Expression>& fterm,
+    const boost::shared_ptr<Expression>& filter, const String& module, const String& fkvar, const String& fvvar, const boost::shared_ptr<Expression>& fterm,
     const DebugInfo& di, const Dictionary::Ptr& scope)
-       : m_TargetType(targetType), m_Name(name), m_Expression(expression), m_Filter(filter), m_FKVar(fkvar),
+       : m_TargetType(targetType), m_Name(name), m_Expression(expression), m_Filter(filter), m_Module(module), m_FKVar(fkvar),
          m_FVVar(fvvar), m_FTerm(fterm), m_DebugInfo(di), m_Scope(scope), m_HasMatches(false)
 { }
 
@@ -54,6 +54,11 @@ boost::shared_ptr<Expression> ApplyRule::GetFilter(void) const
        return m_Filter;
 }
 
+String ApplyRule::GetModule(void) const
+{
+       return m_Module;
+}
+
 String ApplyRule::GetFKVar(void) const
 {
        return m_FKVar;
@@ -80,10 +85,10 @@ Dictionary::Ptr ApplyRule::GetScope(void) const
 }
 
 void ApplyRule::AddRule(const String& sourceType, const String& targetType, const String& name,
-    const boost::shared_ptr<Expression>& expression, const boost::shared_ptr<Expression>& filter, const String& fkvar,
+    const boost::shared_ptr<Expression>& expression, const boost::shared_ptr<Expression>& filter, const String& module, const String& fkvar,
     const String& fvvar, const boost::shared_ptr<Expression>& fterm, const DebugInfo& di, const Dictionary::Ptr& scope)
 {
-       m_Rules[sourceType].push_back(ApplyRule(targetType, name, expression, filter, fkvar, fvvar, fterm, di, scope));
+       m_Rules[sourceType].push_back(ApplyRule(targetType, name, expression, filter, module, fkvar, fvvar, fterm, di, scope));
 }
 
 bool ApplyRule::EvaluateFilter(ScriptFrame& frame) const
index cac23c1533209cbb45b14a8eb85d0e43d94fbcf9..db79f0244b058f23ac22ba2d7691d0c1426016f3 100644 (file)
@@ -41,6 +41,7 @@ public:
        String GetName(void) const;
        boost::shared_ptr<Expression> GetExpression(void) const;
        boost::shared_ptr<Expression> GetFilter(void) const;
+       String GetModule(void) const;
        String GetFKVar(void) const;
        String GetFVVar(void) const;
        boost::shared_ptr<Expression> GetFTerm(void) const;
@@ -52,7 +53,7 @@ public:
        bool EvaluateFilter(ScriptFrame& frame) const;
 
        static void AddRule(const String& sourceType, const String& targetType, const String& name, const boost::shared_ptr<Expression>& expression,
-           const boost::shared_ptr<Expression>& filter, const String& fkvar, const String& fvvar, const boost::shared_ptr<Expression>& fterm, const DebugInfo& di, const Dictionary::Ptr& scope);
+           const boost::shared_ptr<Expression>& filter, const String& module, const String& fkvar, const String& fvvar, const boost::shared_ptr<Expression>& fterm, const DebugInfo& di, const Dictionary::Ptr& scope);
        static std::vector<ApplyRule>& GetRules(const String& type);
 
        static void RegisterType(const String& sourceType, const std::vector<String>& targetTypes);
@@ -68,6 +69,7 @@ private:
        String m_Name;
        boost::shared_ptr<Expression> m_Expression;
        boost::shared_ptr<Expression> m_Filter;
+       String m_Module;
        String m_FKVar;
        String m_FVVar;
        boost::shared_ptr<Expression> m_FTerm;
@@ -79,7 +81,7 @@ private:
        static RuleMap m_Rules;
 
        ApplyRule(const String& targetType, const String& name, const boost::shared_ptr<Expression>& expression,
-           const boost::shared_ptr<Expression>& filter, const String& fkvar, const String& fvvar, const boost::shared_ptr<Expression>& fterm,
+           const boost::shared_ptr<Expression>& filter, const String& module, const String& fkvar, const String& fvvar, const boost::shared_ptr<Expression>& fterm,
            const DebugInfo& di, const Dictionary::Ptr& scope);
 };
 
index 7fbfc625c96f3187862d9e8a33929824115340a6..f713aefadc2e45bb3025401a34d0b87fe17da2be 100644 (file)
@@ -384,7 +384,7 @@ object:
                                BOOST_THROW_EXCEPTION(ScriptError("object rule 'ignore' is missing 'assign' for type '" + type + "'", DebugInfoRange(@2, @4)));
                }
 
-               $$ = new ObjectExpression(abstract, type, $4, filter, context->GetZone(), $5, $6, DebugInfoRange(@2, @5));
+               $$ = new ObjectExpression(abstract, type, $4, filter, context->GetZone(), context->GetModule(), $5, $6, DebugInfoRange(@2, @5));
        }
        ;
 
@@ -1017,7 +1017,7 @@ apply:
                Expression *fterm = context->m_FTerm.top();
                context->m_FTerm.pop();
 
-               $$ = new ApplyExpression(type, target, $4, filter, fkvar, fvvar, fterm, $7, $8, DebugInfoRange(@2, @7));
+               $$ = new ApplyExpression(type, target, $4, filter, context->GetModule(), fkvar, fvvar, fterm, $7, $8, DebugInfoRange(@2, @7));
        }
        ;
 
index 161319c67d12c46bcd3b2ec59df33afbfadc030e..b678b735d79a93ffe7232754f43630c065d090c4 100644 (file)
@@ -40,8 +40,10 @@ std::map<String, std::vector<ZoneFragment> > ConfigCompiler::m_ZoneDirs;
  * @param input Input stream for the configuration file.
  * @param zone The zone.
  */
-ConfigCompiler::ConfigCompiler(const String& path, std::istream *input, const String& zone)
-       : m_Path(path), m_Input(input), m_Zone(zone), m_Eof(false), m_OpenBraces(0), m_IgnoreNewlines(0)
+ConfigCompiler::ConfigCompiler(const String& path, std::istream *input,
+    const String& zone, const String& module)
+       : m_Path(path), m_Input(input), m_Zone(zone), m_Module(module),
+         m_Eof(false), m_OpenBraces(0), m_IgnoreNewlines(0)
 {
        InitializeScanner();
 }
@@ -98,9 +100,20 @@ String ConfigCompiler::GetZone(void) const
        return m_Zone;
 }
 
-void ConfigCompiler::CollectIncludes(std::vector<Expression *>& expressions, const String& file, const String& zone)
+void ConfigCompiler::SetModule(const String& module)
 {
-       expressions.push_back(CompileFile(file, true, zone));
+       m_Module = module;
+}
+
+String ConfigCompiler::GetModule(void) const
+{
+       return m_Module;
+}
+
+void ConfigCompiler::CollectIncludes(std::vector<Expression *>& expressions,
+    const String& file, const String& zone, const String& module)
+{
+       expressions.push_back(CompileFile(file, true, zone, module));
 }
 
 /**
@@ -134,7 +147,7 @@ Expression *ConfigCompiler::HandleInclude(const String& include, bool search, co
 
        std::vector<Expression *> expressions;
 
-       if (!Utility::Glob(includePath, boost::bind(&ConfigCompiler::CollectIncludes, boost::ref(expressions), _1, m_Zone), GlobFile) && includePath.FindFirstOf("*?") == String::NPos) {
+       if (!Utility::Glob(includePath, boost::bind(&ConfigCompiler::CollectIncludes, boost::ref(expressions), _1, m_Zone, m_Module), GlobFile) && includePath.FindFirstOf("*?") == String::NPos) {
                std::ostringstream msgbuf;
                msgbuf << "Include file '" + include + "' does not exist";
                BOOST_THROW_EXCEPTION(ScriptError(msgbuf.str(), debuginfo));
@@ -162,7 +175,7 @@ Expression *ConfigCompiler::HandleIncludeRecursive(const String& path, const Str
                ppath = Utility::DirName(GetPath()) + "/" + path;
 
        std::vector<Expression *> expressions;
-       Utility::GlobRecursive(ppath, pattern, boost::bind(&ConfigCompiler::CollectIncludes, boost::ref(expressions), _1, m_Zone), GlobFile);
+       Utility::GlobRecursive(ppath, pattern, boost::bind(&ConfigCompiler::CollectIncludes, boost::ref(expressions), _1, m_Zone, m_Module), GlobFile);
        return new DictExpression(expressions);
 }
 
@@ -179,7 +192,7 @@ void ConfigCompiler::HandleIncludeZone(const String& tag, const String& path, co
 
        RegisterZoneDir(tag, ppath, zoneName);
 
-       Utility::GlobRecursive(ppath, pattern, boost::bind(&ConfigCompiler::CollectIncludes, boost::ref(expressions), _1, zoneName), GlobFile);
+       Utility::GlobRecursive(ppath, pattern, boost::bind(&ConfigCompiler::CollectIncludes, boost::ref(expressions), _1, zoneName, m_Module), GlobFile);
 }
 
 /**
@@ -232,13 +245,14 @@ void ConfigCompiler::CompileHelper(void)
  * @param stream The input stream.
  * @returns Configuration items.
  */
-Expression *ConfigCompiler::CompileStream(const String& path, std::istream *stream, bool async, const String& zone)
+Expression *ConfigCompiler::CompileStream(const String& path,
+    std::istream *stream, bool async, const String& zone, const String& module)
 {
        CONTEXT("Compiling configuration stream with name '" + path + "'");
 
        stream->exceptions(std::istream::badbit);
 
-       ConfigCompiler* ctx = new ConfigCompiler(path, stream, zone);
+       ConfigCompiler* ctx = new ConfigCompiler(path, stream, zone, module);
 
        if (async) {
                boost::shared_future<boost::shared_ptr<Expression> > ftr = boost::shared_future<boost::shared_ptr<Expression> >(ctx->m_Promise.get_future());
@@ -266,7 +280,8 @@ Expression *ConfigCompiler::CompileStream(const String& path, std::istream *stre
  * @param path The path.
  * @returns Configuration items.
  */
-Expression *ConfigCompiler::CompileFile(const String& path, bool async, const String& zone)
+Expression *ConfigCompiler::CompileFile(const String& path, bool async,
+    const String& zone, const String& module)
 {
        CONTEXT("Compiling configuration file '" + path + "'");
 
@@ -282,7 +297,7 @@ Expression *ConfigCompiler::CompileFile(const String& path, bool async, const St
        Log(LogInformation, "ConfigCompiler")
            << "Compiling config file: " << path;
 
-       return CompileStream(path, stream, async, zone);
+       return CompileStream(path, stream, async, zone, module);
 }
 
 /**
@@ -292,10 +307,11 @@ Expression *ConfigCompiler::CompileFile(const String& path, bool async, const St
  * @param text The text.
  * @returns Configuration items.
  */
-Expression *ConfigCompiler::CompileText(const String& path, const String& text, bool async, const String& zone)
+Expression *ConfigCompiler::CompileText(const String& path, const String& text,
+    bool async, const String& zone, const String& module)
 {
        std::stringstream *stream = new std::stringstream(text);
-       return CompileStream(path, stream, async, zone);
+       return CompileStream(path, stream, async, zone, module);
 }
 
 /**
index 0d72b9ac2ff5bf9ef36f9e9ed9a21683c648c1bd..d1513a24d0c89a3c656a526242e7d25fc0b5e602 100644 (file)
@@ -79,14 +79,18 @@ struct ZoneFragment
 class I2_CONFIG_API ConfigCompiler
 {
 public:
-       explicit ConfigCompiler(const String& path, std::istream *input, const String& zone = String());
+       explicit ConfigCompiler(const String& path, std::istream *input,
+           const String& zone = String(), const String& module = String());
        virtual ~ConfigCompiler(void);
 
        Expression *Compile(void);
 
-       static Expression *CompileStream(const String& path, std::istream *stream, bool async = true, const String& zone = String());
-       static Expression *CompileFile(const String& path, bool async = true, const String& zone = String());
-       static Expression *CompileText(const String& path, const String& text, bool async = true, const String& zone = String());
+       static Expression *CompileStream(const String& path, std::istream *stream,
+           bool async = true, const String& zone = String(), const String& module = String());
+       static Expression *CompileFile(const String& path, bool async = true,
+           const String& zone = String(), const String& module = String());
+       static Expression *CompileText(const String& path, const String& text,
+           bool async = true, const String& zone = String(), const String& module = String());
 
        static void AddIncludeSearchDir(const String& dir);
 
@@ -94,8 +98,12 @@ public:
 
        void SetZone(const String& zone);
        String GetZone(void) const;
+       
+       void SetModule(const String& module);
+       String GetModule(void) const;
 
-       static void CollectIncludes(std::vector<Expression *>& expressions, const String& file, const String& zone);
+       static void CollectIncludes(std::vector<Expression *>& expressions,
+           const String& file, const String& zone, const String& module);
 
        /* internally used methods */
        Expression *HandleInclude(const String& include, bool search, const DebugInfo& debuginfo = DebugInfo());
@@ -117,6 +125,7 @@ private:
        String m_Path;
        std::istream *m_Input;
        String m_Zone;
+       String m_Module;
 
        void *m_Scanner;
 
index 6652cdd8ea8f065b149e37c3d6d2c86bbd72a33f..42b82fa3fb0a6d144d49447f5cf9b5e8de6fe14d 100644 (file)
@@ -62,10 +62,11 @@ ConfigItem::ConfigItem(const String& type, const String& name,
     bool abstract, const boost::shared_ptr<Expression>& exprl,
     const boost::shared_ptr<Expression>& filter,
     const DebugInfo& debuginfo, const Dictionary::Ptr& scope,
-    const String& zone)
+    const String& zone, const String& module)
        : m_Type(type), m_Name(name), m_Abstract(abstract),
          m_Expression(exprl), m_Filter(filter),
-         m_DebugInfo(debuginfo), m_Scope(scope), m_Zone(zone)
+         m_DebugInfo(debuginfo), m_Scope(scope), m_Zone(zone),
+         m_Module(module)
 {
 }
 
@@ -170,6 +171,7 @@ ConfigObject::Ptr ConfigItem::Commit(bool discard)
        dobj->SetDebugInfo(m_DebugInfo);
        dobj->SetTypeNameV(m_Type);
        dobj->SetZoneName(m_Zone);
+       dobj->SetModule(m_Module);
        dobj->SetName(m_Name);
 
        DebugHint debugHints;
index 9513df9df660e52fc9b0887b5832ad3055127604..8e98d33e4fe96761a0d09376e527d6e071f6f237 100644 (file)
@@ -42,7 +42,8 @@ public:
            const boost::shared_ptr<Expression>& exprl,
            const boost::shared_ptr<Expression>& filter,
            const DebugInfo& debuginfo,
-           const Dictionary::Ptr& scope, const String& zone);
+           const Dictionary::Ptr& scope, const String& zone,
+           const String& module);
 
        String GetType(void) const;
        String GetName(void) const;
@@ -60,8 +61,6 @@ public:
        DebugInfo GetDebugInfo(void) const;
        Dictionary::Ptr GetScope(void) const;
 
-       String GetZone(void) const;
-
        static ConfigItem::Ptr GetObject(const String& type,
            const String& name);
 
@@ -82,6 +81,7 @@ private:
        DebugInfo m_DebugInfo; /**< Debug information. */
        Dictionary::Ptr m_Scope; /**< variable scope. */
        String m_Zone; /**< The zone. */
+       String m_Module;
 
        ConfigObject::Ptr m_Object;
 
index 9cf208575d6af6e31289c22e281feb716fde4ff1..c10da1da2aebd3e7c81a7bfeb312ab0523100b16 100644 (file)
@@ -65,6 +65,11 @@ void ConfigItemBuilder::SetZone(const String& zone)
        m_Zone = zone;
 }
 
+void ConfigItemBuilder::SetModule(const String& module)
+{
+       m_Module = module;
+}
+
 void ConfigItemBuilder::AddExpression(Expression *expr)
 {
        m_Expressions.push_back(expr);
@@ -111,6 +116,6 @@ ConfigItem::Ptr ConfigItemBuilder::Compile(void)
        exprl->MakeInline();
 
        return new ConfigItem(m_Type, m_Name, m_Abstract, exprl, m_Filter,
-           m_DebugInfo, m_Scope, m_Zone);
+           m_DebugInfo, m_Scope, m_Zone, m_Module);
 }
 
index 5bc93ffdfd7e9170a7d39b9dee547c888fcf7b1e..9e11d52af07c6e83270de2ba7b48e46d7d452cef 100644 (file)
@@ -47,6 +47,7 @@ public:
        void SetAbstract(bool abstract);
        void SetScope(const Dictionary::Ptr& scope);
        void SetZone(const String& zone);
+       void SetModule(const String& module);
 
        void AddExpression(Expression *expr);
        void SetFilter(const boost::shared_ptr<Expression>& filter);
@@ -62,6 +63,7 @@ private:
        DebugInfo m_DebugInfo; /**< Debug information. */
        Dictionary::Ptr m_Scope; /**< variable scope. */
        String m_Zone; /**< The zone. */
+       String m_Module; /**< The module name. */
 };
 
 }
index f251910f97d3d13291af486235827498202e2d5f..65d910bcc4878fd43323ffc67315a80a20be31c1 100644 (file)
@@ -740,7 +740,7 @@ ExpressionResult ApplyExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhin
        CHECK_RESULT(nameres);
 
        return VMOps::NewApply(frame, m_Type, m_Target, nameres.GetValue(), m_Filter,
-           m_FKVar, m_FVVar, m_FTerm, m_ClosedVars, m_Expression, m_DebugInfo);
+           m_Module, m_FKVar, m_FVVar, m_FTerm, m_ClosedVars, m_Expression, m_DebugInfo);
 }
 
 ExpressionResult ObjectExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
@@ -758,7 +758,7 @@ ExpressionResult ObjectExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhi
        }
 
        return VMOps::NewObject(frame, m_Abstract, m_Type, name, m_Filter, m_Zone,
-           m_ClosedVars, m_Expression, m_DebugInfo);
+           m_Module, m_ClosedVars, m_Expression, m_DebugInfo);
 }
 
 ExpressionResult ForExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
index a9bc3795184e1baf4c0b16c53717451ddb8aec6b..acb9803d377f34a5cc6093bf4d7d7a765eadc0e2 100644 (file)
@@ -807,11 +807,11 @@ class I2_CONFIG_API ApplyExpression : public DebuggableExpression
 {
 public:
        ApplyExpression(const String& type, const String& target, Expression *name,
-           Expression *filter, const String& fkvar, const String& fvvar,
+           Expression *filter, const String& module, const String& fkvar, const String& fvvar,
            Expression *fterm, std::map<String, Expression *> *closedVars,
            Expression *expression, const DebugInfo& debugInfo = DebugInfo())
                : DebuggableExpression(debugInfo), m_Type(type), m_Target(target),
-                   m_Name(name), m_Filter(filter), m_FKVar(fkvar), m_FVVar(fvvar),
+                   m_Name(name), m_Filter(filter), m_Module(module), m_FKVar(fkvar), m_FVVar(fvvar),
                    m_FTerm(fterm), m_ClosedVars(closedVars), m_Expression(expression)
        { }
 
@@ -828,6 +828,7 @@ private:
        String m_Target;
        Expression *m_Name;
        boost::shared_ptr<Expression> m_Filter;
+       String m_Module;
        String m_FKVar;
        String m_FVVar;
        boost::shared_ptr<Expression> m_FTerm;
@@ -839,10 +840,10 @@ class I2_CONFIG_API ObjectExpression : public DebuggableExpression
 {
 public:
        ObjectExpression(bool abstract, const String& type, Expression *name, Expression *filter,
-           const String& zone, std::map<String, Expression *> *closedVars,
+           const String& zone, const String& module, std::map<String, Expression *> *closedVars,
            Expression *expression, const DebugInfo& debugInfo = DebugInfo())
                : DebuggableExpression(debugInfo), m_Abstract(abstract), m_Type(type),
-                 m_Name(name), m_Filter(filter), m_Zone(zone), m_ClosedVars(closedVars), m_Expression(expression)
+                 m_Name(name), m_Filter(filter), m_Zone(zone), m_Module(module), m_ClosedVars(closedVars), m_Expression(expression)
        { }
 
        ~ObjectExpression(void)
@@ -859,6 +860,7 @@ private:
        Expression *m_Name;
        boost::shared_ptr<Expression> m_Filter;
        String m_Zone;
+       String m_Module;
        std::map<String, Expression *> *m_ClosedVars;
        boost::shared_ptr<Expression> m_Expression;
 };
index 5f9d7c6053b2e781daa13697cf285450f925a913..71cddee9e412307b6b7acaf5541f5e8c8cad48e4 100644 (file)
@@ -105,17 +105,17 @@ public:
        }
 
        static inline Value NewApply(ScriptFrame& frame, const String& type, const String& target, const String& name, const boost::shared_ptr<Expression>& filter,
-               const String& fkvar, const String& fvvar, const boost::shared_ptr<Expression>& fterm, std::map<String, Expression *> *closedVars,
+               const String& module, const String& fkvar, const String& fvvar, const boost::shared_ptr<Expression>& fterm, std::map<String, Expression *> *closedVars,
                const boost::shared_ptr<Expression>& expression, const DebugInfo& debugInfo = DebugInfo())
        {
-               ApplyRule::AddRule(type, target, name, expression, filter, fkvar,
+               ApplyRule::AddRule(type, target, name, expression, filter, module, fkvar,
                    fvvar, fterm, debugInfo, EvaluateClosedVars(frame, closedVars));
 
                return Empty;
        }
 
        static inline Value NewObject(ScriptFrame& frame, bool abstract, const String& type, const String& name, const boost::shared_ptr<Expression>& filter,
-               const String& zone, std::map<String, Expression *> *closedVars, const boost::shared_ptr<Expression>& expression, const DebugInfo& debugInfo = DebugInfo())
+               const String& zone, const String& module, std::map<String, Expression *> *closedVars, const boost::shared_ptr<Expression>& expression, const DebugInfo& debugInfo = DebugInfo())
        {
                ConfigItemBuilder::Ptr item = new ConfigItemBuilder(debugInfo);
 
@@ -147,6 +147,7 @@ public:
                item->SetAbstract(abstract);
                item->SetScope(EvaluateClosedVars(frame, closedVars));
                item->SetZone(zone);
+               item->SetModule(module);
                item->SetFilter(filter);
                item->Compile()->Register();
 
index 8f650fd7a174d847d762692b7484b426e2c07daa..61635d0e1a70a19bba3368dabb955fd0f1c07143 100644 (file)
@@ -71,6 +71,8 @@ bool Dependency::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, cons
        if (!zone.IsEmpty())
                builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "zone"), OpSetLiteral, MakeLiteral(zone), di));
 
+       builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "module"), OpSetLiteral, MakeLiteral(rule.GetModule()), di));
+       
        builder->AddExpression(new OwnedExpression(rule.GetExpression()));
 
        ConfigItem::Ptr dependencyItem = builder->Compile();
index 9d46b49d71715e1096cd9a07ccdc84716bcc1ec1..61df51cb1a7ae90cd6131452b3b8bc38b4452e2a 100644 (file)
@@ -70,6 +70,8 @@ bool Notification::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, co
        if (!zone.IsEmpty())
                builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "zone"), OpSetLiteral, MakeLiteral(zone), di));
 
+       builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "module"), OpSetLiteral, MakeLiteral(rule.GetModule()), di));
+
        builder->AddExpression(new OwnedExpression(rule.GetExpression()));
 
        ConfigItem::Ptr notificationItem = builder->Compile();
index 9088d7bb1afc243e1405d34f9ada3189ba8df613..cc416b4c50d641181d92eab1a82b5f0970ede49f 100644 (file)
@@ -69,6 +69,8 @@ bool ScheduledDowntime::EvaluateApplyRuleInstance(const Checkable::Ptr& checkabl
        if (!zone.IsEmpty())
                builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "zone"), OpSetLiteral, MakeLiteral(zone), di));
 
+       builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "module"), OpSetLiteral, MakeLiteral(rule.GetModule()), di));
+
        builder->AddExpression(new OwnedExpression(rule.GetExpression()));
 
        ConfigItem::Ptr downtimeItem = builder->Compile();
index b6373c5e1ef2ebbb7ef5e7d1c87c9b48486686a1..545f0e67717158189f1a0508b1e1235d8b2875be 100644 (file)
@@ -63,6 +63,8 @@ bool Service::EvaluateApplyRuleInstance(const Host::Ptr& host, const String& nam
        if (!zone.IsEmpty())
                builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "zone"), OpSetLiteral, MakeLiteral(zone), di));
 
+       builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "module"), OpSetLiteral, MakeLiteral(rule.GetModule()), di));
+
        builder->AddExpression(new OwnedExpression(rule.GetExpression()));
 
        ConfigItem::Ptr serviceItem = builder->Compile();