]> granicus.if.org Git - icinga2/commitdiff
Refactored IcingaApplication::Get*().
authorGunnar Beutner <gunnar@beutner.name>
Mon, 26 Nov 2012 07:30:52 +0000 (08:30 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Mon, 26 Nov 2012 07:30:52 +0000 (08:30 +0100)
Fixes #3209, #3277

lib/icinga/icingaapplication.cpp
lib/icinga/icingaapplication.h

index bc616f856efd2c376cd869fe42f19d9c54940797..a6500b4b9d6e0c9450d1a6199f43c0a95873bfca 100644 (file)
@@ -90,32 +90,6 @@ int IcingaApplication::Main(const vector<String>& args)
                }
        }
 
-       m_CertificateFile = Get("cert_path");
-       m_CAFile = Get("ca_path");
-       m_Node = Get("node");
-       m_Service = Get("service");
-
-       m_PidPath = Get("pid_path");
-       if (m_PidPath.IsEmpty())
-               m_PidPath = DefaultPidPath;
-
-       m_StatePath = Get("state_path");
-       if (m_StatePath.IsEmpty())
-               m_StatePath = DefaultStatePath;
-
-       m_Macros = Get("macros");
-
-       String logpath = Get("log_path");
-       if (!logpath.IsEmpty()) {
-               ConfigItemBuilder::Ptr fileLogConfig = boost::make_shared<ConfigItemBuilder>();
-               fileLogConfig->SetType("Logger");
-               fileLogConfig->SetName("main");
-               fileLogConfig->SetLocal(true);
-               fileLogConfig->AddExpression("type", OperatorSet, "file");
-               fileLogConfig->AddExpression("path", OperatorSet, logpath);
-               fileLogConfig->Compile()->Commit();
-       }
-
        UpdatePidFile(GetPidPath());
 
        if (!GetCertificateFile().IsEmpty() && !GetCAFile().IsEmpty()) {
@@ -131,9 +105,8 @@ int IcingaApplication::Main(const vector<String>& args)
        }
 
        /* create the primary RPC listener */
-       String service = GetService();
-       if (!service.IsEmpty())
-               EndpointManager::GetInstance()->AddListener(service);
+       if (!GetService().IsEmpty())
+               EndpointManager::GetInstance()->AddListener(GetService());
 
        if (daemonize) {
                Logger::Write(LogInformation, "icinga", "Daemonizing.");
@@ -171,37 +144,47 @@ IcingaApplication::Ptr IcingaApplication::GetInstance(void)
 
 String IcingaApplication::GetCertificateFile(void) const
 {
-       return m_CertificateFile;
+       return Get("cert_path");
 }
 
 String IcingaApplication::GetCAFile(void) const
 {
-       return m_CAFile;
+       return Get("ca_path");
 }
 
 String IcingaApplication::GetNode(void) const
 {
-       return m_Node;
+       return Get("node");
 }
 
 String IcingaApplication::GetService(void) const
 {
-       return m_Service;
+       return Get("service");
 }
 
 String IcingaApplication::GetPidPath(void) const
 {
-       return m_PidPath;
+       Value pidPath = Get("pid_path");
+
+       if (pidPath.IsEmpty())
+               pidPath = DefaultPidPath;
+
+       return pidPath;
 }
 
 String IcingaApplication::GetStatePath(void) const
 {
-       return m_StatePath;
+       Value statePath = Get("state_path");
+
+       if (statePath.IsEmpty())
+               statePath = DefaultStatePath;
+
+       return statePath;
 }
 
 Dictionary::Ptr IcingaApplication::GetMacros(void) const
 {
-       return m_Macros;
+       return Get("macros");
 }
 
 double IcingaApplication::GetStartTime(void) const
index d1175758b3330f6f4a5edac79edd16ec630ff7a5..e238fa6ae3fbf2e8dde2ffa8ee4b1ba290c13d37 100644 (file)
@@ -55,13 +55,6 @@ public:
        static const String DefaultStatePath;
 
 private:
-       String m_CertificateFile;
-       String m_CAFile;
-       String m_Node;
-       String m_Service;
-       String m_PidPath;
-       String m_StatePath;
-       Dictionary::Ptr m_Macros;
        shared_ptr<SSL_CTX> m_SSLContext;
 
        double m_StartTime;