mirror of https://github.com/Icinga/icinga2.git
Fix missing insert IDs for service and contact groups.
This commit is contained in:
parent
17f1b98575
commit
ddc8a9cd7e
|
@ -20,7 +20,6 @@
|
||||||
#include "ido/servicegroupdbobject.h"
|
#include "ido/servicegroupdbobject.h"
|
||||||
#include "ido/dbtype.h"
|
#include "ido/dbtype.h"
|
||||||
#include "ido/dbvalue.h"
|
#include "ido/dbvalue.h"
|
||||||
#include "icinga/servicegroup.h"
|
|
||||||
#include "base/objectlock.h"
|
#include "base/objectlock.h"
|
||||||
#include "base/initialize.h"
|
#include "base/initialize.h"
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
|
@ -36,7 +35,7 @@ ServiceGroupDbObject::ServiceGroupDbObject(const DbType::Ptr& type, const String
|
||||||
|
|
||||||
void ServiceGroupDbObject::StaticInitialize(void)
|
void ServiceGroupDbObject::StaticInitialize(void)
|
||||||
{
|
{
|
||||||
ServiceGroup::OnMembersChanged.connect(&ServiceGroupDbObject::MembersChangedHandler);
|
ServiceGroup::OnMembersChanged.connect(boost::bind(&ServiceGroupDbObject::MembersChangedHandler, ServiceGroup::Ptr()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary::Ptr ServiceGroupDbObject::GetConfigFields(void) const
|
Dictionary::Ptr ServiceGroupDbObject::GetConfigFields(void) const
|
||||||
|
@ -56,10 +55,12 @@ Dictionary::Ptr ServiceGroupDbObject::GetStatusFields(void) const
|
||||||
|
|
||||||
void ServiceGroupDbObject::OnConfigUpdate(void)
|
void ServiceGroupDbObject::OnConfigUpdate(void)
|
||||||
{
|
{
|
||||||
MembersChangedHandler();
|
ServiceGroup::Ptr group = static_pointer_cast<ServiceGroup>(GetObject());
|
||||||
|
|
||||||
|
MembersChangedHandler(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServiceGroupDbObject::MembersChangedHandler(void)
|
void ServiceGroupDbObject::MembersChangedHandler(const ServiceGroup::Ptr& sgfilter)
|
||||||
{
|
{
|
||||||
DbQuery query1;
|
DbQuery query1;
|
||||||
query1.Table = DbType::GetByName("ServiceGroup")->GetTable() + "_members";
|
query1.Table = DbType::GetByName("ServiceGroup")->GetTable() + "_members";
|
||||||
|
@ -71,6 +72,9 @@ void ServiceGroupDbObject::MembersChangedHandler(void)
|
||||||
BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects("ServiceGroup")) {
|
BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects("ServiceGroup")) {
|
||||||
ServiceGroup::Ptr sg = static_pointer_cast<ServiceGroup>(object);
|
ServiceGroup::Ptr sg = static_pointer_cast<ServiceGroup>(object);
|
||||||
|
|
||||||
|
if (sgfilter && sgfilter != sg)
|
||||||
|
continue;
|
||||||
|
|
||||||
BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
|
BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
|
||||||
DbQuery query2;
|
DbQuery query2;
|
||||||
query2.Table = DbType::GetByName("ServiceGroup")->GetTable() + "_members";
|
query2.Table = DbType::GetByName("ServiceGroup")->GetTable() + "_members";
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#define SERVICEGROUPDBOBJECT_H
|
#define SERVICEGROUPDBOBJECT_H
|
||||||
|
|
||||||
#include "ido/dbobject.h"
|
#include "ido/dbobject.h"
|
||||||
|
#include "icinga/servicegroup.h"
|
||||||
#include "base/dynamicobject.h"
|
#include "base/dynamicobject.h"
|
||||||
|
|
||||||
namespace icinga
|
namespace icinga
|
||||||
|
@ -47,7 +48,7 @@ protected:
|
||||||
virtual void OnConfigUpdate(void);
|
virtual void OnConfigUpdate(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void MembersChangedHandler(void);
|
static void MembersChangedHandler(const ServiceGroup::Ptr& sgfilter);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
#include "ido/usergroupdbobject.h"
|
#include "ido/usergroupdbobject.h"
|
||||||
#include "ido/dbtype.h"
|
#include "ido/dbtype.h"
|
||||||
#include "ido/dbvalue.h"
|
#include "ido/dbvalue.h"
|
||||||
#include "icinga/usergroup.h"
|
|
||||||
#include "base/objectlock.h"
|
#include "base/objectlock.h"
|
||||||
#include "base/initialize.h"
|
#include "base/initialize.h"
|
||||||
#include "base/dynamictype.h"
|
#include "base/dynamictype.h"
|
||||||
|
@ -37,7 +36,7 @@ UserGroupDbObject::UserGroupDbObject(const DbType::Ptr& type, const String& name
|
||||||
|
|
||||||
void UserGroupDbObject::StaticInitialize(void)
|
void UserGroupDbObject::StaticInitialize(void)
|
||||||
{
|
{
|
||||||
UserGroup::OnMembersChanged.connect(&UserGroupDbObject::MembersChangedHandler);
|
UserGroup::OnMembersChanged.connect(boost::bind(&UserGroupDbObject::MembersChangedHandler, UserGroup::Ptr()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary::Ptr UserGroupDbObject::GetConfigFields(void) const
|
Dictionary::Ptr UserGroupDbObject::GetConfigFields(void) const
|
||||||
|
@ -57,10 +56,12 @@ Dictionary::Ptr UserGroupDbObject::GetStatusFields(void) const
|
||||||
|
|
||||||
void UserGroupDbObject::OnConfigUpdate(void)
|
void UserGroupDbObject::OnConfigUpdate(void)
|
||||||
{
|
{
|
||||||
MembersChangedHandler();
|
UserGroup::Ptr group = static_pointer_cast<UserGroup>(GetObject());
|
||||||
|
|
||||||
|
MembersChangedHandler(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserGroupDbObject::MembersChangedHandler(void)
|
void UserGroupDbObject::MembersChangedHandler(const UserGroup::Ptr& ugfilter)
|
||||||
{
|
{
|
||||||
DbQuery query1;
|
DbQuery query1;
|
||||||
query1.Table = DbType::GetByName("UserGroup")->GetTable() + "_members";
|
query1.Table = DbType::GetByName("UserGroup")->GetTable() + "_members";
|
||||||
|
@ -72,6 +73,9 @@ void UserGroupDbObject::MembersChangedHandler(void)
|
||||||
BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects("UserGroup")) {
|
BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects("UserGroup")) {
|
||||||
UserGroup::Ptr ug = static_pointer_cast<UserGroup>(object);
|
UserGroup::Ptr ug = static_pointer_cast<UserGroup>(object);
|
||||||
|
|
||||||
|
if (ugfilter && ugfilter != ug)
|
||||||
|
continue;
|
||||||
|
|
||||||
BOOST_FOREACH(const User::Ptr& user, ug->GetMembers()) {
|
BOOST_FOREACH(const User::Ptr& user, ug->GetMembers()) {
|
||||||
DbQuery query2;
|
DbQuery query2;
|
||||||
query2.Table = DbType::GetByName("UserGroup")->GetTable() + "_members";
|
query2.Table = DbType::GetByName("UserGroup")->GetTable() + "_members";
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#define USERGROUPDBOBJECT_H
|
#define USERGROUPDBOBJECT_H
|
||||||
|
|
||||||
#include "ido/dbobject.h"
|
#include "ido/dbobject.h"
|
||||||
|
#include "icinga/usergroup.h"
|
||||||
#include "base/dynamicobject.h"
|
#include "base/dynamicobject.h"
|
||||||
|
|
||||||
namespace icinga
|
namespace icinga
|
||||||
|
@ -47,7 +48,7 @@ protected:
|
||||||
virtual void OnConfigUpdate(void);
|
virtual void OnConfigUpdate(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void MembersChangedHandler(void);
|
static void MembersChangedHandler(const UserGroup::Ptr& ugfilter);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue