[icinga-checkins] icinga.org: icinga2/feature/ido-groups: wip

git at icinga.org git at icinga.org
Thu Jul 21 17:38:29 CEST 2016


Module: icinga2
Branch: feature/ido-groups
Commit: da1e5f2d1abacd0491a6bc0b26859f7e345c4c87
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=da1e5f2d1abacd0491a6bc0b26859f7e345c4c87

Author: Michael Friedrich <michael.friedrich at netways.de>
Date:   Thu Jul 21 17:37:41 2016 +0200

wip

---

 lib/db_ido/dbconnection.cpp    |    6 +++---
 lib/db_ido/hostdbobject.cpp    |   23 +++++++----------------
 lib/db_ido/servicedbobject.cpp |   23 +++++++----------------
 lib/db_ido/userdbobject.cpp    |   17 ++++++-----------
 4 files changed, 23 insertions(+), 46 deletions(-)

diff --git a/lib/db_ido/dbconnection.cpp b/lib/db_ido/dbconnection.cpp
index 186e78c..7970408 100644
--- a/lib/db_ido/dbconnection.cpp
+++ b/lib/db_ido/dbconnection.cpp
@@ -433,7 +433,7 @@ void DbConnection::PrepareDatabase(void)
 	//ClearConfigTable("comments");
 	ClearConfigTable("contact_addresses");
 	ClearConfigTable("contact_notificationcommands");
-	ClearConfigTable("contactgroup_members");
+	//ClearConfigTable("contactgroup_members");
 	//ClearConfigTable("contactgroups");
 	//ClearConfigTable("contacts");
 	//ClearConfigTable("contactstatus");
@@ -445,7 +445,7 @@ void DbConnection::PrepareDatabase(void)
 	ClearConfigTable("host_contacts");
 	ClearConfigTable("host_parenthosts");
 	ClearConfigTable("hostdependencies");
-	ClearConfigTable("hostgroup_members");
+	//ClearConfigTable("hostgroup_members");
 	//ClearConfigTable("hostgroups");
 	//ClearConfigTable("hosts");
 	//ClearConfigTable("hoststatus");
@@ -453,7 +453,7 @@ void DbConnection::PrepareDatabase(void)
 	ClearConfigTable("service_contactgroups");
 	ClearConfigTable("service_contacts");
 	ClearConfigTable("servicedependencies");
-	ClearConfigTable("servicegroup_members");
+	//ClearConfigTable("servicegroup_members");
 	//ClearConfigTable("servicegroups");
 	//ClearConfigTable("services");
 	//ClearConfigTable("servicestatus");
diff --git a/lib/db_ido/hostdbobject.cpp b/lib/db_ido/hostdbobject.cpp
index 47fd7d2..f896eb4 100644
--- a/lib/db_ido/hostdbobject.cpp
+++ b/lib/db_ido/hostdbobject.cpp
@@ -189,29 +189,20 @@ void HostDbObject::OnConfigUpdate(void)
 		BOOST_FOREACH(const String& groupName, groups) {
 			HostGroup::Ptr group = HostGroup::GetByName(groupName);
 
-			std::vector<DbQuery> queries;
-
 			DbQuery query1;
 			query1.Table = DbType::GetByName("HostGroup")->GetTable() + "_members";
-			query1.Type = DbQueryDelete;
+			query1.Type = DbQueryInsert | DbQueryUpdate;
 			query1.Category = DbCatConfig;
+			query1.Fields = new Dictionary();
+			query1.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */
+			query1.Fields->Set("hostgroup_id", DbValue::FromObjectInsertID(group));
+			query1.Fields->Set("host_object_id", host);
 			query1.WhereCriteria = new Dictionary();
 			query1.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
 			query1.WhereCriteria->Set("hostgroup_id", DbValue::FromObjectInsertID(group));
 			query1.WhereCriteria->Set("host_object_id", host);
-			queries.push_back(query1);
-
-			DbQuery query2;
-			query2.Table = DbType::GetByName("HostGroup")->GetTable() + "_members";
-			query2.Type = DbQueryInsert;
-			query2.Category = DbCatConfig;
-			query2.Fields = new Dictionary();
-			query2.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */
-			query2.Fields->Set("hostgroup_id", DbValue::FromObjectInsertID(group));
-			query2.Fields->Set("host_object_id", host);
-			queries.push_back(query2);
-
-			DbObject::OnMultipleQueries(queries);
+
+			DbObject::OnQuery(query1);
 		}
 	}
 
