[icinga-checkins] icinga.org: icinga2/master: Refactored IcingaApplication::Get*().

git at icinga.org git at icinga.org
Mon Nov 26 08:34:53 CET 2012


Module: icinga2
Branch: master
Commit: 18e8d4a976801a26dd1882335507ec73851aefb6
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=18e8d4a976801a26dd1882335507ec73851aefb6

Author: Gunnar Beutner <gunnar at beutner.name>
Date:   Mon Nov 26 08:30:52 2012 +0100

Refactored IcingaApplication::Get*().

Fixes #3209, #3277

---

 lib/icinga/icingaapplication.cpp |   55 +++++++++++++------------------------
 lib/icinga/icingaapplication.h   |    7 -----
 2 files changed, 19 insertions(+), 43 deletions(-)

diff --git a/lib/icinga/icingaapplication.cpp b/lib/icinga/icingaapplication.cpp
index bc616f8..a6500b4 100644
--- a/lib/icinga/icingaapplication.cpp
+++ b/lib/icinga/icingaapplication.cpp
@@ -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
diff --git a/lib/icinga/icingaapplication.h b/lib/icinga/icingaapplication.h
index d117575..e238fa6 100644
--- a/lib/icinga/icingaapplication.h
+++ b/lib/icinga/icingaapplication.h
@@ -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;





More information about the icinga-checkins mailing list