]> granicus.if.org Git - icinga2/commitdiff
Rename config/modules to config/packages
authorMichael Friedrich <michael.friedrich@netways.de>
Fri, 28 Aug 2015 15:58:29 +0000 (17:58 +0200)
committerMichael Friedrich <michael.friedrich@gmail.com>
Tue, 1 Sep 2015 18:09:04 +0000 (20:09 +0200)
fixes #9953

26 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
lib/remote/CMakeLists.txt
lib/remote/configfileshandler.cpp
lib/remote/configobjectutility.cpp
lib/remote/configpackageshandler.cpp [moved from lib/remote/configmoduleshandler.cpp with 69% similarity]
lib/remote/configpackageshandler.hpp [moved from lib/remote/configmoduleshandler.hpp with 94% similarity]
lib/remote/configpackageutility.cpp [moved from lib/remote/configmoduleutility.cpp with 60% similarity]
lib/remote/configpackageutility.hpp [moved from lib/remote/configmoduleutility.hpp with 69% similarity]
lib/remote/configstageshandler.cpp

index e3c6f857eec6f23d0eff5690bfc76fbfc1789dd6..b7f60cb0d0f9aae50dafd5308498dd0fe1b7178a 100644 (file)
@@ -79,7 +79,7 @@ abstract class ConfigObject : ConfigObjectBase
        };
        [config, internal, get_protected] String type (TypeNameV);
        [config] name(Zone) zone (ZoneName);
-       [config] String module;
+       [config] String package;
        [config, internal, get_protected] Array::Ptr templates;
        [get_protected] bool active;
        [get_protected] bool paused {
index 8068a7331f0fb815531e72092016f658ef4559e9..912c70848603312aea1dc7c606c0faeb5051a7f3 100644 (file)
@@ -44,7 +44,7 @@ static bool ExecuteExpression(Expression *expression)
        return true;
 }
 
-static void IncludeZoneDirRecursive(const String& path, const String& module, bool& success)
+static void IncludeZoneDirRecursive(const String& path, const String& package, bool& success)
 {
        String zoneName = Utility::BaseName(path);
 
@@ -52,29 +52,29 @@ static void IncludeZoneDirRecursive(const String& path, const String& module, bo
        ConfigCompiler::RegisterZoneDir("_etc", path, zoneName);
 
        std::vector<Expression *> expressions;
-       Utility::GlobRecursive(path, "*.conf", boost::bind(&ConfigCompiler::CollectIncludes, boost::ref(expressions), _1, zoneName, module), GlobFile);
+       Utility::GlobRecursive(path, "*.conf", boost::bind(&ConfigCompiler::CollectIncludes, boost::ref(expressions), _1, zoneName, package), GlobFile);
        DictExpression expr(expressions);
        if (!ExecuteExpression(&expr))
                success = false;
 }
 
-static void IncludeNonLocalZone(const String& zonePath, const String& module, bool& success)
+static void IncludeNonLocalZone(const String& zonePath, const String& package, bool& success)
 {
        String etcPath = Application::GetZonesDir() + "/" + Utility::BaseName(zonePath);
 
        if (Utility::PathExists(etcPath) || Utility::PathExists(zonePath + "/.authoritative"))
                return;
 
-       IncludeZoneDirRecursive(zonePath, module, success);
+       IncludeZoneDirRecursive(zonePath, package, success);
 }
 
-static void IncludeModule(const String& modulePath, bool& success)
+static void IncludePackage(const String& packagePath, bool& success)
 {
-       String moduleName = Utility::BaseName(modulePath);
+       String packageName = Utility::BaseName(packagePath);
        
-       if (Utility::PathExists(modulePath + "/include.conf")) {
-               Expression *expr = ConfigCompiler::CompileFile(modulePath + "/include.conf",
-                   String(), moduleName);
+       if (Utility::PathExists(packagePath + "/include.conf")) {
+               Expression *expr = ConfigCompiler::CompileFile(packagePath + "/include.conf",
+                   String(), packageName);
                
                if (!ExecuteExpression(expr))
                        success = false;
@@ -117,9 +117,9 @@ bool DaemonUtility::ValidateConfigFiles(const std::vector<std::string>& configs,
        if (!success)
                return false;
 
-       String modulesVarDir = Application::GetLocalStateDir() + "/lib/icinga2/api/modules";
-       if (Utility::PathExists(modulesVarDir))
-               Utility::Glob(modulesVarDir + "/*", boost::bind(&IncludeModule, _1, boost::ref(success)), GlobDirectory);
+       String packagesVarDir = Application::GetLocalStateDir() + "/lib/icinga2/api/packages";
+       if (Utility::PathExists(packagesVarDir))
+               Utility::Glob(packagesVarDir + "/*", boost::bind(&IncludePackage, _1, boost::ref(success)), GlobDirectory);
 
        if (!success)
                return false;
index a0b7e5c8e9a1f978794bba920323a3f702c26902..ad408e2989ec6f7e2ce23259215170ba7a9e2822 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& module, const String& fkvar, const String& fvvar, const boost::shared_ptr<Expression>& fterm,
+    const boost::shared_ptr<Expression>& filter, const String& package, 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_Module(module), m_FKVar(fkvar),
+       : m_TargetType(targetType), m_Name(name), m_Expression(expression), m_Filter(filter), m_Package(package), m_FKVar(fkvar),
          m_FVVar(fvvar), m_FTerm(fterm), m_DebugInfo(di), m_Scope(scope), m_HasMatches(false)
 { }
 
@@ -54,9 +54,9 @@ boost::shared_ptr<Expression> ApplyRule::GetFilter(void) const
        return m_Filter;
 }
 
-String ApplyRule::GetModule(void) const
+String ApplyRule::GetPackage(void) const
 {
-       return m_Module;
+       return m_Package;
 }
 
 String ApplyRule::GetFKVar(void) const
@@ -85,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& module, const String& fkvar,
+    const boost::shared_ptr<Expression>& expression, const boost::shared_ptr<Expression>& filter, const String& package, 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, module, fkvar, fvvar, fterm, di, scope));
+       m_Rules[sourceType].push_back(ApplyRule(targetType, name, expression, filter, package, fkvar, fvvar, fterm, di, scope));
 }
 
 bool ApplyRule::EvaluateFilter(ScriptFrame& frame) const
index db79f0244b058f23ac22ba2d7691d0c1426016f3..83f0842a4a495910c31ba9f773bf180a59a6b460 100644 (file)
@@ -41,7 +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 GetPackage(void) const;
        String GetFKVar(void) const;
        String GetFVVar(void) const;
        boost::shared_ptr<Expression> GetFTerm(void) const;
@@ -53,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& module, 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& package, 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);
@@ -69,7 +69,7 @@ private:
        String m_Name;
        boost::shared_ptr<Expression> m_Expression;
        boost::shared_ptr<Expression> m_Filter;
-       String m_Module;
+       String m_Package;
        String m_FKVar;
        String m_FVVar;
        boost::shared_ptr<Expression> m_FTerm;
@@ -81,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& module, const String& fkvar, const String& fvvar, const boost::shared_ptr<Expression>& fterm,
+           const boost::shared_ptr<Expression>& filter, const String& package, const String& fkvar, const String& fvvar, const boost::shared_ptr<Expression>& fterm,
            const DebugInfo& di, const Dictionary::Ptr& scope);
 };
 
