mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-26 15:14:07 +02:00
Fix: State file doesn't work for generated service objects.
This commit is contained in:
parent
fa9ab6c768
commit
91724814d8
@ -68,9 +68,17 @@ Dictionary::Ptr DynamicObject::Serialize(int attributeTypes) const
|
|||||||
void DynamicObject::Deserialize(const Dictionary::Ptr& update, int attributeTypes)
|
void DynamicObject::Deserialize(const Dictionary::Ptr& update, int attributeTypes)
|
||||||
{
|
{
|
||||||
ASSERT(!OwnsLock());
|
ASSERT(!OwnsLock());
|
||||||
ObjectLock olock(this);
|
|
||||||
|
|
||||||
InternalDeserialize(update, attributeTypes);
|
{
|
||||||
|
ObjectLock olock(this);
|
||||||
|
InternalDeserialize(update, attributeTypes);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (attributeTypes & Attribute_Config)
|
||||||
|
OnConfigLoaded();
|
||||||
|
|
||||||
|
if (attributeTypes & Attribute_State)
|
||||||
|
OnStateLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicObject::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
|
void DynamicObject::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const
|
||||||
@ -176,6 +184,16 @@ void DynamicObject::Stop(void)
|
|||||||
OnStopped(GetSelf());
|
OnStopped(GetSelf());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DynamicObject::OnConfigLoaded(void)
|
||||||
|
{
|
||||||
|
/* Nothing to do here. */
|
||||||
|
}
|
||||||
|
|
||||||
|
void DynamicObject::OnStateLoaded(void)
|
||||||
|
{
|
||||||
|
/* Nothing to do here. */
|
||||||
|
}
|
||||||
|
|
||||||
Value DynamicObject::InvokeMethod(const String& method,
|
Value DynamicObject::InvokeMethod(const String& method,
|
||||||
const std::vector<Value>& arguments)
|
const std::vector<Value>& arguments)
|
||||||
{
|
{
|
||||||
|
@ -102,6 +102,9 @@ protected:
|
|||||||
virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
|
virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
|
||||||
virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
|
virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
|
||||||
|
|
||||||
|
virtual void OnConfigLoaded(void);
|
||||||
|
virtual void OnStateLoaded(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
String m_Name;
|
String m_Name;
|
||||||
String m_Type;
|
String m_Type;
|
||||||
|
@ -56,7 +56,10 @@ void Host::Start(void)
|
|||||||
hg->AddMember(GetSelf());
|
hg->AddMember(GetSelf());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Host::OnConfigLoaded(void)
|
||||||
|
{
|
||||||
UpdateSlaveServices();
|
UpdateSlaveServices();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,6 +127,8 @@ protected:
|
|||||||
virtual void Start(void);
|
virtual void Start(void);
|
||||||
virtual void Stop(void);
|
virtual void Stop(void);
|
||||||
|
|
||||||
|
virtual void OnConfigLoaded(void);
|
||||||
|
|
||||||
virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
|
virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
|
||||||
virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
|
virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
|
||||||
|
|
||||||
|
@ -44,6 +44,12 @@ void Service::Start(void)
|
|||||||
SetSchedulingOffset(rand());
|
SetSchedulingOffset(rand());
|
||||||
UpdateNextCheck();
|
UpdateNextCheck();
|
||||||
|
|
||||||
|
AddDowntimesToCache();
|
||||||
|
AddCommentsToCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Service::OnConfigLoaded(void)
|
||||||
|
{
|
||||||
Array::Ptr groups = GetGroups();
|
Array::Ptr groups = GetGroups();
|
||||||
|
|
||||||
if (groups) {
|
if (groups) {
|
||||||
@ -55,12 +61,11 @@ void Service::Start(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AddDowntimesToCache();
|
|
||||||
AddCommentsToCache();
|
|
||||||
|
|
||||||
Host::Ptr host = GetHost();
|
Host::Ptr host = GetHost();
|
||||||
if (host)
|
if (host)
|
||||||
host->AddService(GetSelf());
|
host->AddService(GetSelf());
|
||||||
|
|
||||||
|
UpdateSlaveNotifications();
|
||||||
}
|
}
|
||||||
|
|
||||||
String Service::GetDisplayName(void) const
|
String Service::GetDisplayName(void) const
|
||||||
|
@ -332,6 +332,8 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
virtual void Start(void);
|
virtual void Start(void);
|
||||||
|
|
||||||
|
virtual void OnConfigLoaded(void);
|
||||||
|
|
||||||
virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
|
virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
|
||||||
virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
|
virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
|
||||||
|
|
||||||
|
@ -27,10 +27,8 @@ using namespace icinga;
|
|||||||
|
|
||||||
REGISTER_TYPE(User);
|
REGISTER_TYPE(User);
|
||||||
|
|
||||||
void User::Start(void)
|
void User::OnConfigLoaded(void)
|
||||||
{
|
{
|
||||||
DynamicObject::Start();
|
|
||||||
|
|
||||||
Array::Ptr groups = GetGroups();
|
Array::Ptr groups = GetGroups();
|
||||||
|
|
||||||
if (groups) {
|
if (groups) {
|
||||||
|
@ -57,9 +57,10 @@ public:
|
|||||||
virtual bool ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *result) const;
|
virtual bool ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *result) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Start(void);
|
|
||||||
virtual void Stop(void);
|
virtual void Stop(void);
|
||||||
|
|
||||||
|
virtual void OnConfigLoaded(void);
|
||||||
|
|
||||||
virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
|
virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
|
||||||
virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
|
virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user