mirror of https://github.com/Icinga/icinga2.git
Bugfixes.
This commit is contained in:
parent
d45bcf99b1
commit
0270d9cf52
|
@ -44,11 +44,11 @@ public:
|
|||
void Start(void)
|
||||
{
|
||||
m_Parent->OnObjectAdded += bind_weak(&ObjectMap::ObjectAddedHandler, shared_from_this());
|
||||
m_Parent->OnObjectCommitted += bind_weak(&ObjectMap::ObjectCommittedHandler, shared_from_this());
|
||||
m_Parent->OnObjectRemoved += bind_weak(&ObjectMap::ObjectRemovedHandler, shared_from_this());
|
||||
m_Parent->OnObjectCommitted += bind_weak(&ObjectMap::ObjectCommittedHandler, shared_from_this());
|
||||
m_Parent->OnObjectRemoved += bind_weak(&ObjectMap::ObjectRemovedHandler, shared_from_this());
|
||||
|
||||
for (typename ObjectSet<TValue>::Iterator it = m_Parent->Begin(); it != m_Parent->End(); it++)
|
||||
AddObject(*it);
|
||||
for (typename ObjectSet<TValue>::Iterator it = m_Parent->Begin(); it != m_Parent->End(); it++)
|
||||
AddObject(*it);
|
||||
}
|
||||
|
||||
Range GetRange(TKey key)
|
||||
|
|
|
@ -74,13 +74,12 @@ public:
|
|||
*/
|
||||
void operator()(const TArgs& args)
|
||||
{
|
||||
typename vector<ObserverType>::iterator i;
|
||||
|
||||
for (i = m_Observers.begin(); i != m_Observers.end(); ) {
|
||||
int result = (*i)(args);
|
||||
vector<ObserverType>::size_type i = 0;
|
||||
for (i = 0; i < m_Observers.size(); i++) {
|
||||
int result = m_Observers[i](args);
|
||||
|
||||
if (result == -1)
|
||||
i = m_Observers.erase(i);
|
||||
m_Observers.erase(m_Observers.begin() + i);
|
||||
else
|
||||
i++;
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ vector<ConfigItem::Ptr> ConfigCompiler::CompileStream(istream *stream)
|
|||
vector<ConfigItem::Ptr> ConfigCompiler::CompileFile(const string& filename)
|
||||
{
|
||||
ifstream stream;
|
||||
stream.exceptions(ifstream::badbit);
|
||||
stream.open(filename, ifstream::in);
|
||||
return CompileStream(&stream);
|
||||
}
|
||||
|
|
|
@ -1,39 +1,36 @@
|
|||
{
|
||||
"icinga": {
|
||||
"icinga": {
|
||||
"replicate": "0",
|
||||
"privkey": "icinga-c1.key",
|
||||
"pubkey": "icinga-c1.crt",
|
||||
"cakey": "ca.crt",
|
||||
"node": "10.0.10.14",
|
||||
"service": "7777"
|
||||
}
|
||||
},
|
||||
"component": {
|
||||
"configrpc": { "replicate": "0", "configSource": "1" },
|
||||
"demo": { "replicate": "0" },
|
||||
"discovery": { "replicate": "0", "broker": "1" }
|
||||
},
|
||||
"host": {
|
||||
"localhost": { "node": "127.0.0.1" }
|
||||
},
|
||||
"endpoint": {
|
||||
"icinga-c2": {
|
||||
"replicate": "0",
|
||||
"roles": [ "demo" ]
|
||||
},
|
||||
"icinga-c3": {
|
||||
"replicate": "0",
|
||||
"roles": [ "demo" ]
|
||||
}
|
||||
},
|
||||
"role": {
|
||||
"broker": {
|
||||
"publications": [ "discovery::NewComponent" ]
|
||||
},
|
||||
"demo": {
|
||||
"publications": [ "demo::*" ],
|
||||
"subscriptions": [ "demo::*" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
local object application "icinga" {
|
||||
privkey = "icinga-c1.key",
|
||||
pubkey = "icinga-c1.crt",
|
||||
cakey = "ca.crt",
|
||||
|
||||
node = "10.0.10.14",
|
||||
service = 7777
|
||||
}
|
||||
|
||||
local object component "configrpc" {
|
||||
configSource = 1
|
||||
}
|
||||
|
||||
local object component "demo" {
|
||||
}
|
||||
|
||||
local object component "discovery" {
|
||||
broker = 1
|
||||
}
|
||||
|
||||
local object endpoint "icinga-c2" {
|
||||
roles = { "demo" }
|
||||
}
|
||||
|
||||
local object endpoint "icinga-c3" {
|
||||
roles = { "demo" }
|
||||
}
|
||||
|
||||
local object role "broker" {
|
||||
publications = { "discovery::NewComponent" }
|
||||
}
|
||||
|
||||
local object role "demo" {
|
||||
publications = { "demo::*" },
|
||||
subscriptions = { "demo::*" }
|
||||
}
|
||||
|
|
|
@ -29,7 +29,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "icinga-app", "icinga-app\ic
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "configfile", "components\configfile\configfile.vcxproj", "{E58F1DA7-B723-412B-B2B7-7FF58E2A944E}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{C1FC77E1-04A4-481B-A78B-2F7AF489C2F8} = {C1FC77E1-04A4-481B-A78B-2F7AF489C2F8}
|
||||
{9C92DA90-FD53-43A9-A244-90F2E8AF9677} = {9C92DA90-FD53-43A9-A244-90F2E8AF9677}
|
||||
{B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7} = {B26AFFA6-2BDF-42E6-A224-2591FFD9BFB7}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "configrpc", "components\configrpc\configrpc.vcxproj", "{697C6D7E-3109-484C-A7AF-384D28711610}"
|
||||
|
|
|
@ -52,6 +52,19 @@ int IcingaApplication::Main(const vector<string>& args)
|
|||
string componentDirectory = GetExeDirectory() + "/../lib/icinga2";
|
||||
AddComponentSearchDir(componentDirectory);
|
||||
|
||||
/* register handler for 'component' config objects */
|
||||
static ConfigObject::Set::Ptr componentObjects = make_shared<ConfigObject::Set>(ConfigObject::GetAllObjects(), ConfigObject::MakeTypePredicate("component"));
|
||||
function<int (const ObjectSetEventArgs<ConfigObject::Ptr>&)> NewComponentHandler = bind_weak(&IcingaApplication::NewComponentHandler, shared_from_this());
|
||||
componentObjects->OnObjectAdded += NewComponentHandler;
|
||||
componentObjects->OnObjectCommitted += NewComponentHandler;
|
||||
componentObjects->OnObjectRemoved += bind_weak(&IcingaApplication::DeletedComponentHandler, shared_from_this());
|
||||
componentObjects->Start();
|
||||
|
||||
/* load config file */
|
||||
ConfigObject::Ptr fileComponentConfig = make_shared<ConfigObject>("component", "configfile");
|
||||
fileComponentConfig->SetProperty("configFilename", args[1]);
|
||||
fileComponentConfig->Commit();
|
||||
|
||||
ConfigObject::Ptr icingaConfig = ConfigObject::GetObject("application", "icinga");
|
||||
|
||||
if (!icingaConfig)
|
||||
|
@ -66,19 +79,6 @@ int IcingaApplication::Main(const vector<string>& args)
|
|||
icingaConfig->GetProperty("node", &m_Node);
|
||||
icingaConfig->GetProperty("service", &m_Service);
|
||||
|
||||
/* register handler for 'component' config objects */
|
||||
static ConfigObject::Set::Ptr componentObjects = make_shared<ConfigObject::Set>(ConfigObject::GetAllObjects(), ConfigObject::MakeTypePredicate("component"));
|
||||
function<int (const ObjectSetEventArgs<ConfigObject::Ptr>&)> NewComponentHandler = bind_weak(&IcingaApplication::NewComponentHandler, shared_from_this());
|
||||
componentObjects->OnObjectAdded += NewComponentHandler;
|
||||
componentObjects->OnObjectCommitted += NewComponentHandler;
|
||||
componentObjects->OnObjectRemoved += bind_weak(&IcingaApplication::DeletedComponentHandler, shared_from_this());
|
||||
componentObjects->Start();
|
||||
|
||||
/* load config file */
|
||||
ConfigObject::Ptr fileComponentConfig = make_shared<ConfigObject>("component", "configfile");
|
||||
fileComponentConfig->GetProperties()->SetProperty("configFilename", args[1]);
|
||||
fileComponentConfig->Commit();
|
||||
|
||||
if (!GetPrivateKeyFile().empty() && !GetPublicKeyFile().empty() && !GetCAKeyFile().empty()) {
|
||||
/* set up SSL context */
|
||||
shared_ptr<X509> cert = Utility::GetX509Certificate(GetPublicKeyFile());
|
||||
|
|
Loading…
Reference in New Issue