From: Gunnar Beutner Date: Thu, 26 Jul 2012 10:41:57 +0000 (+0200) Subject: Merged configfile component into the icinga library. X-Git-Tag: v0.0.1~184 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fcb49044463b805a1e71e6b5df75084078e0a953;p=icinga2 Merged configfile component into the icinga library. --- diff --git a/components/Makefile.am b/components/Makefile.am index 422b8c10c..edf2f2952 100644 --- a/components/Makefile.am +++ b/components/Makefile.am @@ -5,7 +5,6 @@ SUBDIRS = \ checker \ cibsync \ compat \ - configfile \ convenience \ delegation \ demo \ diff --git a/components/configfile/Makefile.am b/components/configfile/Makefile.am deleted file mode 100644 index 7beee1d89..000000000 --- a/components/configfile/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -## Process this file with automake to produce Makefile.in - -pkglib_LTLIBRARIES = \ - configfile.la - -configfile_la_SOURCES = \ - configfilecomponent.cpp \ - configfilecomponent.h \ - i2-configfile.h - -configfile_la_CPPFLAGS = \ - $(BOOST_CPPFLAGS) \ - -I${top_srcdir}/base \ - -I${top_srcdir}/dyn - -configfile_la_LDFLAGS = \ - $(BOOST_LDFLAGS) \ - -module \ - -no-undefined \ - @RELEASE_INFO@ \ - @VERSION_INFO@ - -configfile_la_LIBADD = \ - $(BOOST_SIGNALS_LIB) \ - $(BOOST_THREAD_LIB) \ - $(top_builddir)/base/libbase.la \ - $(top_builddir)/dyn/libdyn.la diff --git a/components/configfile/configfile.vcxproj b/components/configfile/configfile.vcxproj deleted file mode 100644 index ec4f03cba..000000000 --- a/components/configfile/configfile.vcxproj +++ /dev/null @@ -1,98 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - - - - - - - - {E58F1DA7-B723-412B-B2B7-7FF58E2A944E} - Win32Proj - icinga - - - - DynamicLibrary - true - MultiByte - - - DynamicLibrary - false - true - MultiByte - - - - - - - - - - - - - $(SolutionDir)\base;$(SolutionDir)\icinga;$(SolutionDir)\dyn;$(IncludePath) - $(OutDir);$(LibraryPath) - - - $(SolutionDir)\base;$(SolutionDir)\icinga;$(SolutionDir)\dyn;$(IncludePath) - $(OutDir);$(LibraryPath) - - - - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - Level3 - false - true - - - Windows - true - base.lib;dyn.lib;%(AdditionalDependencies) - - - - - - - - - MaxSpeed - true - true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - Speed - Level3 - false - true - - - Windows - true - true - true - base.lib;dyn.lib;%(AdditionalDependencies) - - - $(OutDir)\base.lib;$(OutDir)\jsonrpc.lib - - - - - - \ No newline at end of file diff --git a/components/configfile/configfile.vcxproj.filters b/components/configfile/configfile.vcxproj.filters deleted file mode 100644 index 8fbfd218a..000000000 --- a/components/configfile/configfile.vcxproj.filters +++ /dev/null @@ -1,24 +0,0 @@ - - - - - Headerdateien - - - Headerdateien - - - - - {4cead05d-6b4f-4201-8788-eae48becc992} - - - {2bf43753-a887-4020-8f0c-57806031e919} - - - - - Quelldateien - - - \ No newline at end of file diff --git a/components/configfile/configfilecomponent.cpp b/components/configfile/configfilecomponent.cpp deleted file mode 100644 index 8c935cf80..000000000 --- a/components/configfile/configfilecomponent.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/****************************************************************************** - * Icinga 2 * - * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) * - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License * - * as published by the Free Software Foundation; either version 2 * - * of the License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the Free Software Foundation * - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * - ******************************************************************************/ - -#include "i2-configfile.h" - -using std::ifstream; - -using namespace icinga; - -string ConfigFileComponent::GetName(void) const -{ - return "configfilecomponent"; -} - -void ConfigFileComponent::Start(void) -{ - ifstream fp; - - string filename; - if (!GetConfig()->GetProperty("configFilename", &filename)) - throw_exception(logic_error("Missing 'configFilename' property")); - - vector configItems = ConfigCompiler::CompileFile(filename); - - Logger::Write(LogInformation, "configfile", "Executing config items..."); - - BOOST_FOREACH(const ConfigItem::Ptr& item, configItems) { - item->Commit(); - } -} - -void ConfigFileComponent::Stop(void) -{ -} - -EXPORT_COMPONENT(configfile, ConfigFileComponent); diff --git a/components/configfile/configfilecomponent.h b/components/configfile/configfilecomponent.h deleted file mode 100644 index 618450deb..000000000 --- a/components/configfile/configfilecomponent.h +++ /dev/null @@ -1,49 +0,0 @@ -/****************************************************************************** - * Icinga 2 * - * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) * - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License * - * as published by the Free Software Foundation; either version 2 * - * of the License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the Free Software Foundation * - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * - ******************************************************************************/ - -#ifndef CONFIGFILECOMPONENT_H -#define CONFIGFILECOMPONENT_H - -namespace icinga -{ - -/** - * Thrown when a parser error occurs while reading a config file. - * - * @ingroup configfile - */ -DEFINE_EXCEPTION_CLASS(ConfigParserException); - -/** - * @ingroup configfile - */ -class ConfigFileComponent : public Component -{ -public: - typedef shared_ptr Ptr; - typedef weak_ptr WeakPtr; - - virtual string GetName(void) const; - virtual void Start(void); - virtual void Stop(void); -}; - -} - -#endif /* CONFIGFILECOMPONENT_H */ diff --git a/components/configfile/i2-configfile.h b/components/configfile/i2-configfile.h deleted file mode 100644 index 0c534de88..000000000 --- a/components/configfile/i2-configfile.h +++ /dev/null @@ -1,35 +0,0 @@ -/****************************************************************************** - * Icinga 2 * - * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) * - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License * - * as published by the Free Software Foundation; either version 2 * - * of the License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the Free Software Foundation * - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * - ******************************************************************************/ - -#ifndef I2CONFIGFILECOMPONENT_H -#define I2CONFIGFILECOMPONENT_H - -/** - * @defgroup configfile ConfigFile component - * - * The ConfigFile component reads configuration objects from a configuration - * file - */ - -#include -#include - -#include "configfilecomponent.h" - -#endif /* I2CONFIGFILECOMPONENT_H */ diff --git a/icinga.sln b/icinga.sln index 0c71daecf..cdbcdd5ba 100644 --- a/icinga.sln +++ b/icinga.sln @@ -24,17 +24,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "icinga-app", "icinga-app\ic {EAD41628-BB96-4F99-9070-8A9676801295} = {EAD41628-BB96-4F99-9070-8A9676801295} {2E6C1133-730F-4875-A72C-B455B1DD4C5C} = {2E6C1133-730F-4875-A72C-B455B1DD4C5C} {17C93245-8C20-4316-9573-1AE41D918C10} = {17C93245-8C20-4316-9573-1AE41D918C10} - {E58F1DA7-B723-412B-B2B7-7FF58E2A944E} = {E58F1DA7-B723-412B-B2B7-7FF58E2A944E} {38CE81CC-2660-4EF0-A936-4A337591DA3E} = {38CE81CC-2660-4EF0-A936-4A337591DA3E} {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} = {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "configfile", "components\configfile\configfile.vcxproj", "{E58F1DA7-B723-412B-B2B7-7FF58E2A944E}" - ProjectSection(ProjectDependencies) = postProject - {9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677} - {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7} = {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7} - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "demo", "components\demo\demo.vcxproj", "{2E6C1133-730F-4875-A72C-B455B1DD4C5C}" ProjectSection(ProjectDependencies) = postProject {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} = {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} @@ -116,10 +109,6 @@ Global {BE412865-FEBA-4259-AD41-58950D1F5432}.Debug|Win32.Build.0 = Debug|Win32 {BE412865-FEBA-4259-AD41-58950D1F5432}.Release|Win32.ActiveCfg = Release|Win32 {BE412865-FEBA-4259-AD41-58950D1F5432}.Release|Win32.Build.0 = Release|Win32 - {E58F1DA7-B723-412B-B2B7-7FF58E2A944E}.Debug|Win32.ActiveCfg = Debug|Win32 - {E58F1DA7-B723-412B-B2B7-7FF58E2A944E}.Debug|Win32.Build.0 = Debug|Win32 - {E58F1DA7-B723-412B-B2B7-7FF58E2A944E}.Release|Win32.ActiveCfg = Release|Win32 - {E58F1DA7-B723-412B-B2B7-7FF58E2A944E}.Release|Win32.Build.0 = Release|Win32 {2E6C1133-730F-4875-A72C-B455B1DD4C5C}.Debug|Win32.ActiveCfg = Debug|Win32 {2E6C1133-730F-4875-A72C-B455B1DD4C5C}.Debug|Win32.Build.0 = Debug|Win32 {2E6C1133-730F-4875-A72C-B455B1DD4C5C}.Release|Win32.ActiveCfg = Release|Win32 @@ -176,6 +165,5 @@ Global {704DDD8E-9E6D-4C22-80BD-6DE10F3A5E1C} = {4A1773FD-DDED-4952-8700-C898E890554A} {2BD1C70C-43DB-4F44-B66B-67CF5C7044AA} = {4A1773FD-DDED-4952-8700-C898E890554A} {D02A349B-BAF7-41FB-86FF-B05BA05FE578} = {4A1773FD-DDED-4952-8700-C898E890554A} - {E58F1DA7-B723-412B-B2B7-7FF58E2A944E} = {4A1773FD-DDED-4952-8700-C898E890554A} EndGlobalSection EndGlobal diff --git a/icinga/icingaapplication.cpp b/icinga/icingaapplication.cpp index 6c1a28a36..356018eec 100644 --- a/icinga/icingaapplication.cpp +++ b/icinga/icingaapplication.cpp @@ -165,12 +165,13 @@ int IcingaApplication::Main(const vector& args) convenienceComponentConfig->Compile()->Commit(); /* load config file */ - ConfigItemBuilder::Ptr fileComponentConfig = boost::make_shared(); - fileComponentConfig->SetType("component"); - fileComponentConfig->SetName("configfile"); - fileComponentConfig->SetLocal(true); - fileComponentConfig->AddExpression("configFilename", OperatorSet, configFile); - fileComponentConfig->Compile()->Commit(); + vector configItems = ConfigCompiler::CompileFile(configFile); + + Logger::Write(LogInformation, "configfile", "Executing config items..."); + + BOOST_FOREACH(const ConfigItem::Ptr& item, configItems) { + item->Commit(); + } ConfigObject::Ptr icingaConfig = ConfigObject::GetObject("application", "icinga");