index 532a408a12abf23ebb9845a243a416bca9be704f..120a89f82e177572792ee7c8895c1e0cbdc3d64b 100644 (file)
@@ -378,7 +378,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(), context->GetModule(), $5, $6, DebugInfoRange(@2, @5));
+               $$ = new ObjectExpression(abstract, type, $4, filter, context->GetZone(), context->GetPackage(), $5, $6, DebugInfoRange(@2, @5));
        }
        ;
 
@@ -1015,7 +1015,7 @@ apply:
                Expression *fterm = context->m_FTerm.top();
                context->m_FTerm.pop();
 
-               $$ = new ApplyExpression(type, target, $4, filter, context->GetModule(), fkvar, fvvar, fterm, $7, $8, DebugInfoRange(@2, @7));
+               $$ = new ApplyExpression(type, target, $4, filter, context->GetPackage(), fkvar, fvvar, fterm, $7, $8, DebugInfoRange(@2, @7));
        }
        ;
 
index 3deb93f503ed2d7c2c282f064cfc5a6f686a75dc..0be38a9ccf2310d4a49188f7730b30837a33dc95 100644 (file)
@@ -42,8 +42,8 @@ std::map<String, std::vector<ZoneFragment> > ConfigCompiler::m_ZoneDirs;
  * @param zone The zone.
  */
 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),
+    const String& zone, const String& package)
+       : m_Path(path), m_Input(input), m_Zone(zone), m_Package(package),
          m_Eof(false), m_OpenBraces(0), m_IgnoreNewlines(0)
 {
        InitializeScanner();
@@ -100,20 +100,20 @@ String ConfigCompiler::GetZone(void) const
        return m_Zone;
 }
 
-void ConfigCompiler::SetModule(const String& module)
+void ConfigCompiler::SetPackage(const String& package)
 {
-       m_Module = module;
+       m_Package = package;
 }
 
-String ConfigCompiler::GetModule(void) const
+String ConfigCompiler::GetPackage(void) const
 {
-       return m_Module;
+       return m_Package;
 }
 
 void ConfigCompiler::CollectIncludes(std::vector<Expression *>& expressions,
-    const String& file, const String& zone, const String& module)
+    const String& file, const String& zone, const String& package)
 {
-       expressions.push_back(CompileFile(file, zone, module));
+       expressions.push_back(CompileFile(file, zone, package));
 }
 
 /**
@@ -147,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, m_Module), GlobFile) && includePath.FindFirstOf("*?") == String::NPos) {
+       if (!Utility::Glob(includePath, boost::bind(&ConfigCompiler::CollectIncludes, boost::ref(expressions), _1, m_Zone, m_Package), GlobFile) && includePath.FindFirstOf("*?") == String::NPos) {
                std::ostringstream msgbuf;
                msgbuf << "Include file '" + include + "' does not exist";
                BOOST_THROW_EXCEPTION(ScriptError(msgbuf.str(), debuginfo));
@@ -175,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, m_Module), GlobFile);
+       Utility::GlobRecursive(ppath, pattern, boost::bind(&ConfigCompiler::CollectIncludes, boost::ref(expressions), _1, m_Zone, m_Package), GlobFile);
        return new DictExpression(expressions);
 }
 
@@ -192,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, m_Module), GlobFile);
+       Utility::GlobRecursive(ppath, pattern, boost::bind(&ConfigCompiler::CollectIncludes, boost::ref(expressions), _1, zoneName, m_Package), GlobFile);
 }
 
 /**
@@ -225,13 +225,13 @@ Expression *ConfigCompiler::HandleIncludeZones(const String& tag, const String&
  * @returns Configuration items.
  */
 Expression *ConfigCompiler::CompileStream(const String& path,
-    std::istream *stream, const String& zone, const String& module)
+    std::istream *stream, const String& zone, const String& package)
 {
        CONTEXT("Compiling configuration stream with name '" + path + "'");
 
        stream->exceptions(std::istream::badbit);
 
-       ConfigCompiler ctx(path, stream, zone, module);
+       ConfigCompiler ctx(path, stream, zone, package);
 
        try {
                return ctx.Compile();
@@ -249,7 +249,7 @@ Expression *ConfigCompiler::CompileStream(const String& path,
  * @returns Configuration items.
  */
 Expression *ConfigCompiler::CompileFile(const String& path, const String& zone,
-    const String& module)
+    const String& package)
 {
        CONTEXT("Compiling configuration file '" + path + "'");
 
@@ -264,7 +264,7 @@ Expression *ConfigCompiler::CompileFile(const String& path, const String& zone,
        Log(LogInformation, "ConfigCompiler")
            << "Compiling config file: " << path;
 
-       return CompileStream(path, &stream, zone, module);
+       return CompileStream(path, &stream, zone, package);
 }
 
 /**
@@ -275,10 +275,10 @@ Expression *ConfigCompiler::CompileFile(const String& path, const String& zone,
  * @returns Configuration items.
  */
 Expression *ConfigCompiler::CompileText(const String& path, const String& text,
-    const String& zone, const String& module)
+    const String& zone, const String& package)
 {
        std::stringstream stream(text);
-       return CompileStream(path, &stream, zone, module);
+       return CompileStream(path, &stream, zone, package);
 }
 
 /**
index 63f6e0ed8475c82ae5e00851206fd39d1636de36..85cb6cceddc2534734afe96651ce4a27d609492d 100644 (file)
@@ -80,17 +80,17 @@ class I2_CONFIG_API ConfigCompiler
 {
 public:
        explicit ConfigCompiler(const String& path, std::istream *input,
-           const String& zone = String(), const String& module = String());
+           const String& zone = String(), const String& package = String());
        virtual ~ConfigCompiler(void);
 
        Expression *Compile(void);
 
        static Expression *CompileStream(const String& path, std::istream *stream,
-           const String& zone = String(), const String& module = String());
+           const String& zone = String(), const String& package = String());
        static Expression *CompileFile(const String& path, const String& zone = String(),
-           const String& module = String());
+           const String& package = String());
        static Expression *CompileText(const String& path, const String& text,
-           const String& zone = String(), const String& module = String());
+           const String& zone = String(), const String& package = String());
 
        static void AddIncludeSearchDir(const String& dir);
 
@@ -99,11 +99,11 @@ public:
        void SetZone(const String& zone);
        String GetZone(void) const;
        
-       void SetModule(const String& module);
-       String GetModule(void) const;
+       void SetPackage(const String& package);
+       String GetPackage(void) const;
 
        static void CollectIncludes(std::vector<Expression *>& expressions,
-           const String& file, const String& zone, const String& module);
+           const String& file, const String& zone, const String& package);
 
        /* internally used methods */
        Expression *HandleInclude(const String& include, bool search, const DebugInfo& debuginfo = DebugInfo());
@@ -124,7 +124,7 @@ private:
        String m_Path;
        std::istream *m_Input;
        String m_Zone;
-       String m_Module;
+       String m_Package;
 
        void *m_Scanner;
 
index c1b3f6cd90b7a1d2ded94e69511fe832435781e4..bd80809200abbe478427b16230b6e2776e51dfe4 100644 (file)
@@ -62,11 +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& module)
+    const String& zone, const String& package)
        : 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_Module(module)
+         m_Package(package)
 {
 }
 
@@ -171,7 +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->SetPackage(m_Package);
        dobj->SetName(m_Name);
 
        DebugHint debugHints;
