mirror of https://github.com/Icinga/icinga2.git
parent
978aeed741
commit
a3ea72c4ca
|
@ -35,6 +35,7 @@
|
|||
#include "base/serializer.hpp"
|
||||
#include "base/json.hpp"
|
||||
#include "base/exception.hpp"
|
||||
#include "base/scriptfunction.hpp"
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <boost/foreach.hpp>
|
||||
|
@ -46,6 +47,8 @@ ConfigItem::TypeMap ConfigItem::m_Items;
|
|||
ConfigItem::ItemList ConfigItem::m_UnnamedItems;
|
||||
ConfigItem::ItemList ConfigItem::m_CommittedItems;
|
||||
|
||||
REGISTER_SCRIPTFUNCTION(__commit, &ConfigItem::ScriptCommit);
|
||||
|
||||
/**
|
||||
* Constructor for the ConfigItem class.
|
||||
*
|
||||
|
@ -392,6 +395,29 @@ bool ConfigItem::ActivateItems(void)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ConfigItem::ScriptCommit(void)
|
||||
{
|
||||
WorkQueue upq(25000, Application::GetConcurrency());
|
||||
|
||||
if (!CommitNewItems(upq))
|
||||
return false;
|
||||
|
||||
BOOST_FOREACH(const DynamicType::Ptr& type, DynamicType::GetTypes()) {
|
||||
BOOST_FOREACH(const DynamicObject::Ptr& object, type->GetObjects()) {
|
||||
if (object->IsActive())
|
||||
continue;
|
||||
|
||||
#ifdef I2_DEBUG
|
||||
Log(LogDebug, "ConfigItem")
|
||||
<< "Activating object '" << object->GetName() << "' of type '" << object->GetType()->GetName() << "'";
|
||||
#endif /* I2_DEBUG */
|
||||
upq.Enqueue(boost::bind(&DynamicObject::Activate, object));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<ConfigItem::Ptr> ConfigItem::GetItems(const String& type)
|
||||
{
|
||||
std::vector<ConfigItem::Ptr> items;
|
||||
|
|
|
@ -67,6 +67,8 @@ public:
|
|||
static bool CommitItems(void);
|
||||
static bool ActivateItems(void);
|
||||
|
||||
static bool ScriptCommit(void);
|
||||
|
||||
static std::vector<ConfigItem::Ptr> GetItems(const String& type);
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue