]> granicus.if.org Git - icinga2/commitdiff
Bugfixes.
authorGunnar Beutner <gunnar@beutner.name>
Tue, 12 Jun 2012 08:49:30 +0000 (10:49 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Tue, 12 Jun 2012 08:49:30 +0000 (10:49 +0200)
base/objectmap.h
base/observable.h
dyn/configcompiler.cpp
icinga-app/icinga1.conf
icinga.sln
icinga/icingaapplication.cpp

index 6456ab4c478b7278c2dd5adb871b0e58d2c9e8c5..2411d542e391a1b0d9ffe14f5957078f77b497ca 100644 (file)
@@ -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)
index 26721895a6090b78cf6b2bf14c8a2ecb28f5a9cc..6fafa0b4794cc2c72604fe28e6fc96c847badc87 100644 (file)
@@ -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++;
                }
index 090015226e6c574cd30584bc028748cb50d8e107..978f86b17c4e9c6e6b3d5a90baef226bb3cb1fab 100644 (file)
@@ -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);
 }
index 679874d3ef5d386d821265a675ca1b22e54f2d01..9dbfb2a56a57ecbb5eea713c16b7cb4e3ef4a93c 100644 (file)
@@ -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::*" ]
-               }
-       }
-}
\ No newline at end of file
+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::*" }
+}
index f9766e2d60ba3bd70fe453e76346ec6ed818d400..1cfbaaa5fa08858c1c6d3f3f0cfce86d74c38262 100644 (file)
@@ -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}"
index f4c326848310ecd82e923e5ac3203fbc2f157a9f..642c4df4ac3c31ceff7753bae6b6ff643bc8a0fd 100644 (file)
@@ -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());