]> granicus.if.org Git - icinga2/commitdiff
CompatIDO: implement first draft of {en,dis}able objects supported in ido2db 1.8...
authorMichael Friedrich <michael.friedrich@gmail.com>
Tue, 2 Oct 2012 23:25:44 +0000 (01:25 +0200)
committerMichael Friedrich <michael.friedrich@gmail.com>
Tue, 2 Oct 2012 23:25:44 +0000 (01:25 +0200)
components/compatido/compatidocomponent.cpp
components/compatido/compatidocomponent.h

index 6a663c8c8e50f831cfb2d94acf16f566f1d1b8c7..d61490ec2f0814047122492738f7529ea0a0a9fc 100644 (file)
@@ -243,6 +243,71 @@ void CompatIdoComponent::EndConfigDump(void)
         m_IdoSocket->SendMessage(message.str());
 }
 
+/**
+ * enables host config object in ido
+ */
+void CompatIdoComponent::EnableHostObject(const Host::Ptr& host)
+{
+       stringstream message;
+       message << "\n"
+               << 500 << ":" << "\n"                                   /* enableobject */
+               << 4 << "=" << std::setprecision(17) << Utility::GetTime() << "\n"              /* timestamp */
+               << 53 << "=" << host->GetName() << "\n"                 /* host */
+                << 999 << "\n\n";                                      /* enddata */
+
+        m_IdoSocket->SendMessage(message.str());
+}
+
+/**
+ * enables service config object in ido
+ */
+void CompatIdoComponent::EnableServiceObject(const Service::Ptr& service)
+{
+        stringstream message;
+        message << "\n"
+                << 500 << ":" << "\n"                                   /* enableobject */
+                << 4 << "=" << std::setprecision(17) << Utility::GetTime() << "\n"              /* timestamp */
+                << 53 << "=" << service->GetHost()->GetName() << "\n"   /* host */
+                << 114 << "=" << service->GetAlias() << "\n"            /* service */
+                << 999 << "\n\n";                                       /* enddata */
+
+        m_IdoSocket->SendMessage(message.str());
+}
+
+/**
+ * disables host config object in ido
+ */
+void CompatIdoComponent::DisableHostObject(const Host::Ptr& host)
+{
+        stringstream message;
+        message << "\n"
+                << 501 << ":" << "\n"                                   /* disableobject */
+                << 4 << "=" << std::setprecision(17) << Utility::GetTime() << "\n"              /* timestamp */
+                << 53 << "=" << host->GetName() << "\n"                 /* host */
+                << 999 << "\n\n";                                       /* enddata */
+
+        m_IdoSocket->SendMessage(message.str());
+}
+
+/**
+ * disables service config object in ido
+ */
+void CompatIdoComponent::DisableServiceObject(const Service::Ptr& service)
+{
+        stringstream message;
+        message << "\n"
+                << 501 << ":" << "\n"                                   /* disableobject */
+                << 4 << "=" << std::setprecision(17) << Utility::GetTime() << "\n"              /* timestamp */
+                << 53 << "=" << service->GetHost()->GetName() << "\n"   /* host */
+                << 114 << "=" << service->GetAlias() << "\n"            /* service */
+                << 999 << "\n\n";                                       /* enddata */
+        m_IdoSocket->SendMessage(message.str());
+}
+
+
+
+
 /**
  * dump host config to ido
  *
@@ -629,6 +694,8 @@ void CompatIdoComponent::DumpConfigObjects(void)
                }
 
                DumpHostObject(host);
+               //FIXME remove me, debug only XXX
+               //DisableHostObject(host);
        }
 
        pair<String, vector<String > > hgt;
@@ -673,6 +740,8 @@ void CompatIdoComponent::DumpConfigObjects(void)
                }
 
                DumpServiceObject(service);
+               //FIXME remove me, debug only XXX
+               //DisableServiceObject(service);
        }
 
        pair<String, vector<Service::Ptr> > sgt;
index 1f319b44267ad3bcdb1a1cd516473fb3a380eb1e..4a3fd33457277b8bbb898ed02b302aedaa01682e 100644 (file)
@@ -53,6 +53,11 @@ private:
        void StartConfigDump(void);
        void EndConfigDump(void);
 
+       void EnableHostObject(const Host::Ptr& host);
+       void EnableServiceObject(const Service::Ptr& service);
+       void DisableHostObject(const Host::Ptr& host);
+       void DisableServiceObject(const Service::Ptr& service);
+
        void DumpConfigObjects(void);
        void DumpHostObject(const Host::Ptr& host);
        void DumpServiceObject(const Service::Ptr& service);