d22747edcecd6eb7a5f2ab8f1668195832eebb06
[policy/parent.git] / docs / drools / tutorial_vCPE.rst
1
2 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
3 .. http://creativecommons.org/licenses/by/4.0
4
5 *********************************************************
6 Tutorial: Testing the vCPE use case in a standalone PDP-D
7 *********************************************************
8
9 .. contents::
10     :depth: 3
11
12
13 High Level Architecture
14 ^^^^^^^^^^^^^^^^^^^^^^^
15 The vCPE flow begins with an onset message that is sent from DCAE notifying the PDP-D that an action needs to be taken on a VM/VNF. Once the PDP-D has inserted the onset into drools memory, rules begin to fire to start processing the onset for the vCPE policy that exists in drools memory. If the onset is not enriched with A&AI data, Policy will query A&AI for the VM/VNF data otherwise the PDP-D will get the A&AI data needed directly from the onset. A Guard query is then executed to determine if the action to be taken is allowed. If Guard returns a permit, the PDP-D will then send an APPC Restart recipe request to restart the VM/VNF specified in the request. If APPC is successful then the PDP-D will send a operation success notification on the POLICY-CL-MGT topic. The PDP-D waits for an abatement message to come from DCAE before ending the transaction. Once the abatement is received the PDP-D sends a final success notification and gracefully ends processing the event.
16
17 Initial Setup
18 ^^^^^^^^^^^^^
19
20 For this tutorial, it is assumed that the set up steps from section
21 *Using the Control Loop PDP-D docker image for standalone testing* has been followed.
22
23 Running the Flow
24 ^^^^^^^^^^^^^^^^
25
26 **Step 1:** Deploy the vCPE Operational Policy.
27
28     .. code-block:: bash
29
30        cat pdp-update-vcpe.json
31        {
32          "policies": [
33             {
34             "type": "onap.policies.controlloop.Operational",
35             "type_version": "1.0.0",
36             "properties": {
37             "content": "controlLoop%3A%0A%20%20version%3A%202.0.0%0A%20%20controlLoopName%3A%20ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e%0A%20%20trigger_policy%3A%20unique-policy-id-1-restart%0A%20%20timeout%3A%203600%0A%20%20abatement%3A%20false%0A%20%0Apolicies%3A%0A%20%20-%20id%3A%20unique-policy-id-1-restart%0A%20%20%20%20name%3A%20Restart%20the%20VM%0A%20%20%20%20description%3A%0A%20%20%20%20actor%3A%20APPC%0A%20%20%20%20recipe%3A%20Restart%0A%20%20%20%20target%3A%0A%20%20%20%20%20%20type%3A%20VM%0A%20%20%20%20retry%3A%203%0A%20%20%20%20timeout%3A%201200%0A%20%20%20%20success%3A%20final_success%0A%20%20%20%20failure%3A%20final_failure%0A%20%20%20%20failure_timeout%3A%20final_failure_timeout%0A%20%20%20%20failure_retries%3A%20final_failure_retries%0A%20%20%20%20failure_exception%3A%20final_failure_exception%0A%20%20%20%20failure_guard%3A%20final_failure_guard"
38             },
39             "name": "operational.restart",
40             "version": "1.0.0"
41             }
42           ],
43           "messageName": "PDP_UPDATE",
44           "requestId": "a7a32d3b-37b4-4fb7-9322-b90c6a6fe365",
45           "timestampMs": 1556125347251,
46           "name": "pdpd",
47           "pdpGroup": "controlloop",
48           "pdpSubgroup": "drools"
49        }
50
51        http --verify=no -a "${TELEMETRY_USER}:${TELEMETRY_PASSWORD}" PUT https://localhost:9696/policy/pdp/engine/topics/sources/noop/POLICY-PDP-PAP/events @pdp-update-vcpe.json Content-Type:'text/plain'
52
53        telemetry                                                # verify
54        > get controllers/usecases/drools/facts/usecases/controlloops
55        > get controllers/usecases/drools/facts/usecases/controlloops/ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e
56
57 **Step 2:** Inject a simulated *ONSET* message.
58
59     .. code-block:: bash
60
61        cat dcae.vcpe.onset.json
62        {
63          "closedLoopControlName": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e",
64          "closedLoopAlarmStart": 1463679805324,
65          "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca",
66          "closedLoopEventStatus": "ONSET",
67          "requestID": "664be3d2-6c12-4f4b-a3e7-c349acced200",
68          "target_type": "VNF",
69          "target": "generic-vnf.vnf-id",
70          "AAI": {
71            "vserver.is-closed-loop-disabled": "false",
72            "vserver.prov-status": "ACTIVE",
73            "generic-vnf.vnf-id": "vCPE_Infrastructure_vGMUX_demo_app"
74          },
75          "from": "DCAE",
76          "version": "1.0.2"
77        }
78
79        http --verify=no -a "${TELEMETRY_USER}:${TELEMETRY_PASSWORD}" PUT https://localhost:9696/policy/pdp/engine/topics/sources/noop/DCAE_TOPIC/switches/activation     # activate noop source
80
81        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'  # send onset
82
83 **NOTE:** The simulated onset is enriched with A&AI data. The PDP-D will not make an A&AI query since the data needed can be extracted from the onset.
84
85 Now check the facts in memory, there should be 8 objects present. Two timers exist to put a time limit on the operation and on the overall control loop (in the case of retries or policy chaining). The event and it's associated manager and operation manager are also present in memory. A lock on the target entity is inserted to ensure no other events try to take action on the VM/VNF that is currently processing.
86
87 The network log will be used to monitor the activity coming in and out of the PDP-D. This log is located at *$POLICY_LOGS/network.log*. This will show the notifications that the PDP-D sends out at different stages of processing. The order of successful processing begins with an ACTIVE notification to show that the onset was acknowledged and the operation is beginning transit.
88
89     .. image:: Tut_vCPE_policy_active.JPG
90
91 Once the event is in the ACTIVE state, the PDP-D consults Guard to determine if this operation should be allowed, a series of operation notifications are sent for starting the Guard query, obtaining a PERMIT or DENY, and beginning the operation.
92
93     .. image:: Tut_vCPE_guard_not_queried.JPG
94
95 |
96
97     .. image:: Tut_vCPE_guard_result.JPG
98
99 |
100
101     .. image:: Tut_vCPE_policy_operation.JPG
102
103 **Step 3:** Inject an APPC response in the APPC-LCM-WRITE topic
104
105     .. code-block:: bash
106
107        cat appc.lcm.success.json
108        {
109          "body": {
110            "output": {
111              "common-header": {
112                "timestamp": "2017-08-25T21:06:23.037Z",
113                "api-ver": "5.00",
114                "originator-id": "664be3d2-6c12-4f4b-a3e7-c349acced200",
115                "request-id": "664be3d2-6c12-4f4b-a3e7-c349acced200",
116                "sub-request-id": "1",
117                "flags": {}
118              },
119              "status": {
120                "code": 400,
121                "message": "Restart Successful"
122              }
123            }
124          },
125          "version": "2.0",
126          "rpc-name": "restart",
127          "correlation-id": "664be3d2-6c12-4f4b-a3e7-c349acced200-1",
128          "type": "response"
129        }
130
131        http --verify=no -a "${TELEMETRY_USER}:${TELEMETRY_PASSWORD}" PUT https://localhost:9696/policy/pdp/engine/topics/sources/noop/APPC-LCM-WRITE/switches/activation   # activate noop source
132
133        http --verify=no -a "${TELEMETRY_USER}:${TELEMETRY_PASSWORD}" PUT https://localhost:9696/policy/pdp/engine/topics/sources/noop/APPC-LCM-WRITE/events @appc.lcm.success.json Content-Type:'text/plain'
134
135     .. image:: Tut_vCPE_inject_appc_response.JPG
136
137 The network log will show the PDP-D sent an operation success notification.
138
139     .. image:: Tut_vCPE_policy_operation_success.JPG
140
141 Once the transaction has completed, a final success notification is sent from the PDP-D.
142
143     .. image:: Tut_vCPE_policy_final_success.JPG
144
145 After processing there should only be 2 facts left in memory.
146
147 End of Document