diff --git a/lib/db_ido/servicedbobject.cpp b/lib/db_ido/servicedbobject.cpp
index 2806e1c..d5581fb 100644
--- a/lib/db_ido/servicedbobject.cpp
+++ b/lib/db_ido/servicedbobject.cpp
@@ -188,29 +188,20 @@ void ServiceDbObject::OnConfigUpdate(void)
 		BOOST_FOREACH(const String& groupName, groups) {
 			ServiceGroup::Ptr group = ServiceGroup::GetByName(groupName);
 
-			std::vector<DbQuery> queries;
-
 			DbQuery query1;
 			query1.Table = DbType::GetByName("ServiceGroup")->GetTable() + "_members";
-			query1.Type = DbQueryDelete;
+			query1.Type = DbQueryInsert | DbQueryUpdate;
 			query1.Category = DbCatConfig;
+			query1.Fields = new Dictionary();
+			query1.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */
+			query1.Fields->Set("servicegroup_id", DbValue::FromObjectInsertID(group));
+			query1.Fields->Set("service_object_id", service);
 			query1.WhereCriteria = new Dictionary();
 			query1.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
 			query1.WhereCriteria->Set("servicegroup_id", DbValue::FromObjectInsertID(group));
 			query1.WhereCriteria->Set("service_object_id", service);
-			queries.push_back(query1);
-
-			DbQuery query2;
-			query2.Table = DbType::GetByName("ServiceGroup")->GetTable() + "_members";
-			query2.Type = DbQueryInsert;
-			query2.Category = DbCatConfig;
-			query2.Fields = new Dictionary();
-			query2.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */
-			query2.Fields->Set("servicegroup_id", DbValue::FromObjectInsertID(group));
-			query2.Fields->Set("service_object_id", service);
-			queries.push_back(query2);
-
-			DbObject::OnMultipleQueries(queries);
+
+			DbObject::OnQuery(query1);
 		}
 	}
 
diff --git a/lib/db_ido/userdbobject.cpp b/lib/db_ido/userdbobject.cpp
index 5adfd09..3a783b0 100644
--- a/lib/db_ido/userdbobject.cpp
+++ b/lib/db_ido/userdbobject.cpp
@@ -95,23 +95,18 @@ void UserDbObject::OnConfigUpdate(void)
 
 			DbQuery query1;
 			query1.Table = DbType::GetByName("UserGroup")->GetTable() + "_members";
-			query1.Type = DbQueryDelete;
+			query1.Type = DbQueryInsert;
 			query1.Category = DbCatConfig;
+			query1.Fields = new Dictionary();
+			query1.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */
+			query1.Fields->Set("contactgroup_id", DbValue::FromObjectInsertID(group));
+			query1.Fields->Set("contact_object_id", user);
 			query1.WhereCriteria = new Dictionary();
 			query1.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */
 			query1.WhereCriteria->Set("contactgroup_id", DbValue::FromObjectInsertID(group));
 			query1.WhereCriteria->Set("contact_object_id", user);
-			OnQuery(query1);
 
-			DbQuery query2;
-			query2.Table = DbType::GetByName("UserGroup")->GetTable() + "_members";
-			query2.Type = DbQueryInsert;
-			query2.Category = DbCatConfig;
-			query2.Fields = new Dictionary();
-			query2.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */
-			query2.Fields->Set("contactgroup_id", DbValue::FromObjectInsertID(group));
-			query2.Fields->Set("contact_object_id", user);
-			OnQuery(query2);
+			OnQuery(query1);
 		}
 	}
 



More information about the icinga-checkins mailing list