blob: df67624c32cbd614e0a66e3f62ace523d37bcce5 [file] [log] [blame]
jhh108dd8f2020-06-12 17:01:24 -05001
2.. This work is licensed under a Creative Commons Attribution 4.0 International License.
3.. http://creativecommons.org/licenses/by/4.0
4
5.. _pdpd-apps-label:
6
7PDP-D Applications
8##################
9
10.. contents::
11 :depth: 2
12
13Overview
14========
15
16PDP-D applications uses the PDP-D Engine middleware to provide domain specific services.
17See :ref:`pdpd-engine-label` for the description of the PDP-D infrastructure.
18
19At this time *Control Loops* are the only type of applications supported.
20
21*Control Loop* applications must support at least one of the following *Policy Types*:
22
23- **onap.policies.controlloop.Operational** (Operational Policies for Legacy Control Loops)
24- **onap.policies.controlloop.operational.common.Drools** (Tosca Compliant Operational Policies)
25
26Software
27========
28
29Source Code repositories
30~~~~~~~~~~~~~~~~~~~~~~~~
31
32The PDP-D Applications software resides on the `policy/drools-applications <https://git.onap.org/policy/drools-applications>`__ repository. The actor libraries introduced in the *frankfurt* release reside in
33the `policy/models repository <https://git.onap.org/policy/models>`__.
34
35At this time, the *control loop* application is the only application supported in ONAP.
36All the application projects reside under the
37`controlloop directory <https://git.onap.org/policy/drools-applications/tree/controlloop>`__.
38
39Docker Image
40~~~~~~~~~~~~
41
42See the *drools-applications*
43`released versions <https://wiki.onap.org/display/DW/Policy+Framework+Project%3A+Component+Versions>`__
44for the latest images:
45
46.. code-block:: bash
47
48 docker pull onap/policy-pdpd-cl:1.6.4
49
50At the time of this writing *1.6.4* is the latest version.
51
52The *onap/policy-pdpd-cl* image extends the *onap/policy-drools* image with
Jim Hahnae9582c2020-11-02 14:36:25 -050053the *usecases* controller that realizes the *control loop* application.
jhh108dd8f2020-06-12 17:01:24 -050054
Jim Hahnae9582c2020-11-02 14:36:25 -050055Usecases Controller
jhh108dd8f2020-06-12 17:01:24 -050056====================
57
Jim Hahnae9582c2020-11-02 14:36:25 -050058The `usecases <https://git.onap.org/policy/drools-applications/tree/controlloop/common/controller-usecases>`__
jhh108dd8f2020-06-12 17:01:24 -050059controller is the *control loop* application in ONAP.
60
61There are three parts in this controller:
62
Jim Hahnae9582c2020-11-02 14:36:25 -050063* The `drl rules <https://git.onap.org/policy/drools-applications/tree/controlloop/common/controller-usecases/src/main/resources/usecases.drl>`__.
64* The `kmodule.xml <https://git.onap.org/policy/drools-applications/tree/controlloop/common/controller-usecases/src/main/resources/META-INF/kmodule.xml>`__.
65* The `dependencies <https://git.onap.org/policy/drools-applications/tree/controlloop/common/controller-usecases/pom.xml>`__.
jhh108dd8f2020-06-12 17:01:24 -050066
67The `kmodule.xml` specifies only one session, and declares in the *kbase* section the two operational policy types that
68it supports.
69
Jim Hahnae9582c2020-11-02 14:36:25 -050070The Usecases controller relies on the new Actor framework to interact with remote
jhh108dd8f2020-06-12 17:01:24 -050071components, part of a control loop transaction. The reader is referred to the
72*Policy Platform Actor Development Guidelines* in the documentation for further information.
73
74Operational Policy Types
75========================
76
Jim Hahnae9582c2020-11-02 14:36:25 -050077The *usecases* controller supports the two Operational policy types:
jhh108dd8f2020-06-12 17:01:24 -050078
79- *onap.policies.controlloop.Operational*.
80- *onap.policies.controlloop.operational.common.Drools*.
81
82The *onap.policies.controlloop.Operational* is the legacy operational type, used before
83the *frankfurt* release. The *onap.policies.controlloop.operational.common.Drools*
84is the Tosca compliant policy type introduced in *frankfurt*.
85
86The legacy operational policy type is defined at the
87`onap.policies.controlloop.Operational.yaml <https://git.onap.org/policy/models/tree/models-examples/src/main/resources/policytypes/onap.policies.controlloop.Operational.yaml>`__.
88
89The Tosca Compliant Operational Policy Type is defined at the
90`onap.policies.controlloop.operational.common.Drools <https://git.onap.org/policy/models/tree/models-examples/src/main/resources/policytypes/onap.policies.controlloop.operational.common.Drools.yaml>`__.
91
92An example of a Legacy Operational Policy can be found
93`here <https://git.onap.org/policy/models/tree/models-examples/src/main/resources/policies/vDNS.policy.operational.legacy.input.json>`__.
94
95An example of a Tosca Compliant Operational Policy can be found
96`here <https://git.onap.org/policy/models/tree/models-examples/src/main/resources/policies/vDNS.policy.operational.input.tosca.json>`__.
97
Ram Krishna Verma56e98082021-06-22 17:47:59 -040098Policy Chaining
99===============
100
101The *usecases* controller supports chaining of multiple operations inside a Tosca Operational Policy. The next operation can be chained based on the result/output from an operation.
102The possibilities available for chaining are:
103
104- *success: chain after the result of operation is success*
105- *failure: chain after the result of operation is failure due to issues with controller/actor*
106- *failure_timeout: chain after the result of operation is failure due to timeout*
107- *failure_retries: chain after the result of operation is failure after all retries*
108- *failure_exception: chain after the result of operation is failure due to exception*
109- *failure_guard: chain after the result of operation is failure due to guard not allowing the operation*
110
111An example of policy chaining for VNF can be found
112`here <https://github.com/onap/policy-models/blob/master/models-examples/src/main/resources/policies/vFirewall.cds.policy.operational.chaining.yaml>`__.
113
114An example of policy chaining for PNF can be found
115`here <https://github.com/onap/policy-models/blob/master/models-examples/src/main/resources/policies/pnf.cds.policy.operational.chaining.yaml>`__.
116
jhh108dd8f2020-06-12 17:01:24 -0500117Features
118========
119
120Since the PDP-D Control Loop Application image was created from the PDP-D Engine one (*onap/policy-drools*),
121it inherits all features and functionality.
122
123The enabled features in the *onap/policy-pdpd-cl* image are:
124
125- **distributed locking**: distributed resource locking.
126- **healthcheck**: healthcheck.
127- **lifecycle**: enables the lifecycle APIs.
128- **controlloop-trans**: control loop transaction tracking.
129- **controlloop-management**: generic controller capabilities.
Jim Hahnae9582c2020-11-02 14:36:25 -0500130- **controlloop-usecases**: new *controller* introduced in the guilin release to realize the ONAP use cases.
jhh108dd8f2020-06-12 17:01:24 -0500131
132The following features are installed but disabled:
133
Jim Hahnae9582c2020-11-02 14:36:25 -0500134- **controlloop-frankfurt**: *controller* used in the frankfurt release.
135- **controlloop-tdjam**: experimental java-only *controller* to be deprecated post guilin.
jhh108dd8f2020-06-12 17:01:24 -0500136- **controlloop-utils**: *actor* simulators.
137
138Control Loops Transaction (controlloop-trans)
139~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
140
141It tracks Control Loop Transactions and Operations. These are recorded in
142the *$POLICY_LOGS/audit.log* and *$POLICY_LOGS/metrics.log*, and accessible
143through the telemetry APIs.
144
145Control Loops Management (controlloop-management)
146~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
147
148It installs common control loop application resources, and provides
149telemetry API extensions. *Actor* configurations are packaged in this
150feature.
151
Jim Hahnae9582c2020-11-02 14:36:25 -0500152Usecases Controller (controlloop-usecases)
jhh108dd8f2020-06-12 17:01:24 -0500153~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
154
Jim Hahnae9582c2020-11-02 14:36:25 -0500155It is the *guilin* release implementation of the ONAP use cases.
jhh108dd8f2020-06-12 17:01:24 -0500156It relies on the new *Actor* model framework to carry out a policy's
157execution.
158
Jim Hahnae9582c2020-11-02 14:36:25 -0500159Frankfurt Controller (controlloop-frankfurt)
jhh108dd8f2020-06-12 17:01:24 -0500160~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
161
Jim Hahnae9582c2020-11-02 14:36:25 -0500162This is the frankfurt controller that will be deprecated after the
163guilin release.
164
165TDJAM Controller (controlloop-tdjam)
166~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
167
168This is an experimental, java-only controller that will be deprecated after the
169guilin release.
jhh108dd8f2020-06-12 17:01:24 -0500170
171Utilities (controlloop-utils)
172~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
173
174Enables *actor simulators* for testing purposes.
175
176Offline Mode
177============
178
179The default ONAP installation in *onap/policy-pdpd-cl:1.6.4* is *OFFLINE*.
180In this configuration, the *rules* artifact and the *dependencies* are all in the local
181maven repository. This requires that the maven dependencies are preloaded in the local
182repository.
183
184An offline configuration requires two configuration items:
185
186- *OFFLINE* environment variable set to true (see `values.yaml <https://git.onap.org/oom/tree/kubernetes/policy/values.yaml>`__.
187- override of the default *settings.xml* (see
188 `settings.xml <https://git.onap.org/oom/tree/kubernetes/policy/charts/drools/resources/configmaps/settings.xml>`__) override.
189
190Running the PDP-D Control Loop Application in a single container
191================================================================
192
193Environment File
194~~~~~~~~~~~~~~~~
195
196First create an environment file (in this example *env.conf*) to configure the PDP-D.
197
198.. code-block:: bash
199
200 # SYSTEM software configuration
201
202 POLICY_HOME=/opt/app/policy
203 POLICY_LOGS=/var/log/onap/policy/pdpd
204 KEYSTORE_PASSWD=Pol1cy_0nap
205 TRUSTSTORE_PASSWD=Pol1cy_0nap
206
207 # Telemetry credentials
208
209 TELEMETRY_PORT=9696
210 TELEMETRY_HOST=0.0.0.0
211 TELEMETRY_USER=demo@people.osaaf.org
212 TELEMETRY_PASSWORD=demo123456!
213
214 # nexus repository
215
216 SNAPSHOT_REPOSITORY_ID=
217 SNAPSHOT_REPOSITORY_URL=
218 RELEASE_REPOSITORY_ID=
219 RELEASE_REPOSITORY_URL=
220 REPOSITORY_USERNAME=
221 REPOSITORY_PASSWORD=
222 REPOSITORY_OFFLINE=true
223
224 MVN_SNAPSHOT_REPO_URL=
225 MVN_RELEASE_REPO_URL=
226
227 # Relational (SQL) DB access
228
229 SQL_HOST=
230 SQL_USER=
231 SQL_PASSWORD=
232
233 # AAF
234
235 AAF=false
236 AAF_NAMESPACE=org.onap.policy
237 AAF_HOST=aaf.api.simpledemo.onap.org
238
239 # PDP-D DMaaP configuration channel
240
241 PDPD_CONFIGURATION_TOPIC=PDPD-CONFIGURATION
242 PDPD_CONFIGURATION_API_KEY=
243 PDPD_CONFIGURATION_API_SECRET=
244 PDPD_CONFIGURATION_CONSUMER_GROUP=
245 PDPD_CONFIGURATION_CONSUMER_INSTANCE=
246 PDPD_CONFIGURATION_PARTITION_KEY=
247
248 # PAP-PDP configuration channel
249
250 POLICY_PDP_PAP_TOPIC=POLICY-PDP-PAP
251 POLICY_PDP_PAP_GROUP=defaultGroup
252
253 # Symmetric Key for encoded sensitive data
254
255 SYMM_KEY=
256
257 # Healthcheck Feature
258
259 HEALTHCHECK_USER=demo@people.osaaf.org
260 HEALTHCHECK_PASSWORD=demo123456!
261
262 # Pooling Feature
263
264 POOLING_TOPIC=POOLING
265
266 # PAP
267
268 PAP_HOST=
269 PAP_USERNAME=
270 PAP_PASSWORD=
271
272 # PAP legacy
273
274 PAP_LEGACY_USERNAME=
275 PAP_LEGACY_PASSWORD=
276
277 # PDP-X
278
279 PDP_HOST=localhost
280 PDP_PORT=6669
281 PDP_CONTEXT_URI=pdp/api/getDecision
282 PDP_USERNAME=policy
283 PDP_PASSWORD=password
284 GUARD_DISABLED=true
285
286 # DCAE DMaaP
287
288 DCAE_TOPIC=unauthenticated.DCAE_CL_OUTPUT
289 DCAE_SERVERS=localhost
290 DCAE_CONSUMER_GROUP=dcae.policy.shared
291
292 # Open DMaaP
293
294 DMAAP_SERVERS=localhost
295
296 # AAI
297
298 AAI_HOST=localhost
299 AAI_PORT=6666
300 AAI_CONTEXT_URI=
301 AAI_USERNAME=policy
302 AAI_PASSWORD=policy
303
304 # SO
305
306 SO_HOST=localhost
307 SO_PORT=6667
308 SO_CONTEXT_URI=
309 SO_URL=https://localhost:6667/
310 SO_USERNAME=policy
311 SO_PASSWORD=policy
312
313 # VFC
314
315 VFC_HOST=localhost
316 VFC_PORT=6668
317 VFC_CONTEXT_URI=api/nslcm/v1/
318 VFC_USERNAME=policy
319 VFC_PASSWORD=policy
320
321 # SDNC
322
323 SDNC_HOST=localhost
324 SDNC_PORT=6670
325 SDNC_CONTEXT_URI=restconf/operations/
326
327Configuration
328~~~~~~~~~~~~~
329
330noop.pre.sh
331"""""""""""
332
333In order to avoid the noise in the logs that relate to dmaap configuration, a startup script (*noop.pre.sh*) is added
334to convert *dmaap* endpoints to *noop* in the host directory to be mounted.
335
336.. code-block:: bash
337
338 #!/bin/bash -x
339
340 sed -i "s/^dmaap/noop/g" $POLICY_HOME/config/*.properties
341
342features.pre.sh
343"""""""""""""""
344
345We can enable the *controlloop-utils* and disable the *distributed-locking* feature to avoid using the database.
346
347.. code-block:: bash
348
349 #!/bin/bash -x
350
351 bash -c "/opt/app/policy/bin/features disable distributed-locking"
352 bash -c "/opt/app/policy/bin/features enable controlloop-utils"
353
354active.post.sh
355""""""""""""""
356
357The *active.post.sh* script makes the PDP-D active.
358
359.. code-block:: bash
360
361 #!/bin/bash -x
362
363 bash -c "http --verify=no -a ${TELEMETRY_USER}:${TELEMETRY_PASSWORD} PUT https://localhost:9696/policy/pdp/engine/lifecycle/state/ACTIVE"
364
365Actor Properties
366""""""""""""""""
367
Jim Hahnae9582c2020-11-02 14:36:25 -0500368In the *guilin* release, some *actors* configurations need to be overridden to support *http* for compatibility
jhh108dd8f2020-06-12 17:01:24 -0500369with the *controlloop-utils* feature.
370
371AAI-http-client.properties
372""""""""""""""""""""""""""
373
374.. code-block:: bash
375
376 http.client.services=AAI
377
378 http.client.services.AAI.managed=true
379 http.client.services.AAI.https=false
380 http.client.services.AAI.host=${envd:AAI_HOST}
381 http.client.services.AAI.port=${envd:AAI_PORT}
382 http.client.services.AAI.userName=${envd:AAI_USERNAME}
383 http.client.services.AAI.password=${envd:AAI_PASSWORD}
384 http.client.services.AAI.contextUriPath=${envd:AAI_CONTEXT_URI}
385
386SDNC-http-client.properties
387"""""""""""""""""""""""""""
388
389.. code-block:: bash
390
391 http.client.services=SDNC
392
393 http.client.services.SDNC.managed=true
394 http.client.services.SDNC.https=false
395 http.client.services.SDNC.host=${envd:SDNC_HOST}
396 http.client.services.SDNC.port=${envd:SDNC_PORT}
397 http.client.services.SDNC.userName=${envd:SDNC_USERNAME}
398 http.client.services.SDNC.password=${envd:SDNC_PASSWORD}
399 http.client.services.SDNC.contextUriPath=${envd:SDNC_CONTEXT_URI}
400
401VFC-http-client.properties
402""""""""""""""""""""""""""
403
404.. code-block:: bash
405
406 http.client.services=VFC
407
408 http.client.services.VFC.managed=true
409 http.client.services.VFC.https=false
410 http.client.services.VFC.host=${envd:VFC_HOST}
411 http.client.services.VFC.port=${envd:VFC_PORT}
412 http.client.services.VFC.userName=${envd:VFC_USERNAME}
413 http.client.services.VFC.password=${envd:VFC_PASSWORD}
414 http.client.services.VFC.contextUriPath=${envd:VFC_CONTEXT_URI:api/nslcm/v1/}
415
416settings.xml
417""""""""""""
418
419The *standalone-settings.xml* file is the default maven settings override in the container.
420
421.. code-block:: bash
422
423 <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
424 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
425 xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
426
427 <offline>true</offline>
428
429 <profiles>
430 <profile>
431 <id>policy-local</id>
432 <repositories>
433 <repository>
434 <id>file-repository</id>
435 <url>file:${user.home}/.m2/file-repository</url>
436 <releases>
437 <enabled>true</enabled>
438 <updatePolicy>always</updatePolicy>
439 </releases>
440 <snapshots>
441 <enabled>true</enabled>
442 <updatePolicy>always</updatePolicy>
443 </snapshots>
444 </repository>
445 </repositories>
446 </profile>
447 </profiles>
448
449 <activeProfiles>
450 <activeProfile>policy-local</activeProfile>
451 </activeProfiles>
452
453 </settings>
454
455Bring up the PDP-D Control Loop Application
456~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
457
458.. code-block:: bash
459
460 docker run --rm -p 9696:9696 -v ${PWD}/config:/tmp/policy-install/config --env-file ${PWD}/env/env.conf -it --name PDPD -h pdpd nexus3.onap.org:10001/onap/policy-pdpd-cl:1.6.4
461
462To run the container in detached mode, add the *-d* flag.
463
464Note that we are opening the *9696* telemetry API port to the outside world, mounting the *config* host directory,
465and setting environment variables.
466
467To open a shell into the PDP-D:
468
469.. code-block:: bash
470
471 docker exec -it pdp-d bash
472
473Once in the container, run tools such as *telemetry*, *db-migrator*, *policy* to look at the system state:
474
475.. code-block:: bash
476
477 docker exec -it PDPD bash -c "/opt/app/policy/bin/telemetry"
478 docker exec -it PDPD bash -c "/opt/app/policy/bin/policy status"
479 docker exec -it PDPD bash -c "/opt/app/policy/bin/db-migrator -s ALL -o report"
480
481Controlled instantiation of the PDP-D Control Loop Appplication
482~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
483
484Sometimes a developer may want to start and stop the PDP-D manually:
485
486.. code-block:: bash
487
488 # start a bash
489
490 docker run --rm -p 9696:9696 -v ${PWD}/config:/tmp/policy-install/config --env-file ${PWD}/env/env.conf -it --name PDPD -h pdpd nexus3.onap.org:10001/onap/policy-pdpd-cl:1.6.4 bash
491
492 # use this command to start policy applying host customizations from /tmp/policy-install/config
493
494 pdpd-cl-entrypoint.sh vmboot
495
496 # or use this command to start policy without host customization
497
498 policy start
499
500 # at any time use the following command to stop the PDP-D
501
502 policy stop
503
504 # and this command to start the PDP-D back again
505
506 policy start
507
508Scale-out use case testing
509==========================
510
511First step is to create the *operational.scaleout* policy.
512
513policy.vdns.json
514~~~~~~~~~~~~~~~~
515
516.. code-block:: bash
517
518 {
519 "type": "onap.policies.controlloop.operational.common.Drools",
520 "type_version": "1.0.0",
521 "name": "operational.scaleout",
522 "version": "1.0.0",
523 "metadata": {
524 "policy-id": "operational.scaleout"
525 },
526 "properties": {
527 "id": "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3",
528 "timeout": 60,
529 "abatement": false,
530 "trigger": "unique-policy-id-1-scale-up",
531 "operations": [
532 {
533 "id": "unique-policy-id-1-scale-up",
534 "description": "Create a new VF Module",
535 "operation": {
536 "actor": "SO",
537 "operation": "VF Module Create",
538 "target": {
539 "targetType": "VFMODULE",
540 "entityIds": {
541 "modelInvariantId": "e6130d03-56f1-4b0a-9a1d-e1b2ebc30e0e",
542 "modelVersionId": "94b18b1d-cc91-4f43-911a-e6348665f292",
543 "modelName": "VfwclVfwsnkBbefb8ce2bde..base_vfw..module-0",
544 "modelVersion": 1,
545 "modelCustomizationId": "47958575-138f-452a-8c8d-d89b595f8164"
546 }
547 },
548 "payload": {
549 "requestParameters": "{\"usePreload\":true,\"userParams\":[]}",
550 "configurationParameters": "[{\"ip-addr\":\"$.vf-module-topology.vf-module-parameters.param[9]\",\"oam-ip-addr\":\"$.vf-module-topology.vf-module-parameters.param[16]\",\"enabled\":\"$.vf-module-topology.vf-module-parameters.param[23]\"}]"
551 }
552 },
553 "timeout": 20,
554 "retries": 0,
555 "success": "final_success",
556 "failure": "final_failure",
557 "failure_timeout": "final_failure_timeout",
558 "failure_retries": "final_failure_retries",
559 "failure_exception": "final_failure_exception",
560 "failure_guard": "final_failure_guard"
561 }
562 ]
563 }
564 }
565
566To provision the *scale-out policy*, issue the following command:
567
568.. code-block:: bash
569
570 http --verify=no -a "${TELEMETRY_USER}:${TELEMETRY_PASSWORD}" https://localhost:9696/policy/pdp/engine/lifecycle/policies @usecases/policy.vdns.json
571
572Verify that the policy shows with the telemetry tools:
573
574.. code-block:: bash
575
576 docker exec -it PDPD bash -c "/opt/app/policy/bin/telemetry"
577 > get /policy/pdp/engine/lifecycle/policies
Jim Hahnae9582c2020-11-02 14:36:25 -0500578 > get /policy/pdp/engine/controllers/usecases/drools/facts/usecases/controlloops
jhh108dd8f2020-06-12 17:01:24 -0500579
580
581dcae.vdns.onset.json
582~~~~~~~~~~~~~~~~~~~~
583
584.. code-block:: bash
585
586 {
587 "closedLoopControlName": "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3",
588 "closedLoopAlarmStart": 1463679805324,
589 "closedLoopEventClient": "microservice.stringmatcher",
590 "closedLoopEventStatus": "ONSET",
591 "requestID": "c7c6a4aa-bb61-4a15-b831-ba1472dd4a65",
592 "target_type": "VNF",
593 "target": "vserver.vserver-name",
594 "AAI": {
595 "vserver.is-closed-loop-disabled": "false",
596 "vserver.prov-status": "ACTIVE",
597 "vserver.vserver-name": "OzVServer"
598 },
599 "from": "DCAE",
600 "version": "1.0.2"
601 }
602
603To initiate a control loop transaction, simulate a DCAE ONSET to Policy:
604
605.. code-block:: bash
606
607 http --verify=no -a "${TELEMETRY_USER}:${TELEMETRY_PASSWORD}" PUT https://localhost:9696/policy/pdp/engine/topics/sources/noop/DCAE_TOPIC/events @dcae.vdns.onset.json Content-Type:'text/plain'
608
609This will trigger the scale out control loop transaction that will interact with the *SO*
610simulator to complete the transaction.
611
612Verify in *$POLICY_LOGS/network.log* that a *FINAL: SUCCESS* notification is sent over the POLICY-CL-MGT channel.
613An entry in the *$POLICY_LOGS/audit.log* should indicate successful completion as well.
614
615vCPE use case testing
616=====================
617
618First step is to create the *operational.restart* policy.
619
620policy.vcpe.json
621~~~~~~~~~~~~~~~~
622
623.. code-block:: bash
624
625 {
626 "type": "onap.policies.controlloop.operational.common.Drools",
627 "type_version": "1.0.0",
628 "name": "operational.restart",
629 "version": "1.0.0",
630 "metadata": {
631 "policy-id": "operational.restart"
632 },
633 "properties": {
634 "id": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e",
635 "timeout": 300,
636 "abatement": false,
637 "trigger": "unique-policy-id-1-restart",
638 "operations": [
639 {
640 "id": "unique-policy-id-1-restart",
641 "description": "Restart the VM",
642 "operation": {
643 "actor": "APPC",
644 "operation": "Restart",
645 "target": {
646 "targetType": "VNF"
647 }
648 },
649 "timeout": 240,
650 "retries": 0,
651 "success": "final_success",
652 "failure": "final_failure",
653 "failure_timeout": "final_failure_timeout",
654 "failure_retries": "final_failure_retries",
655 "failure_exception": "final_failure_exception",
656 "failure_guard": "final_failure_guard"
657 }
658 ]
659 }
660 }
661
662To provision the *operational.restart policy* issue the following command:
663
664.. code-block:: bash
665
666 http --verify=no -a "${TELEMETRY_USER}:${TELEMETRY_PASSWORD}" https://localhost:9696/policy/pdp/engine/lifecycle/policies @usecases/policy.vcpe.json
667
668Verify that the policy shows with the telemetry tools:
669
670.. code-block:: bash
671
672 docker exec -it PDPD bash -c "/opt/app/policy/bin/telemetry"
673 > get /policy/pdp/engine/lifecycle/policies
Jim Hahnae9582c2020-11-02 14:36:25 -0500674 > get /policy/pdp/engine/controllers/usecases/drools/facts/usecases/controlloops
jhh108dd8f2020-06-12 17:01:24 -0500675
676
677dcae.vcpe.onset.json
678~~~~~~~~~~~~~~~~~~~~
679
680.. code-block:: bash
681
682 {
683 "closedLoopControlName": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e",
684 "closedLoopAlarmStart": 1463679805324,
685 "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca",
686 "closedLoopEventStatus": "ONSET",
687 "requestID": "664be3d2-6c12-4f4b-a3e7-c349acced200",
688 "target_type": "VNF",
689 "target": "generic-vnf.vnf-id",
690 "AAI": {
691 "vserver.is-closed-loop-disabled": "false",
692 "vserver.prov-status": "ACTIVE",
693 "generic-vnf.vnf-id": "vCPE_Infrastructure_vGMUX_demo_app"
694 },
695 "from": "DCAE",
696 "version": "1.0.2"
697 }
698
699To initiate a control loop transaction, simulate a DCAE ONSET to Policy:
700
701.. code-block:: bash
702
703 http --verify=no -a "${TELEMETRY_USER}:${TELEMETRY_PASSWORD}" PUT https://localhost:9696/policy/pdp/engine/topics/sources/noop/DCAE_TOPIC/events @dcae.vcpe.onset.json Content-Type:'text/plain'
704
705This will spawn a vCPE control loop transaction in the PDP-D. Policy will send a *restart* message over the
706*APPC-LCM-READ* channel to APPC and wait for a response.
707
708Verify that you see this message in the network.log by looking for *APPC-LCM-READ* messages.
709
710Note the *sub-request-id* value from the restart message in the *APPC-LCM-READ* channel.
711
712Replace *REPLACEME* in the *appc.vcpe.success.json* with this sub-request-id.
713
714appc.vcpe.success.json
715~~~~~~~~~~~~~~~~~~~~~~
716
717.. code-block:: bash
718
719 {
720 "body": {
721 "output": {
722 "common-header": {
723 "timestamp": "2017-08-25T21:06:23.037Z",
724 "api-ver": "5.00",
725 "originator-id": "664be3d2-6c12-4f4b-a3e7-c349acced200",
726 "request-id": "664be3d2-6c12-4f4b-a3e7-c349acced200",
727 "sub-request-id": "REPLACEME",
728 "flags": {}
729 },
730 "status": {
731 "code": 400,
732 "message": "Restart Successful"
733 }
734 }
735 },
736 "version": "2.0",
737 "rpc-name": "restart",
738 "correlation-id": "664be3d2-6c12-4f4b-a3e7-c349acced200-1",
739 "type": "response"
740 }
741
742
743Send a simulated APPC response back to the PDP-D over the *APPC-LCM-WRITE* channel.
744
745.. code-block:: bash
746
747 http --verify=no -a "${TELEMETRY_USER}:${TELEMETRY_PASSWORD}" PUT https://localhost:9696/policy/pdp/engine/topics/sources/noop/APPC-LCM-WRITE/events @appc.vcpe.success.json Content-Type:'text/plain'
748
749Verify in *$POLICY_LOGS/network.log* that a *FINAL: SUCCESS* notification is sent over the *POLICY-CL-MGT* channel,
750and an entry is added to the *$POLICY_LOGS/audit.log* indicating successful completion.
751
752vFirewall use case testing
753===========================
754
755First step is to create the *operational.modifyconfig* policy.
756
757policy.vfw.json
758~~~~~~~~~~~~~~~
759
760.. code-block:: bash
761
762 {
763 "type": "onap.policies.controlloop.operational.common.Drools",
764 "type_version": "1.0.0",
765 "name": "operational.modifyconfig",
766 "version": "1.0.0",
767 "metadata": {
768 "policy-id": "operational.modifyconfig"
769 },
770 "properties": {
771 "id": "ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a",
772 "timeout": 300,
773 "abatement": false,
774 "trigger": "unique-policy-id-1-modifyConfig",
775 "operations": [
776 {
777 "id": "unique-policy-id-1-modifyConfig",
778 "description": "Modify the packet generator",
779 "operation": {
780 "actor": "APPC",
781 "operation": "ModifyConfig",
782 "target": {
783 "targetType": "VNF",
784 "entityIds": {
785 "resourceID": "bbb3cefd-01c8-413c-9bdd-2b92f9ca3d38"
786 }
787 },
788 "payload": {
789 "streams": "{\"active-streams\": 5 }"
790 }
791 },
792 "timeout": 240,
793 "retries": 0,
794 "success": "final_success",
795 "failure": "final_failure",
796 "failure_timeout": "final_failure_timeout",
797 "failure_retries": "final_failure_retries",
798 "failure_exception": "final_failure_exception",
799 "failure_guard": "final_failure_guard"
800 }
801 ]
802 }
803 }
804
805
806To provision the *operational.modifyconfig policy*, issue the following command:
807
808.. code-block:: bash
809
810 http --verify=no -a "${TELEMETRY_USER}:${TELEMETRY_PASSWORD}" https://localhost:9696/policy/pdp/engine/lifecycle/policies @usecases/policy.vfw.json
811
812Verify that the policy shows with the telemetry tools:
813
814.. code-block:: bash
815
816 docker exec -it PDPD bash -c "/opt/app/policy/bin/telemetry"
817 > get /policy/pdp/engine/lifecycle/policies
Jim Hahnae9582c2020-11-02 14:36:25 -0500818 > get /policy/pdp/engine/controllers/usecases/drools/facts/usecases/controlloops
jhh108dd8f2020-06-12 17:01:24 -0500819
820
821dcae.vfw.onset.json
822~~~~~~~~~~~~~~~~~~~~
823
824.. code-block:: bash
825
826 {
827 "closedLoopControlName": "ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a",
828 "closedLoopAlarmStart": 1463679805324,
829 "closedLoopEventClient": "microservice.stringmatcher",
830 "closedLoopEventStatus": "ONSET",
831 "requestID": "c7c6a4aa-bb61-4a15-b831-ba1472dd4a65",
832 "target_type": "VNF",
833 "target": "generic-vnf.vnf-name",
834 "AAI": {
835 "vserver.is-closed-loop-disabled": "false",
836 "vserver.prov-status": "ACTIVE",
837 "generic-vnf.vnf-name": "fw0002vm002fw002",
838 "vserver.vserver-name": "OzVServer"
839 },
840 "from": "DCAE",
841 "version": "1.0.2"
842 }
843
844
845To initiate a control loop transaction, simulate a DCAE ONSET to Policy:
846
847.. code-block:: bash
848
849 http --verify=no -a "${TELEMETRY_USER}:${TELEMETRY_PASSWORD}" PUT https://localhost:9696/policy/pdp/engine/topics/sources/noop/DCAE_TOPIC/events @dcae.vfw.onset.json Content-Type:'text/plain'
850
851This will spawn a vFW control loop transaction in the PDP-D. Policy will send a *ModifyConfig* message over the
852*APPC-CL* channel to APPC and wait for a response. This can be seen by searching the network.log for *APPC-CL*.
853
854Note the *SubRequestId* field in the *ModifyConfig* message in the *APPC-CL* topic in the network.log
855
856Send a simulated APPC response back to the PDP-D over the *APPC-CL* channel.
857To do this, change the *REPLACEME* text in the *appc.vcpe.success.json* with this *SubRequestId*.
858
859appc.vcpe.success.json
860~~~~~~~~~~~~~~~~~~~~~~
861
862.. code-block:: bash
863
864 {
865 "CommonHeader": {
866 "TimeStamp": 1506051879001,
867 "APIver": "1.01",
868 "RequestID": "c7c6a4aa-bb61-4a15-b831-ba1472dd4a65",
869 "SubRequestID": "REPLACEME",
870 "RequestTrack": [],
871 "Flags": []
872 },
873 "Status": {
874 "Code": 400,
875 "Value": "SUCCESS"
876 },
877 "Payload": {
878 "generic-vnf.vnf-id": "f17face5-69cb-4c88-9e0b-7426db7edddd"
879 }
880 }
881
882.. code-block:: bash
883
884 http --verify=no -a "${TELEMETRY_USER}:${TELEMETRY_PASSWORD}" PUT https://localhost:9696/policy/pdp/engine/topics/sources/noop/APPC-CL/events @appc.vcpe.success.json Content-Type:'text/plain'
885
886Verify in *$POLICY_LOGS/network.log* that a *FINAL: SUCCESS* notification is sent over the POLICY-CL-MGT channel,
887and an entry is added to the *$POLICY_LOGS/audit.log* indicating successful completion.
888
889
890Running PDP-D Control Loop Application with other components
891============================================================
892
893The reader can also look at the `integration/csit repository <https://git.onap.org/integration/csit>`__.
894More specifically, these directories have examples of other PDP-D Control Loop configurations:
895
896* `plans <https://git.onap.org/integration/csit/tree/plans/policy/drools-applications>`__: startup scripts.
897* `scripts <https://git.onap.org/integration/csit/tree/scripts/policy/drools-apps/docker-compose-drools-apps.yml>`__: docker-compose and related files.
898* `plans <https://git.onap.org/integration/csit/tree/tests/policy/drools-applications>`__: test plan.
899
900Additional information
901======================
902
903For additional information, please see the
904`Drools PDP Development and Testing (In Depth) <https://wiki.onap.org/display/DW/2020+Frankfurt+Tutorials>`__ page.
905
906