index 8e98d33e4fe96761a0d09376e527d6e071f6f237..b69b828c469806f251147d511c81796c1d3ace6e 100644 (file)
@@ -43,7 +43,7 @@ public:
            const boost::shared_ptr<Expression>& filter,
            const DebugInfo& debuginfo,
            const Dictionary::Ptr& scope, const String& zone,
-           const String& module);
+           const String& package);
 
        String GetType(void) const;
        String GetName(void) const;
@@ -81,7 +81,7 @@ private:
        DebugInfo m_DebugInfo; /**< Debug information. */
        Dictionary::Ptr m_Scope; /**< variable scope. */
        String m_Zone; /**< The zone. */
-       String m_Module;
+       String m_Package;
 
        ConfigObject::Ptr m_Object;
 
index c10da1da2aebd3e7c81a7bfeb312ab0523100b16..00405b3827d7c3fcfcc8cf3b77d22d9f97466f84 100644 (file)
@@ -65,9 +65,9 @@ void ConfigItemBuilder::SetZone(const String& zone)
        m_Zone = zone;
 }
 
-void ConfigItemBuilder::SetModule(const String& module)
+void ConfigItemBuilder::SetPackage(const String& package)
 {
-       m_Module = module;
+       m_Package = package;
 }
 
 void ConfigItemBuilder::AddExpression(Expression *expr)
@@ -116,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_Module);
+           m_DebugInfo, m_Scope, m_Zone, m_Package);
 }
 
index 9e11d52af07c6e83270de2ba7b48e46d7d452cef..318bcaa31994d68a4fe9c272d0c8fe0681c4d4cf 100644 (file)
@@ -47,7 +47,7 @@ public:
        void SetAbstract(bool abstract);
        void SetScope(const Dictionary::Ptr& scope);
        void SetZone(const String& zone);
-       void SetModule(const String& module);
+       void SetPackage(const String& package);
 
        void AddExpression(Expression *expr);
        void SetFilter(const boost::shared_ptr<Expression>& filter);
@@ -63,7 +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. */
+       String m_Package; /**< The package name. */
 };
 
 }
index 59db8449660e800c3c86a709f073e957ae25b6eb..fcee207770c1848c4df2c5c3f9fbef0db26fd6a9 100644 (file)
@@ -749,7 +749,7 @@ ExpressionResult ApplyExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhin
        CHECK_RESULT(nameres);
 
        return VMOps::NewApply(frame, m_Type, m_Target, nameres.GetValue(), m_Filter,
-           m_Module, m_FKVar, m_FVVar, m_FTerm, m_ClosedVars, m_Expression, m_DebugInfo);
+           m_Package, m_FKVar, m_FVVar, m_FTerm, m_ClosedVars, m_Expression, m_DebugInfo);
 }
 
 ExpressionResult ObjectExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
@@ -767,7 +767,7 @@ ExpressionResult ObjectExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhi
        }
 
        return VMOps::NewObject(frame, m_Abstract, m_Type, name, m_Filter, m_Zone,
-           m_Module, m_ClosedVars, m_Expression, m_DebugInfo);
+           m_Package, m_ClosedVars, m_Expression, m_DebugInfo);
 }
 
 ExpressionResult ForExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
index 202c4bf65fda511714502f5b37c130b2ec4d6dd0..adb96bc1a6a13894e434d42d0dc70683d729e478 100644 (file)
@@ -803,11 +803,11 @@ class I2_CONFIG_API ApplyExpression : public DebuggableExpression
 {
 public:
        ApplyExpression(const String& type, const String& target, Expression *name,
-           Expression *filter, const String& module, const String& fkvar, const String& fvvar,
+           Expression *filter, const String& package, 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_Module(module), m_FKVar(fkvar), m_FVVar(fvvar),
+                   m_Name(name), m_Filter(filter), m_Package(package), m_FKVar(fkvar), m_FVVar(fvvar),
                    m_FTerm(fterm), m_ClosedVars(closedVars), m_Expression(expression)
        { }
 
@@ -824,7 +824,7 @@ private:
        String m_Target;
        Expression *m_Name;
        boost::shared_ptr<Expression> m_Filter;
-       String m_Module;
+       String m_Package;
        String m_FKVar;
        String m_FVVar;
        boost::shared_ptr<Expression> m_FTerm;
@@ -836,10 +836,10 @@ class I2_CONFIG_API ObjectExpression : public DebuggableExpression
 {
 public:
        ObjectExpression(bool abstract, const String& type, Expression *name, Expression *filter,
-           const String& zone, const String& module, std::map<String, Expression *> *closedVars,
+           const String& zone, const String& package, 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_Module(module), m_ClosedVars(closedVars), m_Expression(expression)
+                 m_Name(name), m_Filter(filter), m_Zone(zone), m_Package(package), m_ClosedVars(closedVars), m_Expression(expression)
        { }
 
        ~ObjectExpression(void)
@@ -856,7 +856,7 @@ private:
        Expression *m_Name;
        boost::shared_ptr<Expression> m_Filter;
        String m_Zone;
-       String m_Module;
+       String m_Package;
        std::map<String, Expression *> *m_ClosedVars;
        boost::shared_ptr<Expression> m_Expression;
 };
index 71cddee9e412307b6b7acaf5541f5e8c8cad48e4..f342ac0c4c801f86a6a011084d806e94421fc1e4 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& module, const String& fkvar, const String& fvvar, const boost::shared_ptr<Expression>& fterm, std::map<String, Expression *> *closedVars,
+               const String& package, 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, module, fkvar,
+               ApplyRule::AddRule(type, target, name, expression, filter, package, 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, const String& module, std::map<String, Expression *> *closedVars, const boost::shared_ptr<Expression>& expression, const DebugInfo& debugInfo = DebugInfo())
+               const String& zone, const String& package, std::map<String, Expression *> *closedVars, const boost::shared_ptr<Expression>& expression, const DebugInfo& debugInfo = DebugInfo())
        {
                ConfigItemBuilder::Ptr item = new ConfigItemBuilder(debugInfo);
 
@@ -147,7 +147,7 @@ public:
                item->SetAbstract(abstract);
                item->SetScope(EvaluateClosedVars(frame, closedVars));
                item->SetZone(zone);
-               item->SetModule(module);
+               item->SetPackage(package);
                item->SetFilter(filter);
                item->Compile()->Register();
 
index 61635d0e1a70a19bba3368dabb955fd0f1c07143..2c1d561df502c637d0359a5e995649ab137d89f1 100644 (file)
@@ -71,7 +71,7 @@ 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 SetExpression(MakeIndexer(ScopeThis, "package"), OpSetLiteral, MakeLiteral(rule.GetPackage()), di));
        
        builder->AddExpression(new OwnedExpression(rule.GetExpression()));
 
index 61df51cb1a7ae90cd6131452b3b8bc38b4452e2a..fb77d6962ca0a023e11ed636c8deca7ed997366b 100644 (file)
@@ -70,7 +70,7 @@ 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 SetExpression(MakeIndexer(ScopeThis, "package"), OpSetLiteral, MakeLiteral(rule.GetPackage()), di));
 
        builder->AddExpression(new OwnedExpression(rule.GetExpression()));
 
index cc416b4c50d641181d92eab1a82b5f0970ede49f..426ac717fb153408d3d40987398a81c10a323b02 100644 (file)
@@ -69,7 +69,7 @@ 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 SetExpression(MakeIndexer(ScopeThis, "package"), OpSetLiteral, MakeLiteral(rule.GetPackage()), di));
 
        builder->AddExpression(new OwnedExpression(rule.GetExpression()));
 
