]> granicus.if.org Git - icinga2/commitdiff
Removed roles/publications.
authorGunnar Beutner <gunnar.beutner@netways.de>
Tue, 14 Aug 2012 08:53:04 +0000 (10:53 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Tue, 14 Aug 2012 08:53:04 +0000 (10:53 +0200)
19 files changed:
components/checker/checkercomponent.cpp
components/cibsync/cibsynccomponent.cpp
components/delegation/delegationcomponent.cpp
components/demo/democomponent.cpp
components/discovery/discoverycomponent.cpp
components/discovery/discoverycomponent.h
components/discovery/discoverymessage.cpp
components/discovery/discoverymessage.h
configure.ac
doc/icinga2-config.odt
icinga-app/icinga-checker1.conf
icinga-app/icinga-checker2.conf
icinga-app/icinga-standalone.conf
icinga-app/icinga1.conf
icinga-app/icinga2.conf
icinga-app/icinga3.conf
icinga/endpoint.cpp
icinga/endpoint.h
icinga/jsonrpcendpoint.cpp

index fe12717d5fc940f3b5c17ccc302191a9d8dfa114..ed98ee86d5953bca77a6704cf13b8afc1d0ee760 100644 (file)
@@ -24,7 +24,11 @@ using namespace icinga;
 void CheckerComponent::Start(void)
 {
        m_Endpoint = boost::make_shared<VirtualEndpoint>();
-       m_Endpoint->RegisterPublication("checker::ServiceStateChange");
+
+       /* dummy registration so the delegation module knows this is a checker
+          TODO: figure out a better way for this */
+       m_Endpoint->RegisterSubscription("checker");
+
        EndpointManager::GetInstance()->RegisterEndpoint(m_Endpoint);
 
        Service::OnCheckerChanged.connect(bind(&CheckerComponent::CheckerChangedHandler, this, _1));
index ecd4ebf579d0f7d7abd0c83b09058a67b25de8ee..a44a168fb27b63fe3f14bd59f96b4be8219eee18 100644 (file)
@@ -36,12 +36,8 @@ void CIBSyncComponent::Start(void)
        DynamicObject::OnUnregistered.connect(boost::bind(&CIBSyncComponent::LocalObjectUnregisteredHandler, this, _1));
        DynamicObject::OnTransactionClosing.connect(boost::bind(&CIBSyncComponent::TransactionClosingHandler, this, _1));
 
-       m_Endpoint->RegisterPublication("config::ObjectUpdate");
-       m_Endpoint->RegisterPublication("config::ObjectRemoved");
-
        EndpointManager::GetInstance()->OnNewEndpoint.connect(boost::bind(&CIBSyncComponent::NewEndpointHandler, this, _2));
 
-       m_Endpoint->RegisterPublication("config::FetchObjects");
        m_Endpoint->RegisterTopicHandler("config::ObjectUpdate",
            boost::bind(&CIBSyncComponent::RemoteObjectUpdateHandler, this, _2, _3));
        m_Endpoint->RegisterTopicHandler("config::ObjectRemoved",
index bc4a053af311357d7482180932fc079b1ef233e0..560dac5919d86dfd77630bbe7d4806485db9df6b 100644 (file)
@@ -33,7 +33,7 @@ void DelegationComponent::Start(void)
 
 bool DelegationComponent::IsEndpointChecker(const Endpoint::Ptr& endpoint)
 {
-       return (endpoint->HasPublication("checker::ServiceStateChange"));
+       return (endpoint->HasSubscription("checker"));
 }
 
 vector<Endpoint::Ptr> DelegationComponent::GetCheckerCandidates(const Service::Ptr& service) const
index 5e7158b23a452e2eae82fb6aa86536f711476493..edeae95c2fad247138b95049f390878b635bf90e 100644 (file)
@@ -29,7 +29,6 @@ void DemoComponent::Start(void)
        m_Endpoint = boost::make_shared<VirtualEndpoint>();
        m_Endpoint->RegisterTopicHandler("demo::HelloWorld",
            boost::bind(&DemoComponent::HelloWorldRequestHandler, this, _2, _3));
-       m_Endpoint->RegisterPublication("demo::HelloWorld");
        EndpointManager::GetInstance()->RegisterEndpoint(m_Endpoint);
 
        m_DemoTimer = boost::make_shared<Timer>();
index a34f1ed8210f8e57b2b838eafee1d04f4370b343..cdbfddb88b09b570169382606cfa5de248b62038 100644 (file)
@@ -28,11 +28,9 @@ void DiscoveryComponent::Start(void)
 {
        m_Endpoint = boost::make_shared<VirtualEndpoint>();
 
-       m_Endpoint->RegisterPublication("discovery::RegisterComponent");
        m_Endpoint->RegisterTopicHandler("discovery::RegisterComponent",
                boost::bind(&DiscoveryComponent::RegisterComponentMessageHandler, this, _2, _3));
 
-       m_Endpoint->RegisterPublication("discovery::NewComponent");
        m_Endpoint->RegisterTopicHandler("discovery::NewComponent",
                boost::bind(&DiscoveryComponent::NewComponentMessageHandler, this, _3));
 
@@ -101,12 +99,6 @@ void DiscoveryComponent::NewEndpointHandler(const Endpoint::Ptr& endpoint)
                return;
        }
 
-       /* accept discovery::RegisterComponent messages from any endpoint */
-       endpoint->RegisterPublication("discovery::RegisterComponent");
-
-       /* accept discovery::Welcome messages from any endpoint */
-       endpoint->RegisterPublication("discovery::Welcome");
-
        String identity = endpoint->GetIdentity();
 
        if (identity == EndpointManager::GetInstance()->GetIdentity()) {
@@ -156,10 +148,6 @@ void DiscoveryComponent::NewEndpointHandler(const Endpoint::Ptr& endpoint)
 
        // register published/subscribed topics for this endpoint
        ComponentDiscoveryInfo::Ptr info = ic->second;
-       BOOST_FOREACH(String publication, info->Publications) {
-               endpoint->RegisterPublication(publication);
-       }
-
        BOOST_FOREACH(String subscription, info->Subscriptions) {
                endpoint->RegisterSubscription(subscription);
        }
@@ -180,9 +168,6 @@ void DiscoveryComponent::DiscoveryEndpointHandler(const Endpoint::Ptr& endpoint,
 
        for (i = endpoint->BeginSubscriptions(); i != endpoint->EndSubscriptions(); i++)
                info->Subscriptions.insert(*i);
-
-       for (i = endpoint->BeginPublications(); i != endpoint->EndPublications(); i++)
-               info->Publications.insert(*i);
 }
 
 /**
@@ -295,41 +280,12 @@ void DiscoveryComponent::SendDiscoveryMessage(const String& method, const String
 
        params.SetSubscriptions(subscriptions);
 
-       Dictionary::Ptr publications = boost::make_shared<Dictionary>();
-       BOOST_FOREACH(String publication, info->Publications) {
-               publications->Add(publication);
-       }
-
-       params.SetPublications(publications);
-
        if (recipient)
                EndpointManager::GetInstance()->SendUnicastMessage(m_Endpoint, recipient, request);
        else
                EndpointManager::GetInstance()->SendMulticastMessage(m_Endpoint, request);
 }
 
-bool DiscoveryComponent::HasMessagePermission(const Dictionary::Ptr& roles, const String& messageType, const String& message)
-{
-       if (!roles)
-               return false;
-
-       Value roleName;
-       BOOST_FOREACH(tie(tuples::ignore, roleName), roles) {
-               DynamicObject::Ptr role = DynamicObject::GetObject("Role", roleName);
-               Dictionary::Ptr permissions = role->Get(messageType);
-               if (!permissions)
-                       continue;
-
-               Value permission;
-               BOOST_FOREACH(tie(tuples::ignore, permission), permissions) {
-                       if (Utility::Match(permission, message))
-                               return true;
-               }
-       }
-
-       return false;
-}
-
 /**
  * Processes a discovery message by registering the component in the
  * discovery component registry.
@@ -363,27 +319,13 @@ void DiscoveryComponent::ProcessDiscoveryMessage(const String& identity, const D
 
        Endpoint::Ptr endpoint = EndpointManager::GetInstance()->GetEndpointByIdentity(identity);
 
-       Dictionary::Ptr publications;
-       if (message.GetPublications(&publications)) {
-               Value publication;
-               BOOST_FOREACH(tie(tuples::ignore, publication), publications) {
-                       if (trusted || HasMessagePermission(roles, "publications", publication)) {
-                               info->Publications.insert(publication);
-                               if (endpoint)
-                                       endpoint->RegisterPublication(publication);
-                       }
-               }
-       }
-
        Dictionary::Ptr subscriptions;
        if (message.GetSubscriptions(&subscriptions)) {
                Value subscription;
                BOOST_FOREACH(tie(tuples::ignore, subscription), subscriptions) {
-                       if (trusted || HasMessagePermission(roles, "subscriptions", subscription)) {
-                               info->Subscriptions.insert(subscription);
-                               if (endpoint)
-                                       endpoint->RegisterSubscription(subscription);
-                       }
+                       info->Subscriptions.insert(subscription);
+                       if (endpoint)
+                               endpoint->RegisterSubscription(subscription);
                }
        }
 
@@ -490,7 +432,6 @@ void DiscoveryComponent::DiscoveryTimerHandler(void)
                        /* update LastSeen if we're still connected to this endpoint */
                        info->LastSeen = now;
                } else {
-                       /* TODO: figure out whether we actually want to connect to this component */
                        /* try and reconnect to this component */
                        try {
                                if (!info->Node.IsEmpty() && !info->Service.IsEmpty())
index 629d78b3e97bdfe955350331151b0cb2fe24657e..1160a5884c5f61053ac3c5a48f3fe770d89c1bcb 100644 (file)
@@ -74,8 +74,6 @@ private:
 
        void FinishDiscoverySetup(const Endpoint::Ptr& endpoint);
 
-       bool HasMessagePermission(const Dictionary::Ptr& roles, const String& messageType, const String& message);
-
        static const int RegistrationTTL = 300;
 };
 
index 6f22c7bd88606dc5abdfcc2ff80da2327b283951..fde9df491bd68cbc1385db2a5aa5aff69f4b23f6 100644 (file)
@@ -69,12 +69,3 @@ void DiscoveryMessage::SetSubscriptions(const Dictionary::Ptr& value)
        Set("subscriptions", value);
 }
 
-bool DiscoveryMessage::GetPublications(Dictionary::Ptr *value) const
-{
-       return Get("publications", value);
-}
-
-void DiscoveryMessage::SetPublications(const Dictionary::Ptr& value)
-{
-       Set("publications", value);
-}
index 9d6379afe24f9317f882e0416123b66d366b64ef..6f984b45193940f6f3b3aa923b6e566604d7486d 100644 (file)
@@ -43,9 +43,6 @@ public:
 
        bool GetSubscriptions(Dictionary::Ptr *value) const;
        void SetSubscriptions(const Dictionary::Ptr& value);
-
-       bool GetPublications(Dictionary::Ptr *value) const;
-       void SetPublications(const Dictionary::Ptr& value);
 };
 
 }
index 5dea77e1189b59308eab86ebfe6d1be3b69dfa3d..4d439c62ebdf42d290d9a70da0a222aacf146801 100644 (file)
@@ -53,6 +53,7 @@ AX_CXX_GCC_ABI_DEMANGLE
 AX_BOOST_BASE
 AX_BOOST_SIGNALS
 AX_BOOST_THREAD
+AX_BOOST_SYSTEM
 AX_BOOST_UNIT_TEST_FRAMEWORK
 AX_CHECK_OPENSSL([], [AC_MSG_ERROR([You need the OpenSSL headers and libraries in order to build this application])])
 AC_CHECK_LIB(ssl, SSL_new)
index f6243285755f909eb07036141b840c270afc834a..1cba65153ea20facc80d86cf03b3fe055a8b8445 100644 (file)
Binary files a/doc/icinga2-config.odt and b/doc/icinga2-config.odt differ
index b32ccb83a386cd13fff6e70445a9ec795ca207c3..c7c6f97a53c1670bd02ee7e10a293c0c732044d2 100644 (file)
@@ -20,11 +20,5 @@ local object Component "discovery" {
 local object Endpoint "icinga-c1" {
         node = "192.168.5.46",
         service = 7777,
-
-        roles = { "all" }
 }
 
-local object Role "all" {
-        publications = { "*" },
-        subscriptions = { "*" }
-}
index b249de745f91d63bce991439966bfd4a2b559995..70e8f9fc7e81f53415b040964a5ba9bd9dbe1336 100644 (file)
@@ -14,11 +14,5 @@ local object component "discovery" {
 local object endpoint "icinga-c1" {
        node = "192.168.5.46",
        service = 7777,
-
-       roles = { "all" }
 }
 
-local object role "all" {
-       publications = { "*" },
-       subscriptions = { "*" }
-}
index 897efddfc2c1ba8de0be7ab021ace063a9ebe6b4..a6acc464aa1c1f19cbedffc50fd8962d49493d5a 100644 (file)
@@ -3,7 +3,11 @@ local object Application "icinga" {
        ca = "ca.crt",
 
        node = "192.168.2.235",
-       service = 7777
+       service = 7777,
+
+       macros = {
+               plugindir = "/usr/local/icinga/libexec"
+       }
 }
 
 local object Component "discovery" {
@@ -22,23 +26,6 @@ local object Component "compat" {
 
 }
 
-local object Endpoint "icinga-c2" {
-       roles = { "all" }
-}
-
-local object Endpoint "icinga-c3" {
-       roles = { "all" }
-}
-
-local object Endpoint "icinga-c4" {
-       roles = { "all" }
-}
-
-local object Role "all" {
-       publications = { "*" },
-       subscriptions = { "*" }
-}
-
 object Host "localhost" {
 
 }
@@ -46,10 +33,6 @@ object Host "localhost" {
 abstract object Service "nagios-service" {
        methods = {
                check = "native::NagiosCheck"
-       },
-
-       macros = {
-               plugindir = "/usr/local/icinga/libexec"
        }
 }
 
index 35469dc4cd751cae4dda55af3ba290992d08fd0d..f24b3c11aba33ac1e1cda1514528f4a4566b989f 100644 (file)
@@ -17,19 +17,3 @@ 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 0b0b855323eaa6429c9f38928a24a4dfa2f0a93b..6dbee780c27523f9b4aa280a8ca3d23ec77ed9a3 100644 (file)
@@ -22,13 +22,6 @@ local object component "discovery" {
 local object endpoint "icinga-c3" {
        node = "192.168.5.46",
        service = 9999,
-
-       roles = { "all" }
-}
-
-local object role "all" {
-       publications = { "*" },
-       subscriptions = { "*" }
 }
 
 # --------------------------------------------
index 1793167f80c87328eadaf26743205f7b1b737646..7e880b11b5e041551ae9c8776e3aa61a64f01509 100644 (file)
@@ -19,11 +19,5 @@ local object component "discovery" {
 local object endpoint "icinga-c2" {
        node = "192.168.2.235",
        service = 7777,
-
-       roles = { "all" }
 }
 
-local object role "all" {
-       publications = { "*" },
-       subscriptions = { "*" }
-}
index d5466e8adeab572e9371544fd3b89094568d3e50..1209963dff7bb0128730132deb4f40c8eaef0fd2 100644 (file)
@@ -72,37 +72,6 @@ bool Endpoint::HasSubscription(String topic) const
        return (m_Subscriptions.find(topic) != m_Subscriptions.end());
 }
 
-/**
- * Registers a topic publication for this endpoint.
- *
- * @param topic The name of the topic.
- */
-void Endpoint::RegisterPublication(String topic)
-{
-       m_Publications.insert(topic);
-}
-
-/**
- * Removes a topic publication from this endpoint.
- *
- * @param topic The name of the topic.
- */
-void Endpoint::UnregisterPublication(String topic)
-{
-       m_Publications.erase(topic);
-}
-
-/**
- * Checks whether the endpoint  has a publication for the specified topic.
- *
- * @param topic The name of the topic.
- * @returns true if the endpoint is publishing this topic, false otherwise.
- */
-bool Endpoint::HasPublication(String topic) const
-{
-       return (m_Publications.find(topic) != m_Publications.end());
-}
-
 /**
  * Removes all subscriptions for the endpoint.
  */
@@ -111,14 +80,6 @@ void Endpoint::ClearSubscriptions(void)
        m_Subscriptions.clear();
 }
 
-/**
- * Removes all publications for the endpoint.
- */
-void Endpoint::ClearPublications(void)
-{
-       m_Publications.clear();
-}
-
 /**
  * Returns the beginning of the subscriptions list.
  *
@@ -139,26 +100,6 @@ Endpoint::ConstTopicIterator Endpoint::EndSubscriptions(void) const
        return m_Subscriptions.end();
 }
 
-/**
- * Returns the beginning of the publications list.
- *
- * @returns An iterator that points to the first publication.
- */
-Endpoint::ConstTopicIterator Endpoint::BeginPublications(void) const
-{
-       return m_Publications.begin();
-}
-
-/**
- * Returns the end of the publications list.
- *
- * @returns An iterator that points past the last publication.
- */
-Endpoint::ConstTopicIterator Endpoint::EndPublications(void) const
-{
-       return m_Publications.end();
-}
-
 /**
  * Sets whether a welcome message has been received from this endpoint.
  *
index d853dd61a0880132f8aab213b68fcfff03e82624..f6586bbe311f09869500d6063bb7e37d0cca09e1 100644 (file)
@@ -58,10 +58,6 @@ public:
        void UnregisterSubscription(String topic);
        bool HasSubscription(String topic) const;
 
-       void RegisterPublication(String topic);
-       void UnregisterPublication(String topic);
-       bool HasPublication(String topic) const;
-
        virtual bool IsLocal(void) const = 0;
        virtual bool IsConnected(void) const = 0;
 
@@ -71,21 +67,15 @@ public:
        virtual void Stop(void) = 0;
 
        void ClearSubscriptions(void);
-       void ClearPublications(void);
 
        ConstTopicIterator BeginSubscriptions(void) const;
        ConstTopicIterator EndSubscriptions(void) const;
 
-       ConstTopicIterator BeginPublications(void) const;
-       ConstTopicIterator EndPublications(void) const;
-
        boost::signal<void (const Endpoint::Ptr&)> OnSessionEstablished;
 
 private:
        set<String> m_Subscriptions; /**< The topics this endpoint is
                                          subscribed to. */
-       set<String> m_Publications; /**< The topics this endpoint is
-                                        publishing. */
        bool m_ReceivedWelcome; /**< Have we received a welcome message
                                     from this endpoint? */
        bool m_SentWelcome; /**< Have we sent a welcome message to this
index f392ccb307578a60be27cfca7f2bb4802445c0fe..e21215cc557ce86ee1714097ab407a40f9ee8156 100644 (file)
@@ -96,9 +96,6 @@ void JsonRpcEndpoint::NewMessageHandler(const MessagePart& message)
        if (!request.GetMethod(&method))
                return;
 
-       if (!HasPublication(method))
-               return;
-
        String id;
        if (request.GetID(&id))
                GetEndpointManager()->SendAnycastMessage(sender, request);
@@ -119,10 +116,9 @@ void JsonRpcEndpoint::ClientClosedHandler(void)
 
        Logger::Write(LogWarning, "jsonrpc", "Lost connection to endpoint: identity=" + GetIdentity());
 
-       // TODO: _only_ clear non-persistent publications/subscriptions
-       // unregister ourselves if no persistent publications/subscriptions are left (use a timer for that, once we have a TTL property for the topics)
+       // TODO: _only_ clear non-persistent subscriptions
+       // unregister ourselves if no persistent subscriptions are left (use a timer for that, once we have a TTL property for the topics)
        ClearSubscriptions();
-       ClearPublications();
 
        // remove the endpoint if there are no more subscriptions */
        if (BeginSubscriptions() == EndSubscriptions()) {