Centralize readthedocs docs
[ccsdk/distribution.git] / docs / platform / plugins / dmaap.rst
1 Cloudify DMaaP Plugin
2 ---------------------
3
4 Cloudify plugin for creating and managing DMaaP Data Router feeds and
5 subscriptions and DMaaP Message Router topics. The plugin uses the DMaaP
6 Bus Controller API.
7
8 Plugin Support for DMaaP Data Router
9 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10
11 Plugin Types for DMaaP Data Router
12 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13
14 The Cloudify type definitions for DMaaP Data Router nodes and
15 relationships are defined in ```dmaap.yaml`` <./dmaap.yaml>`__.
16
17 There are four node types for DMaaP Data Router:
18
19 -  ``ccsdk.nodes.Feed``: This type represents a feed that does not yet
20    exist and that should be created when the install workflow is run
21    against a blueprint that contains a node of this type.
22
23 +------------------------+----------+-------------+---------------------------------------------------------------------------------------------+
24 | Property               | Type     | Required?   | Description                                                                                 |
25 +========================+==========+=============+=============================================================================================+
26 | feed\_name             | string   | no          | a name that identifies the feed (plugin will generate if absent)                            |
27 +------------------------+----------+-------------+---------------------------------------------------------------------------------------------+
28 | feed\_version          | string   | no          | version number for the feed (feed\_name + feed\_version uniquely identify the feed in DR)   |
29 +------------------------+----------+-------------+---------------------------------------------------------------------------------------------+
30 | feed\_description      | string   | no          | human-readable description of the feed                                                      |
31 +------------------------+----------+-------------+---------------------------------------------------------------------------------------------+
32 | aspr\_classification   | string   | no          | AT&T ASPR classification of the feed                                                        |
33 +------------------------+----------+-------------+---------------------------------------------------------------------------------------------+
34
35 -  ``ccsdk.nodes.ExistingFeed``: This type represents a feed that
36    already exists. Nodes of this type are placed in a blueprint so that
37    other nodes in the blueprint can be set up as publishers or
38    subscribers to the feed. The table below shows the properties that a
39    node of this type may have.
40
41 +------------+----------+-------------+---------------------------------------------------------------+
42 | Property   | Type     | Required?   | Description                                                   |
43 +============+==========+=============+===============================================================+
44 | feed\_id   | string   | yes         | Feed identifier assigned by DMaaP when the feed was created   |
45 +------------+----------+-------------+---------------------------------------------------------------+
46
47 -  ``ccsdk.nodes.ExternalTargetFeed``: This type represents a feed
48    created in an external DMaaP environment (i.e., an environment that
49    the plugin cannot access to make provisioning requests, such as a
50    shared corporate system). Nodes of this type are placed in a
51    blueprint so that other feed nodes of type ``ccsdk.nodes.Feed`` or
52    ``ccsdk.nodes.ExistingFeed`` can be set up to "bridge" to external
53    feeds by publishing data to the external feeds. The table below shows
54    the properties that a node of this type may have.
55
56 +------------+----------+-------------+----------------------------------------------------------------+
57 | Property   | Type     | Required?   | Description                                                    |
58 +============+==========+=============+================================================================+
59 | url        | string   | yes         | The publish URL of the external feed.                          |
60 +------------+----------+-------------+----------------------------------------------------------------+
61 | username   | string   | yes         | The username to be used when delivering to the external feed   |
62 +------------+----------+-------------+----------------------------------------------------------------+
63 | userpw     | string   | yes         | The password to be used when delivering to the external feed   |
64 +------------+----------+-------------+----------------------------------------------------------------+
65
66 *Note: These properties are usually obtained by manually creating a feed
67 in the external DMaaP DR system and then creating a publisher for that
68 feed.*
69
70 -  ``ccsdk.nodes.ExternalSourceFeed``: This type represents a feed
71    created in an external DMaaP environment (i.e., an environment that
72    the plugin cannot access to makes provisioning requests, such as a
73    shared corporate system). Nodes of this type are place in a blueprint
74    so that they can be set up to "bridge" to other feed nodes of type
75    ``ccsdk.nodes.Feed`` or ``ccsdk.nodes.ExistingFeed``. This type has
76    no node properties, but when a bridge is set up, the url, username,
77    and password are attached to the node as runtime\_properties, using
78    the name of the target feed node as the top-level key.
79
80 There are five relationship types for DMaaP Data Router:
81
82 -  ``ccsdk.relationships.publish_files``, used to indicate that the
83    relationship's source node sends is a publisher to the Data Router
84    feed represented by the relationship's target node.
85 -  ``ccsdk.relationships.subscribe_to_files``, used to indicate that the
86    relationship's source node is a subscriber to the Data Router feed
87    represented by the relationship's target node.
88 -  ``ccsdk.relationships.bridges_to``, used to indicate that the
89    relationship's source node (a ``ccsdk.nodes.Feed`` or
90    ``ccsdk.nodes.ExistingFeed``) should be set up to forward data
91    ("bridge") to the relationship's target feed (another
92    ``ccsdk.nodes.Feed`` or ``ccsdk.nodes.ExistingFeed``).
93 -  ``ccsdk.relationships.bridges_to_external``, used to indicate that
94    the relationship's source node (a ``ccsdk.nodes.Feed`` or
95    ``ccsdk.nodes.ExistingFeed``) should be set up to forward data
96    ("bridge") to the relationship's target node (a feed in an external
97    DMaaP system, represented by a ``ccsdk.nodes.ExternalTargetFeed``
98    node).
99 -  ``ccsdk.relationships.bridges_from_external_to_internal``, used to
100    indicate the the relationship's source node (a feed in an external
101    DMaaP system, represented by a ``ccsdk.nodes.ExternalSourceFeed``
102    node) should be set up to forward date ("bridge") to the
103    relationship's target node (an internal ONAP feed, represented by a
104    ``ccsdk.nodes.Feed`` or ``ccsdk.nodes.ExistingFeed`` node).
105
106 The plugin code implements the lifecycle operations needed to create and
107 delete feeds and to add and remove publishers and subscribers. It also
108 implements the operations needed to set up bridging between feeds.
109
110 Interaction with Other Plugins
111 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
112
113 When creating a new feed or processing a reference to an existing feed,
114 the plugin operates independently of other plugins.
115
116 When processing a ``ccsdk.relationships.publish_files`` relationship or
117 a ``ccsdk.relationships.subscribe_to_files`` relationship, this plugin
118 needs to obtain data from the source node and, in the case of
119 ``publish_files``, provide data to the source node. Certain conventions
120 are therefore needed for passing data between this plugin and the
121 plugins responsible for the source nodes in these relationships. In
122 Cloudify, the mechanism for sharing data among plugins is the
123 ``ctx.instance.runtime_properties`` dictionary associated with each
124 node.
125
126 A given source node may have relationships with several feeds. For
127 example, an ONAP DCAE data collector might publish two different types
128 of data to two different feeds. An ONAP DCAE analytics module might
129 subscribe to one feed to get input for its processing and publish its
130 results to a different feed. When this DMaaP plugin and the plugin for
131 the source node exchange information, they need to do in a way that lets
132 them distinguish among different feeds. We do this through a simple
133 convention: for each source node to feed relationship, the source node
134 plugin will create a property in the source node's
135 ``runtime_properties`` dictionary. The name of the property will be the
136 same as the name of the target node of the relationship. For instance,
137 if a node has a ``publishes_files`` relationship with a target node
138 named ``feed00``, then the plugin that's responsible for managing the
139 source node with create an entry in the source node's
140 ``runtime_properties`` dictionary named ``feed00``. This entry itself
141 will be a dictionary.
142
143 The content of this data exchange dictionary depends on whether the
144 source node is a publisher (i.e., the relationship is ``publish_files``)
145 or a subscriber (i.e., the relationship is ``subscribe_to_files``).
146
147 For the ``publish_files`` relationship, the data exchange dictionary has
148 the following properties:
149
150 +----------------+----------------------+--------------------------------------------------------------------------------------------------+
151 | Property       | Set by               | Description                                                                                      |
152 +================+======================+==================================================================================================+
153 | location       | source node plugin   | the DMaaP location for the publisher, used to set up routing                                     |
154 +----------------+----------------------+--------------------------------------------------------------------------------------------------+
155 | publish\_url   | DMaaP plugin         | the URL to which the publisher makes Data Router publish requests                                |
156 +----------------+----------------------+--------------------------------------------------------------------------------------------------+
157 | log\_url       | DMaaP plugin         | the URL from which log data for the feed can be obtained                                         |
158 +----------------+----------------------+--------------------------------------------------------------------------------------------------+
159 | username       | DMaaP plugin         | the username (generated by the DMaaP plugin) the publisher uses to authenticate to Data Router   |
160 +----------------+----------------------+--------------------------------------------------------------------------------------------------+
161 | password       | DMaaP plugin         | the password (generated by the DMaaP plugin) the publisher uses to authenticate to Data Router   |
162 +----------------+----------------------+--------------------------------------------------------------------------------------------------+
163
164 For the ``subscribe_to_files`` relationship, the data exchange
165 dictionary has the following properties:
166
167 +-----------------+----------------------+-----------------------------------------------------------------------------------------+
168 | Property        | Set by               | Description                                                                             |
169 +=================+======================+=========================================================================================+
170 | location        | source node plugin   | the DMaaP location for the subscriber, used to set up routing                           |
171 +-----------------+----------------------+-----------------------------------------------------------------------------------------+
172 | delivery\_url   | source node plugin   | the URL to which the Data Router should deliver files                                   |
173 +-----------------+----------------------+-----------------------------------------------------------------------------------------+
174 | username        | source node plugin   | the username Data Router uses to authenticate to the subscriber when delivering files   |
175 +-----------------+----------------------+-----------------------------------------------------------------------------------------+
176 | password        | source node plugin   | the username Data Router uses to authenticate to the subscriber when delivering file    |
177 +-----------------+----------------------+-----------------------------------------------------------------------------------------+
178
179 Plugin Support for DMaaP Message Router
180 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
181
182 Plugin Types for DMaaP Message Router
183 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
184
185 The Cloudify type definitions for DMaaP Message Router nodes and
186 relationships are defined in ```dmaap.yaml`` <./dmaap.yaml>`__.
187
188 There are two node types for DMaaP Message Router:
189
190 -  ``ccsdk.nodes.Topic``: This type represents a topic that does not yet
191    exist and that should be created when the install workflow is run
192    against a blueprint that contains a node of this type.
193
194 +----------------------+-----------+-------------+-----------------------------------------------------------------------------+
195 | Property             | Type      | Required?   | Description                                                                 |
196 +======================+===========+=============+=============================================================================+
197 | topic\_name          | string    | no          | a name that uniquely identifies the feed (plugin will generate if absent)   |
198 +----------------------+-----------+-------------+-----------------------------------------------------------------------------+
199 | topic\_description   | string    | no          | human-readable description of the feed                                      |
200 +----------------------+-----------+-------------+-----------------------------------------------------------------------------+
201 | txenable             | boolean   | no          | flag indicating whether transactions are enabled for this topic             |
202 +----------------------+-----------+-------------+-----------------------------------------------------------------------------+
203 | replication\_case    | string    | no          | type of replication required for the topic (defaults to no replication)     |
204 +----------------------+-----------+-------------+-----------------------------------------------------------------------------+
205 | global\_mr\_url      | string    | no          | Global MR host name for replication to a global MR instance                 |
206 +----------------------+-----------+-------------+-----------------------------------------------------------------------------+
207
208 Note: In order to set up topics, a user should be familiar with message
209 router and how it is configured, and this README is not the place to
210 explain the details of message router. Here are a couple of pieces of
211 information that might be helpful. Currently, the allowed values for
212 ``replication_case`` are:
213
214 -  ``REPLICATION_NONE``
215 -  ``REPLICATION_EDGE_TO_CENTRAL``
216 -  ``REPLICATION_EDGE_TO_CENTRAL_TO_GLOBAL``
217 -  ``REPLICATION_CENTRAL_TO_EDGE``
218 -  ``REPLICATION_CENTRAL_TO_GLOBAL``
219 -  ``REPLICATION_GLOBAL_TO_CENTRAL``
220 -  ``REPLICATION_GLOBAL_TO_CENTRAL_TO_EDGE``
221
222 The ``global_mr_url`` is actually a host name, not a full URL. It points
223 to a host in a global message router cluster. (A 'global' message router
224 cluster is one that's not part of ONAP.)
225
226 -  ``ccsdk.nodes.ExistingTopic``: This type represents a topic that
227    already exists. Nodes of this type are placed in a blueprint so that
228    other nodes in the blueprint can be set up as publishers or
229    subscribers to the topic. The table below shows the properties that a
230    node of this type may have.
231
232 +------------+----------+-------------+--------------------------------------------+
233 | Property   | Type     | Required?   | Description                                |
234 +============+==========+=============+============================================+
235 | fqtn       | string   | yes         | fully-qualified topic name for the topic   |
236 +------------+----------+-------------+--------------------------------------------+
237
238 Interaction with Other Plugins
239 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
240
241 When creating a new topic or processing a reference to an existing
242 topic, the plugin operates independently of other plugins.
243
244 When processing a ``ccsdk.relationships.publish_events`` relationship or
245 a ``ccsdk.relationships.subscribe_to_events`` relationship, this plugin
246 needs to obtain data from and provide data to the source node. Certain
247 conventions are therefore needed for passing data between this plugin
248 and the plugins responsible for the source nodes in these relationships.
249 In Cloudify, the mechanism for sharing data among plugins is the
250 ``ctx.instance.runtime_properties`` dictionary associated with each
251 node.
252
253 A given source node may have relationships with several topics. For
254 example, an ONAP DCAE analytics module might subscribe to one topic to
255 get input for its processing and publish its results to a different
256 topic. When this DMaaP plugin and the plugin for the source node
257 exchange information, they need to do in a way that lets them
258 distinguish among different feeds. We do this through a simple
259 convention: for each source node to topic relationship, the source node
260 plugin will create a property in the source node's
261 ``runtime_properties`` dictionary. The name of the property will be the
262 same as the name of the target node of the relationship. For instance,
263 if a node has a ``publishes_events`` relationship with a target node
264 named ``topic00``, then the plugin that's responsible for managing the
265 source node with create an entry in the source node's
266 ``runtime_properties`` dictionary named ``topic00``. This entry itself
267 will be a dictionary.
268
269 For both types of relationship, the data exchange dictionary has the
270 following properties:
271
272 +----------------+----------------------+----------------------------------------------------------------------------------+
273 | Property       | Set by               | Description                                                                      |
274 +================+======================+==================================================================================+
275 | location       | source node plugin   | the DMaaP location for the publisher or subscriber, used to set up routing       |
276 +----------------+----------------------+----------------------------------------------------------------------------------+
277 | client\_role   | source node plugin   | the AAF client role that's requesting publish or subscribe access to the topic   |
278 +----------------+----------------------+----------------------------------------------------------------------------------+
279 | topic\_url     | DMaaP plugin         | the URL for accessing the topic to publish or receive events                     |
280 +----------------+----------------------+----------------------------------------------------------------------------------+
281
282 Interaction with Consul configuration store
283 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
284
285 In addition to storing the results of DMaaP Data Router and DMaaP
286 Message Router provisioning operations in ``runtime_properties``, the
287 DMaaP plugin also stores these results into the ONAP configuration
288 store, which resides in a `Consul key-value
289 store <https://www.consul.io/>`__. This allows DMaaP clients (components
290 that act as publishers, subscribers, or both) to retrieve their DMaaP
291 configuration information from Consul, rather than having the plugin
292 that deploys the client directly configure the client using data in
293 ``runtime_properties``.
294
295 The ``runtime_properties`` for a client must contain a property called
296 ``service_component_name``. If this property is not present, the plugin
297 will raise a NonRecoverableError and cause the installation to fail.
298
299 If ``service_component_name`` is present, then the plugin will use a
300 Consul key consisting of the value of ``service_component_name``
301 prepended to the fixed string ``:dmaap``. For example, if the
302 ``service_component_name`` is ``client123``, the plugin will use
303 ``client123:dmaap`` as the key for storing DMaaP information into
304 Consul. Information for all of the feeds and topics for a client are
305 stored under the same key.
306
307 The value stored is a nested JSON object. At the top level of the object
308 are properties representing each topic or feed for which the component
309 is a publisher or subscriber. The name of the property is the node name
310 of the target feed or topic. The value of the property is another JSON
311 object that corresponds to the dictionary that the plugin created in
312 ``runtime_properties`` corresponding to the target feed or topic. Note
313 that the information in Consul includes all of the properties for the
314 feed or topic, those set by the source node plugin as well as those set
315 by the DMaaP plugin.
316
317 Examples:
318
319 Data Router publisher, target feed ``feed00``:
320
321 ::
322
323     {
324       "feed00": {
325         "username": "rC9QR51I",
326         "log_url": "https://dmaap.example.com/feedlog/972",
327         "publish_url": "https://dmaap.example.com/publish/972",
328         "location": "loc00",
329         "password": "QOQeUh5KLR",
330         "publisher_id": "972.360gm"
331       }
332     }
333
334 Data Router subscriber, target feed ``feed01``:
335
336 ::
337
338     {
339       "feed01": {
340         "username": "drdeliver",
341         "password": "1loveDataR0uter",
342         "location": "loc00",
343         "delivery_url": "https://example.com/whatever",
344         "subscriber_id": "1550"
345       }
346     }
347
348 Message Router publisher to ``topic00``, subscriber to ``topic01``. Note
349 how each topic appears as a top-level property in the object.
350
351 ::
352
353     {
354       "topic00": {
355         "topic_url": "https://dmaap.example.com:3905/events/org.onap.ccsdk.dmaap.FTL2.outboundx",
356         "client_role": "org.onap.ccsdk.member",
357         "location": "loc00",
358         "client_id": "1494621774522"
359       },
360       "topic01": {
361         "topic_url": "https://dmaap.example.com:3905/events/org.onap.ccsdk.dmaap.FTL2.inboundx",
362         "client_role": "org.onap.ccsdk.member",
363         "location": "loc00",
364         "client_id": "1494621778627"
365       }
366     }
367
368 Packaging and installing
369 ~~~~~~~~~~~~~~~~~~~~~~~~
370
371 The DMaaP plugin is meant to be used as a `Cloudify managed
372 plugin <http://docs.getcloudify.org/3.4.0/plugins/using-plugins/>`__.
373 Managed plugins are packaged using
374 ```wagon`` <https://github.com/cloudify-cosmo/wagon>`__.
375
376 To package this plugin, executing the following command in the top-level
377 directory of this plugin, from a Python environment in which ``wagon``
378 has been installed:
379
380 ::
381
382     wagon create -s . -r -o /path/to/directory/for/wagon/output
383
384 Once the wagon file is built, it can be uploaded to a Cloudify Manager
385 host using the ``cfy plugins upload`` command described in the
386 documentation above.
387
388 Managed plugins can also be loaded at the time a Cloudify Manager host
389 is installed, via the installation blueprint and inputs file. We expect
390 that this plugin will be loaded at Cloudify Manager installation time,
391 and that ``cfy plugins upload`` will be used only for delivering patches
392 between releases.
393
394 Configuration
395 ~~~~~~~~~~~~~
396
397 The plugin needs to be configured with certain parameters needed to
398 access the DMaaP Bus Controller. In keeping with the ONAP architecture,
399 this information is stored in Consul.
400
401 The plugin finds the address and port of the DMaaP Bus Controller using
402 the Consul service discovery facility. The plugin expects the Bus
403 Controller to be registered under the name ``dmaap_bus_controller``.
404
405 Additional parameters come from the ``dmaap`` key in the Cloudify
406 Manager's Consul configuration, which is stored in the Consul KV store
407 under the key name 'cloudify\_manager'. The table below lists the
408 properties in the configuration:
409
410 +----------------+----------+-------------+--------------+---------------------------------------------------------------------------------------------+
411 | Property       | Type     | Required?   | Default      | Description                                                                                 |
412 +================+==========+=============+==============+=============================================================================================+
413 | ``username``   | string   | Yes         | (none)       | The username for logging into DMaaP Bus Controller                                          |
414 +----------------+----------+-------------+--------------+---------------------------------------------------------------------------------------------+
415 | ``password``   | string   | Yes         | (none)       | The password for logging into DMaaP Bus Controller                                          |
416 +----------------+----------+-------------+--------------+---------------------------------------------------------------------------------------------+
417 | ``owner``      | string   | Yes         | (none)       | The name to be used as the owner for entities created by the plugin                         |
418 +----------------+----------+-------------+--------------+---------------------------------------------------------------------------------------------+
419 | ``protocol``   | string   | No          | ``https``    | The protocol (URL scheme) used to access the DMaaP bus controller (``http`` or ``https``)   |
420 +----------------+----------+-------------+--------------+---------------------------------------------------------------------------------------------+
421 | ``path``       | string   | No          | ``webapi``   | The path to the root of the DMaaP Bus Controller API endpoint                               |
422 +----------------+----------+-------------+--------------+---------------------------------------------------------------------------------------------+
423
424 Here is an example of a Cloudify Manager configuration object showing
425 only the ``dmaap`` key:
426
427 ::
428
429     {
430       "dmaap": {
431         "username": "dmaap.client@ccsdkorch.onap.org",
432         "password": "guessmeifyoucan"
433         "owner": "ccsdkorc"
434       },
435
436       (other configuration here)
437
438     }
439