index 545f0e67717158189f1a0508b1e1235d8b2875be..67896d143dc44688657232877fdb6cf431583812 100644 (file)
@@ -63,7 +63,7 @@ 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 SetExpression(MakeIndexer(ScopeThis, "package"), OpSetLiteral, MakeLiteral(rule.GetPackage()), di));
 
        builder->AddExpression(new OwnedExpression(rule.GetExpression()));
 
index a728a4aa622ee50b096b1a21c1479829163077ec..f52c39b7ead7aacd4fbf18399181ef84c737b2db 100644 (file)
@@ -24,7 +24,7 @@ set(remote_SOURCES
   actionshandler.cpp apiaction.cpp
   apifunction.cpp apilistener.cpp apilistener.thpp apilistener-sync.cpp
   apiuser.cpp apiuser.thpp authority.cpp base64.cpp 
-  configfileshandler.cpp configmoduleshandler.cpp configmoduleutility.cpp configobjectutility.cpp
+  configfileshandler.cpp configpackageshandler.cpp configpackageutility.cpp configobjectutility.cpp
   configstageshandler.cpp createobjecthandler.cpp deleteobjecthandler.cpp
   endpoint.cpp endpoint.thpp filterutility.cpp
   httpchunkedencoding.cpp httpclientconnection.cpp httpserverconnection.cpp httphandler.cpp httprequest.cpp httpresponse.cpp
index fb59c4b3b8862079e41a332901593b397863d8f8..5532bcf96302123fba3b7038f346f3b5622f2132 100644 (file)
@@ -18,7 +18,7 @@
  ******************************************************************************/
 
 #include "remote/configfileshandler.hpp"
-#include "remote/configmoduleutility.hpp"
+#include "remote/configpackageutility.hpp"
 #include "remote/httputility.hpp"
 #include "base/exception.hpp"
 #include <boost/algorithm/string/join.hpp>
@@ -45,7 +45,7 @@ void ConfigFilesHandler::HandleGet(const ApiUser::Ptr& user, HttpRequest& reques
        const std::vector<String>& urlPath = request.RequestUrl->GetPath();
 
        if (urlPath.size() >= 4)
-               params->Set("module", urlPath[3]);
+               params->Set("package", urlPath[3]);
 
        if (urlPath.size() >= 5)
                params->Set("stage", urlPath[4]);
@@ -55,22 +55,22 @@ void ConfigFilesHandler::HandleGet(const ApiUser::Ptr& user, HttpRequest& reques
                params->Set("path", boost::algorithm::join(tmpPath, "/"));
        }
 
-       String moduleName = HttpUtility::GetLastParameter(params, "module");
+       String packageName = HttpUtility::GetLastParameter(params, "package");
        String stageName = HttpUtility::GetLastParameter(params, "stage");
 
-       if (!ConfigModuleUtility::ValidateName(moduleName) || !ConfigModuleUtility::ValidateName(stageName)) {
+       if (!ConfigPackageUtility::ValidateName(packageName) || !ConfigPackageUtility::ValidateName(stageName)) {
                response.SetStatus(403, "Forbidden");
                return;
        }
 
        String relativePath = HttpUtility::GetLastParameter(params, "path");
 
-       if (ConfigModuleUtility::ContainsDotDot(relativePath)) {
+       if (ConfigPackageUtility::ContainsDotDot(relativePath)) {
                response.SetStatus(403, "Forbidden");
                return;
        }
 
-       String path = ConfigModuleUtility::GetModuleDir() + "/" + moduleName + "/" + stageName + "/" + relativePath;
+       String path = ConfigPackageUtility::GetPackageDir() + "/" + packageName + "/" + stageName + "/" + relativePath;
 
        if (!Utility::PathExists(path)) {
                response.SetStatus(404, "File not found");
index 1304bef0ed5068f23a4553e1b71c00d3aca93c43..0ce87e89e1cac0f6907dd6ca4c356ec6ed1b2c07 100644 (file)
@@ -18,7 +18,7 @@
  ******************************************************************************/
 
 #include "remote/configobjectutility.hpp"
-#include "remote/configmoduleutility.hpp"
+#include "remote/configpackageutility.hpp"
 #include "config/configitembuilder.hpp"
 #include "config/configitem.hpp"
 #include "config/configwriter.hpp"
@@ -33,8 +33,8 @@ using namespace icinga;
 
 String ConfigObjectUtility::GetConfigDir(void)
 {
-       return ConfigModuleUtility::GetModuleDir() + "/_api/" +
-           ConfigModuleUtility::GetActiveStage("_api");
+       return ConfigPackageUtility::GetPackageDir() + "/_api/" +
+           ConfigPackageUtility::GetActiveStage("_api");
 }
 
 String ConfigObjectUtility::EscapeName(const String& name)
@@ -59,7 +59,7 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full
        builder->SetType(type->GetName());
        builder->SetName(name);
        builder->SetScope(ScriptGlobal::GetGlobals());
-       builder->SetModule("_api");
+       builder->SetPackage("_api");
 
        if (templates) {
                ObjectLock olock(templates);
@@ -116,11 +116,11 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full
                return false;
        }
        
-       if (!ConfigModuleUtility::ModuleExists("_api")) {
-               ConfigModuleUtility::CreateModule("_api");
+       if (!ConfigPackageUtility::PackageExists("_api")) {
+               ConfigPackageUtility::CreatePackage("_api");
        
-               String stage = ConfigModuleUtility::CreateStage("_api");
-               ConfigModuleUtility::ActivateStage("_api", stage);
+               String stage = ConfigPackageUtility::CreateStage("_api");
+               ConfigPackageUtility::ActivateStage("_api", stage);
        } 
        
        String typeDir = type->GetPluralName();
@@ -205,7 +205,7 @@ bool ConfigObjectUtility::DeleteObjectHelper(const ConfigObject::Ptr& object, bo
 
 bool ConfigObjectUtility::DeleteObject(const ConfigObject::Ptr& object, bool cascade, const Array::Ptr& errors)
 {
-       if (object->GetModule() != "_api") {
+       if (object->GetPackage() != "_api") {
                if (errors)
                        errors->Add("Object cannot be deleted because it was not created using the API.");
 
similarity index 69%
rename from lib/remote/configmoduleshandler.cpp
rename to lib/remote/configpackageshandler.cpp
index ef8b9491c8987400e1319fc3fbb761f9f13fb7c1..47ce7cd6e80bb88f32b526055e45f9677d9df64d 100644 (file)
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
  ******************************************************************************/
 
-#include "remote/configmoduleshandler.hpp"
-#include "remote/configmoduleutility.hpp"
+#include "remote/configpackageshandler.hpp"
+#include "remote/configpackageutility.hpp"
 #include "remote/httputility.hpp"
 #include "base/exception.hpp"
 
 using namespace icinga;
 
-REGISTER_URLHANDLER("/v1/config/modules", ConfigModulesHandler);
+REGISTER_URLHANDLER("/v1/config/packages", ConfigPackagesHandler);
 
-bool ConfigModulesHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& request, HttpResponse& response)
+bool ConfigPackagesHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest& request, HttpResponse& response)
 {
        if (request.RequestUrl->GetPath().size() > 4)
                return false;
@@ -43,18 +43,18 @@ bool ConfigModulesHandler::HandleRequest(const ApiUser::Ptr& user, HttpRequest&
        return true;
 }
 
-void ConfigModulesHandler::HandleGet(const ApiUser::Ptr& user, HttpRequest& request, HttpResponse& response)
+void ConfigPackagesHandler::HandleGet(const ApiUser::Ptr& user, HttpRequest& request, HttpResponse& response)
 {
-       std::vector<String> modules = ConfigModuleUtility::GetModules();
+       std::vector<String> packages = ConfigPackageUtility::GetPackages();
 
        Array::Ptr results = new Array();
 
-       BOOST_FOREACH(const String& module, modules) {
-               Dictionary::Ptr moduleInfo = new Dictionary();
-               moduleInfo->Set("name", module);
-               moduleInfo->Set("stages", Array::FromVector(ConfigModuleUtility::GetStages(module)));
-               moduleInfo->Set("active-stage", ConfigModuleUtility::GetActiveStage(module));
-               results->Add(moduleInfo);
+       BOOST_FOREACH(const String& package, packages) {
+               Dictionary::Ptr packageInfo = new Dictionary();
+               packageInfo->Set("name", package);
+               packageInfo->Set("stages", Array::FromVector(ConfigPackageUtility::GetStages(package)));
+               packageInfo->Set("active-stage", ConfigPackageUtility::GetActiveStage(package));
+               results->Add(packageInfo);
        }
 
        Dictionary::Ptr result = new Dictionary();
@@ -64,25 +64,25 @@ void ConfigModulesHandler::HandleGet(const ApiUser::Ptr& user, HttpRequest& requ
        HttpUtility::SendJsonBody(response, result);
 }
 
-void ConfigModulesHandler::HandlePost(const ApiUser::Ptr& user, HttpRequest& request, HttpResponse& response)
+void ConfigPackagesHandler::HandlePost(const ApiUser::Ptr& user, HttpRequest& request, HttpResponse& response)
 {
        Dictionary::Ptr params = HttpUtility::FetchRequestParameters(request);
 
        if (request.RequestUrl->GetPath().size() >= 4)
-               params->Set("module", request.RequestUrl->GetPath()[3]);
+               params->Set("package", request.RequestUrl->GetPath()[3]);
 
-       String moduleName = HttpUtility::GetLastParameter(params, "module");
+       String packageName = HttpUtility::GetLastParameter(params, "package");
 
-       if (!ConfigModuleUtility::ValidateName(moduleName)) {
+       if (!ConfigPackageUtility::ValidateName(packageName)) {
                response.SetStatus(403, "Forbidden");
                return;
        }
 
        int code = 200;
-       String status = "Created module.";
+       String status = "Created package.";
 
        try {
-               ConfigModuleUtility::CreateModule(moduleName);
+               ConfigPackageUtility::CreatePackage(packageName);
        } catch (const std::exception& ex) {
                code = 501;
                status = "Error: " + DiagnosticInformation(ex);
@@ -90,7 +90,7 @@ void ConfigModulesHandler::HandlePost(const ApiUser::Ptr& user, HttpRequest& req
 
        Dictionary::Ptr result1 = new Dictionary();
 
-       result1->Set("module", moduleName);
+       result1->Set("package", packageName);
        result1->Set("code", code);
        result1->Set("status", status);
 
@@ -104,25 +104,25 @@ void ConfigModulesHandler::HandlePost(const ApiUser::Ptr& user, HttpRequest& req
        HttpUtility::SendJsonBody(response, result);
 }
 
-void ConfigModulesHandler::HandleDelete(const ApiUser::Ptr& user, HttpRequest& request, HttpResponse& response)
+void ConfigPackagesHandler::HandleDelete(const ApiUser::Ptr& user, HttpRequest& request, HttpResponse& response)
 {
        Dictionary::Ptr params = HttpUtility::FetchRequestParameters(request);
 
        if (request.RequestUrl->GetPath().size() >= 4)
-               params->Set("module", request.RequestUrl->GetPath()[3]);
+               params->Set("package", request.RequestUrl->GetPath()[3]);
 
-       String moduleName = HttpUtility::GetLastParameter(params, "module");
+       String packageName = HttpUtility::GetLastParameter(params, "package");
 
-       if (!ConfigModuleUtility::ValidateName(moduleName)) {
+       if (!ConfigPackageUtility::ValidateName(packageName)) {
                response.SetStatus(403, "Forbidden");
                return;
        }
 
        int code = 200;
-       String status = "Deleted module.";
+       String status = "Deleted package.";
 
        try {
-               ConfigModuleUtility::DeleteModule(moduleName);
+               ConfigPackageUtility::DeletePackage(packageName);
        } catch (const std::exception& ex) {
                code = 501;
                status = "Error: " + DiagnosticInformation(ex);
@@ -130,7 +130,7 @@ void ConfigModulesHandler::HandleDelete(const ApiUser::Ptr& user, HttpRequest& r
 
        Dictionary::Ptr result1 = new Dictionary();
 
-       result1->Set("module", moduleName);
+       result1->Set("package", packageName);
        result1->Set("code", code);
        result1->Set("status", status);
 
similarity index 94%
rename from lib/remote/configmoduleshandler.hpp
rename to lib/remote/configpackageshandler.hpp
index 9195eaf5f1791499537383228904419521502a0d..e97d1bdd26de6b3f2f66ef561236eb28dfa3eaa7 100644 (file)
 namespace icinga
 {
 
-class I2_REMOTE_API ConfigModulesHandler : public HttpHandler
+class I2_REMOTE_API ConfigPackagesHandler : public HttpHandler
 {
 public:
-       DECLARE_PTR_TYPEDEFS(ConfigModulesHandler);
+       DECLARE_PTR_TYPEDEFS(ConfigPackagesHandler);
 
        virtual bool HandleRequest(const ApiUser::Ptr& user, HttpRequest& request, HttpResponse& response) override;
 
similarity index 60%
rename from lib/remote/configmoduleutility.cpp
rename to lib/remote/configpackageutility.cpp
index 964519ba08843a66bfb3f7e5f8f12f0786a79431..79cb182f158224cda61339179c636d5ed0997f87 100644 (file)
@@ -17,7 +17,7 @@
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
  ******************************************************************************/
 
-#include "remote/configmoduleutility.hpp"
+#include "remote/configpackageutility.hpp"
 #include "base/application.hpp"
 #include "base/exception.hpp"
 #include "base/scriptglobal.hpp"
 
 using namespace icinga;
 
-String ConfigModuleUtility::GetModuleDir(void)
+String ConfigPackageUtility::GetPackageDir(void)
 {
-       return Application::GetLocalStateDir() + "/lib/icinga2/api/modules";
+       return Application::GetLocalStateDir() + "/lib/icinga2/api/packages";
 }
 
-void ConfigModuleUtility::CreateModule(const String& name)
+void ConfigPackageUtility::CreatePackage(const String& name)
 {
-       String path = GetModuleDir() + "/" + name;
+       String path = GetPackageDir() + "/" + name;
 
        if (Utility::PathExists(path))
-               BOOST_THROW_EXCEPTION(std::invalid_argument("Module already exists."));
+               BOOST_THROW_EXCEPTION(std::invalid_argument("Package already exists."));
 
        Utility::MkDirP(path, 0700);
-       WriteModuleConfig(name);
+       WritePackageConfig(name);
 }
 
-void ConfigModuleUtility::DeleteModule(const String& name)
+void ConfigPackageUtility::DeletePackage(const String& name)
 {
-       String path = GetModuleDir() + "/" + name;
+       String path = GetPackageDir() + "/" + name;
 
        if (!Utility::PathExists(path))
-               BOOST_THROW_EXCEPTION(std::invalid_argument("Module does not exist."));
+               BOOST_THROW_EXCEPTION(std::invalid_argument("Package does not exist."));
 
        Utility::RemoveDirRecursive(path);
        Application::RequestRestart();
 }
 
-std::vector<String> ConfigModuleUtility::GetModules(void)
+std::vector<String> ConfigPackageUtility::GetPackages(void)
 {
-       std::vector<String> modules;
-       Utility::Glob(GetModuleDir() + "/*", boost::bind(&ConfigModuleUtility::CollectDirNames, _1, boost::ref(modules)), GlobDirectory);
-       return modules;
+       std::vector<String> packages;
+       Utility::Glob(GetPackageDir() + "/*", boost::bind(&ConfigPackageUtility::CollectDirNames, _1, boost::ref(packages)), GlobDirectory);
+       return packages;
 }
 
-void ConfigModuleUtility::CollectDirNames(const String& path, std::vector<String>& dirs)
+void ConfigPackageUtility::CollectDirNames(const String& path, std::vector<String>& dirs)
 {
        String name = Utility::BaseName(path);
        dirs.push_back(name);
 }
 
-bool ConfigModuleUtility::ModuleExists(const String& name)
+bool ConfigPackageUtility::PackageExists(const String& name)
 {
-       return Utility::PathExists(GetModuleDir() + "/" + name);
+       return Utility::PathExists(GetPackageDir() + "/" + name);
 }
 
-String ConfigModuleUtility::CreateStage(const String& moduleName, const Dictionary::Ptr& files)
+String ConfigPackageUtility::CreateStage(const String& packageName, const Dictionary::Ptr& files)
 {
        String stageName = Utility::NewUniqueID();
 
-       String path = GetModuleDir() + "/" + moduleName;
+       String path = GetPackageDir() + "/" + packageName;
 
        if (!Utility::PathExists(path))
-               BOOST_THROW_EXCEPTION(std::invalid_argument("Module does not exist."));
+               BOOST_THROW_EXCEPTION(std::invalid_argument("Package does not exist."));
 
        path += "/" + stageName;
 
        Utility::MkDirP(path, 0700);
        Utility::MkDirP(path + "/conf.d", 0700);
        Utility::MkDirP(path + "/zones.d", 0700);
-       WriteStageConfig(moduleName, stageName);
+       WriteStageConfig(packageName, stageName);
 
        bool foundDotDot = false;
        
@@ -103,7 +103,7 @@ String ConfigModuleUtility::CreateStage(const String& moduleName, const Dictiona
        
                        String filePath = path + "/" + kv.first;
        
-                       Log(LogInformation, "ConfigModuleUtility")
+                       Log(LogInformation, "ConfigPackageUtility")
                            << "Updating configuration file: " << filePath;
        
                        //pass the directory and generate a dir tree, if not existing already
@@ -122,16 +122,16 @@ String ConfigModuleUtility::CreateStage(const String& moduleName, const Dictiona
        return stageName;
 }
 
-void ConfigModuleUtility::WriteModuleConfig(const String& moduleName)
+void ConfigPackageUtility::WritePackageConfig(const String& packageName)
 {
-       String stageName = GetActiveStage(moduleName);
+       String stageName = GetActiveStage(packageName);
 
-       String includePath = GetModuleDir() + "/" + moduleName + "/include.conf";
+       String includePath = GetPackageDir() + "/" + packageName + "/include.conf";
        std::ofstream fpInclude(includePath.CStr(), std::ofstream::out | std::ostream::binary | std::ostream::trunc);
        fpInclude << "include \"*/include.conf\"\n";
        fpInclude.close();
 
-       String activePath = GetModuleDir() + "/" + moduleName + "/active.conf";
+       String activePath = GetPackageDir() + "/" + packageName + "/active.conf";
        std::ofstream fpActive(activePath.CStr(), std::ofstream::out | std::ostream::binary | std::ostream::trunc);
        fpActive << "if (!globals.contains(\"ActiveStages\")) {\n"
                 << "  globals.ActiveStages = {}\n"
@@ -139,67 +139,67 @@ void ConfigModuleUtility::WriteModuleConfig(const String& moduleName)
                 << "\n"
                 << "if (globals.contains(\"ActiveStageOverride\")) {\n"
                 << "  var arr = ActiveStageOverride.split(\":\")\n"
-                << "  if (arr[0] == \"" << moduleName << "\") {\n"
+                << "  if (arr[0] == \"" << packageName << "\") {\n"
                 << "    if (arr.len() < 2) {\n"
                 << "      log(LogCritical, \"Config\", \"Invalid value for ActiveStageOverride\")\n"
                 << "    } else {\n"
-                << "      ActiveStages[\"" << moduleName << "\"] = arr[1]\n"
+                << "      ActiveStages[\"" << packageName << "\"] = arr[1]\n"
                 << "    }\n"
                 << "  }\n"
                 << "}\n"
                 << "\n"
-                << "if (!ActiveStages.contains(\"" << moduleName << "\")) {\n"
-                << "  ActiveStages[\"" << moduleName << "\"] = \"" << stageName << "\"\n"
+                << "if (!ActiveStages.contains(\"" << packageName << "\")) {\n"
+                << "  ActiveStages[\"" << packageName << "\"] = \"" << stageName << "\"\n"
                 << "}\n";
        fpActive.close();
 }
 
-void ConfigModuleUtility::WriteStageConfig(const String& moduleName, const String& stageName)
+void ConfigPackageUtility::WriteStageConfig(const String& packageName, const String& stageName)
 {
-       String path = GetModuleDir() + "/" + moduleName + "/" + stageName + "/include.conf";
+       String path = GetPackageDir() + "/" + packageName + "/" + stageName + "/include.conf";
        std::ofstream fp(path.CStr(), std::ofstream::out | std::ostream::binary | std::ostream::trunc);
        fp << "include \"../active.conf\"\n"
-          << "if (ActiveStages[\"" << moduleName << "\"] == \"" << stageName << "\") {\n"
+          << "if (ActiveStages[\"" << packageName << "\"] == \"" << stageName << "\") {\n"
           << "  include_recursive \"conf.d\"\n"
-          << "  include_zones \"" << moduleName << "\", \"zones.d\"\n"
+          << "  include_zones \"" << packageName << "\", \"zones.d\"\n"
           << "}\n";
        fp.close();
 }
 
-void ConfigModuleUtility::ActivateStage(const String& moduleName, const String& stageName)
+void ConfigPackageUtility::ActivateStage(const String& packageName, const String& stageName)
 {
-       String activeStagePath = GetModuleDir() + "/" + moduleName + "/active-stage";
+       String activeStagePath = GetPackageDir() + "/" + packageName + "/active-stage";
        std::ofstream fpActiveStage(activeStagePath.CStr(), std::ofstream::out | std::ostream::binary | std::ostream::trunc);
        fpActiveStage << stageName;
        fpActiveStage.close();
 
-       WriteModuleConfig(moduleName);
+       WritePackageConfig(packageName);
 }
 
-void ConfigModuleUtility::TryActivateStageCallback(const ProcessResult& pr, const String& moduleName, const String& stageName)
+void ConfigPackageUtility::TryActivateStageCallback(const ProcessResult& pr, const String& packageName, const String& stageName)
 {
-       String logFile = GetModuleDir() + "/" + moduleName + "/" + stageName + "/startup.log";
+       String logFile = GetPackageDir() + "/" + packageName + "/" + stageName + "/startup.log";
        std::ofstream fpLog(logFile.CStr(), std::ofstream::out | std::ostream::binary | std::ostream::trunc);
        fpLog << pr.Output;
        fpLog.close();
 
-       String statusFile = GetModuleDir() + "/" + moduleName + "/" + stageName + "/status";
+       String statusFile = GetPackageDir() + "/" + packageName + "/" + stageName + "/status";
        std::ofstream fpStatus(statusFile.CStr(), std::ofstream::out | std::ostream::binary | std::ostream::trunc);
        fpStatus << pr.ExitStatus;
        fpStatus.close();
 
        /* validation went fine, activate stage and reload */
        if (pr.ExitStatus == 0) {
-               ActivateStage(moduleName, stageName);
+               ActivateStage(packageName, stageName);
                Application::RequestRestart();
        } else {
-               Log(LogCritical, "ConfigModuleUtility")
-                   << "Config validation failed for module '"
-                   << moduleName << "' and stage '" << stageName << "'.";
+               Log(LogCritical, "ConfigPackageUtility")
+                   << "Config validation failed for package '"
+                   << packageName << "' and stage '" << stageName << "'.";
        }
 }
 
-void ConfigModuleUtility::AsyncTryActivateStage(const String& moduleName, const String& stageName)
+void ConfigPackageUtility::AsyncTryActivateStage(const String& packageName, const String& stageName)
 {
        // prepare arguments
        Array::Ptr args = new Array();
@@ -207,36 +207,36 @@ void ConfigModuleUtility::AsyncTryActivateStage(const String& moduleName, const
        args->Add("daemon");
        args->Add("--validate");
        args->Add("--define");
-       args->Add("ActiveStageOverride=" + moduleName + ":" + stageName);
+       args->Add("ActiveStageOverride=" + packageName + ":" + stageName);
 
        Process::Ptr process = new Process(Process::PrepareCommand(args));
        process->SetTimeout(300);
-       process->Run(boost::bind(&TryActivateStageCallback, _1, moduleName, stageName));
+       process->Run(boost::bind(&TryActivateStageCallback, _1, packageName, stageName));
 }
 
-void ConfigModuleUtility::DeleteStage(const String& moduleName, const String& stageName)
+void ConfigPackageUtility::DeleteStage(const String& packageName, const String& stageName)
 {
-       String path = GetModuleDir() + "/" + moduleName + "/" + stageName;
+       String path = GetPackageDir() + "/" + packageName + "/" + stageName;
 
        if (!Utility::PathExists(path))
                BOOST_THROW_EXCEPTION(std::invalid_argument("Stage does not exist."));
 
-       if (GetActiveStage(moduleName) == stageName)
+       if (GetActiveStage(packageName) == stageName)
                BOOST_THROW_EXCEPTION(std::invalid_argument("Active stage cannot be deleted."));
 
        Utility::RemoveDirRecursive(path);
 }
 
-std::vector<String> ConfigModuleUtility::GetStages(const String& moduleName)
+std::vector<String> ConfigPackageUtility::GetStages(const String& packageName)
 {
        std::vector<String> stages;
-       Utility::Glob(GetModuleDir() + "/" + moduleName + "/*", boost::bind(&ConfigModuleUtility::CollectDirNames, _1, boost::ref(stages)), GlobDirectory);
+       Utility::Glob(GetPackageDir() + "/" + packageName + "/*", boost::bind(&ConfigPackageUtility::CollectDirNames, _1, boost::ref(stages)), GlobDirectory);
        return stages;
 }
 
-String ConfigModuleUtility::GetActiveStage(const String& moduleName)
+String ConfigPackageUtility::GetActiveStage(const String& packageName)
 {
-       String path = GetModuleDir() + "/" + moduleName + "/active-stage";
+       String path = GetPackageDir() + "/" + packageName + "/active-stage";
 
        std::ifstream fp;
        fp.open(path.CStr());
@@ -253,15 +253,15 @@ String ConfigModuleUtility::GetActiveStage(const String& moduleName)
 }
 
 
-std::vector<std::pair<String, bool> > ConfigModuleUtility::GetFiles(const String& moduleName, const String& stageName)
+std::vector<std::pair<String, bool> > ConfigPackageUtility::GetFiles(const String& packageName, const String& stageName)
 {
        std::vector<std::pair<String, bool> > paths;
-       Utility::GlobRecursive(GetModuleDir() + "/" + moduleName + "/" + stageName, "*", boost::bind(&ConfigModuleUtility::CollectPaths, _1, boost::ref(paths)), GlobDirectory | GlobFile);
+       Utility::GlobRecursive(GetPackageDir() + "/" + packageName + "/" + stageName, "*", boost::bind(&ConfigPackageUtility::CollectPaths, _1, boost::ref(paths)), GlobDirectory | GlobFile);
 
        return paths;
 }
 
-void ConfigModuleUtility::CollectPaths(const String& path, std::vector<std::pair<String, bool> >& paths)
+void ConfigPackageUtility::CollectPaths(const String& path, std::vector<std::pair<String, bool> >& paths)
 {
 #ifndef _WIN32
        struct stat statbuf;
@@ -286,7 +286,7 @@ void ConfigModuleUtility::CollectPaths(const String& path, std::vector<std::pair
 #endif /* _WIN32 */
 }
 
-bool ConfigModuleUtility::ContainsDotDot(const String& path)
+bool ConfigPackageUtility::ContainsDotDot(const String& path)
 {
        std::vector<String> tokens;
        boost::algorithm::split(tokens, path, boost::is_any_of("/\\"));
@@ -299,7 +299,7 @@ bool ConfigModuleUtility::ContainsDotDot(const String& path)
        return false;
 }
 
-bool ConfigModuleUtility::ValidateName(const String& name)
+bool ConfigPackageUtility::ValidateName(const String& name)
 {
        if (name.IsEmpty())
                return false;
similarity index 69%
rename from lib/remote/configmoduleutility.hpp
rename to lib/remote/configpackageutility.hpp
index 5370f562db2d3247c841aec0d77eafeccbada41d..b6c95201603ad3313e48e75e08e176fe273e9fb8 100644 (file)
@@ -35,25 +35,25 @@ namespace icinga
  *
  * @ingroup remote
  */
-class I2_REMOTE_API ConfigModuleUtility
+class I2_REMOTE_API ConfigPackageUtility
 {
 
 public:
-       static String GetModuleDir(void);
+       static String GetPackageDir(void);
 
-       static void CreateModule(const String& name);
-       static void DeleteModule(const String& name);
-       static std::vector<String> GetModules(void);
-       static bool ModuleExists(const String& name);
+       static void CreatePackage(const String& name);
+       static void DeletePackage(const String& name);
+       static std::vector<String> GetPackages(void);
+       static bool PackageExists(const String& name);
 
-       static String CreateStage(const String& moduleName, const Dictionary::Ptr& files = Dictionary::Ptr());
-       static void DeleteStage(const String& moduleName, const String& stageName);
-       static std::vector<String> GetStages(const String& moduleName);
-       static String GetActiveStage(const String& moduleName);
-       static void ActivateStage(const String& moduleName, const String& stageName);
-       static void AsyncTryActivateStage(const String& moduleName, const String& stageName);
+       static String CreateStage(const String& packageName, const Dictionary::Ptr& files = Dictionary::Ptr());
+       static void DeleteStage(const String& packageName, const String& stageName);
+       static std::vector<String> GetStages(const String& packageName);
+       static String GetActiveStage(const String& packageName);
+       static void ActivateStage(const String& packageName, const String& stageName);
+       static void AsyncTryActivateStage(const String& packageName, const String& stageName);
 
-       static std::vector<std::pair<String, bool> > GetFiles(const String& moduleName, const String& stageName);
+       static std::vector<std::pair<String, bool> > GetFiles(const String& packageName, const String& stageName);
 
        static bool ContainsDotDot(const String& path);
        static bool ValidateName(const String& name);
@@ -62,10 +62,10 @@ private:
        static void CollectDirNames(const String& path, std::vector<String>& dirs);
        static void CollectPaths(const String& path, std::vector<std::pair<String, bool> >& paths);
 
-       static void WriteModuleConfig(const String& moduleName);
-       static void WriteStageConfig(const String& moduleName, const String& stageName);
+       static void WritePackageConfig(const String& packageName);
+       static void WriteStageConfig(const String& packageName, const String& stageName);
 
-       static void TryActivateStageCallback(const ProcessResult& pr, const String& moduleName, const String& stageName);
+       static void TryActivateStageCallback(const ProcessResult& pr, const String& packageName, const String& stageName);
 };
 
 }
index 3d42271dc741c87db1006e245cb063c17df7f7f1..b3b7094d1286dc0e24897b9a9f57dd29c7555181 100644 (file)
@@ -18,7 +18,7 @@
  ******************************************************************************/
 
 #include "remote/configstageshandler.hpp"
-#include "remote/configmoduleutility.hpp"
+#include "remote/configpackageutility.hpp"
 #include "remote/httputility.hpp"
 #include "base/application.hpp"
 #include "base/exception.hpp"
@@ -50,24 +50,24 @@ void ConfigStagesHandler::HandleGet(const ApiUser::Ptr& user, HttpRequest& reque
        Dictionary::Ptr params = HttpUtility::FetchRequestParameters(request);
 
        if (request.RequestUrl->GetPath().size() >= 4)
-               params->Set("module", request.RequestUrl->GetPath()[3]);
+               params->Set("package", request.RequestUrl->GetPath()[3]);
 
        if (request.RequestUrl->GetPath().size() >= 5)
                params->Set("stage", request.RequestUrl->GetPath()[4]);
 
-       String moduleName = HttpUtility::GetLastParameter(params, "module");
+       String packageName = HttpUtility::GetLastParameter(params, "package");
        String stageName = HttpUtility::GetLastParameter(params, "stage");
 
-       if (!ConfigModuleUtility::ValidateName(moduleName) || !ConfigModuleUtility::ValidateName(stageName)) {
+       if (!ConfigPackageUtility::ValidateName(packageName) || !ConfigPackageUtility::ValidateName(stageName)) {
                response.SetStatus(403, "Forbidden");
                return;
        }
 
        Array::Ptr results = new Array();
 
-       std::vector<std::pair<String, bool> > paths = ConfigModuleUtility::GetFiles(moduleName, stageName);
+       std::vector<std::pair<String, bool> > paths = ConfigPackageUtility::GetFiles(packageName, stageName);
 
-       String prefixPath = ConfigModuleUtility::GetModuleDir() + "/" + moduleName + "/" + stageName + "/";
+       String prefixPath = ConfigPackageUtility::GetPackageDir() + "/" + packageName + "/" + stageName + "/";
 
        typedef std::pair<String, bool> kv_pair;
        BOOST_FOREACH(const kv_pair& kv, paths) {
@@ -89,11 +89,11 @@ void ConfigStagesHandler::HandlePost(const ApiUser::Ptr& user, HttpRequest& requ
        Dictionary::Ptr params = HttpUtility::FetchRequestParameters(request);
 
        if (request.RequestUrl->GetPath().size() >= 4)
-               params->Set("module", request.RequestUrl->GetPath()[3]);
+               params->Set("package", request.RequestUrl->GetPath()[3]);
 
-       String moduleName = HttpUtility::GetLastParameter(params, "module");
+       String packageName = HttpUtility::GetLastParameter(params, "package");
 
-       if (!ConfigModuleUtility::ValidateName(moduleName)) {
+       if (!ConfigPackageUtility::ValidateName(packageName)) {
                response.SetStatus(403, "Forbidden");
                return;
        }
@@ -108,10 +108,10 @@ void ConfigStagesHandler::HandlePost(const ApiUser::Ptr& user, HttpRequest& requ
                if (!files)
                        BOOST_THROW_EXCEPTION(std::invalid_argument("Parameter 'files' must be specified."));
 
-               stageName = ConfigModuleUtility::CreateStage(moduleName, files);
+               stageName = ConfigPackageUtility::CreateStage(packageName, files);
 
                /* validate the config. on success, activate stage and reload */
-               ConfigModuleUtility::AsyncTryActivateStage(moduleName, stageName);
+               ConfigPackageUtility::AsyncTryActivateStage(packageName, stageName);
        } catch (const std::exception& ex) {
                code = 501;
                status = "Error: " + DiagnosticInformation(ex);
@@ -119,7 +119,7 @@ void ConfigStagesHandler::HandlePost(const ApiUser::Ptr& user, HttpRequest& requ
 
        Dictionary::Ptr result1 = new Dictionary();
 
-       result1->Set("module", moduleName);
+       result1->Set("package", packageName);
        result1->Set("stage", stageName);
        result1->Set("code", code);
        result1->Set("status", status);
@@ -139,15 +139,15 @@ void ConfigStagesHandler::HandleDelete(const ApiUser::Ptr& user, HttpRequest& re
        Dictionary::Ptr params = HttpUtility::FetchRequestParameters(request);
 
        if (request.RequestUrl->GetPath().size() >= 4)
-               params->Set("module", request.RequestUrl->GetPath()[3]);
+               params->Set("package", request.RequestUrl->GetPath()[3]);
 
        if (request.RequestUrl->GetPath().size() >= 5)
                params->Set("stage", request.RequestUrl->GetPath()[4]);
 
-       String moduleName = HttpUtility::GetLastParameter(params, "module");
+       String packageName = HttpUtility::GetLastParameter(params, "package");
        String stageName = HttpUtility::GetLastParameter(params, "stage");
 
-       if (!ConfigModuleUtility::ValidateName(moduleName) || !ConfigModuleUtility::ValidateName(stageName)) {
+       if (!ConfigPackageUtility::ValidateName(packageName) || !ConfigPackageUtility::ValidateName(stageName)) {
                response.SetStatus(403, "Forbidden");
                return;
        }
@@ -156,7 +156,7 @@ void ConfigStagesHandler::HandleDelete(const ApiUser::Ptr& user, HttpRequest& re
        String status = "Deleted stage.";
 
        try {
-               ConfigModuleUtility::DeleteStage(moduleName, stageName);
+               ConfigPackageUtility::DeleteStage(packageName, stageName);
        } catch (const std::exception& ex) {
                code = 501;
                status = "Error: " + DiagnosticInformation(ex);
@@ -164,7 +164,7 @@ void ConfigStagesHandler::HandleDelete(const ApiUser::Ptr& user, HttpRequest& re
 
        Dictionary::Ptr result1 = new Dictionary();
 
-       result1->Set("module", moduleName);
+       result1->Set("package", packageName);
        result1->Set("stage", stageName);
        result1->Set("code", code);
        result1->Set("status", status);