Merge "user guide demo for monitoring gui"
[policy/parent.git] / docs / drools / tutorial_cl.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 Using the Control Loop PDP-D docker image for standalone testing
7 ***********************************************************************************************
8
9 .. contents::
10     :depth: 3
11
12 In this tutorial will start a Control Loop PDP-D container to use to test Operational Policies
13 without companion components.
14
15 **Step 1:** Copy a template *base.conf* with configuration to instantiate the container.
16
17     .. code-block:: bash
18
19         mkdir config
20         cd config
21         wget https://git.onap.org/policy/docker/plain/config/drools/base.conf?h=dublin -O base.conf
22
23
24 **Step 2:** Simplify *base.conf* for a standalone configuration (by disabling db and nexus access):
25
26     .. code-block:: bash
27
28         cd config
29         sed -i "s/^SQL_HOST=.*$/SQL_HOST=/g" base.conf
30         sed -i "s/^SNAPSHOT_REPOSITORY_ID=.*$/SNAPSHOT_REPOSITORY_ID=/g" base.conf
31         sed -i "s/^SNAPSHOT_REPOSITORY_URL=.*$/SNAPSHOT_REPOSITORY_URL=/g" base.conf
32         sed -i "s/^RELEASE_REPOSITORY_ID=.*$/RELEASE_REPOSITORY_ID=/g" base.conf
33         sed -i "s/^RELEASE_REPOSITORY_URL=.*$/RELEASE_REPOSITORY_URL=/g" base.conf
34
35         Note: For MacOS use - sed -i'' -e "s/^SQL_HOST=.*$/SQL_HOST=/g" base.conf and similar for all sed commands.
36
37 **Step 3:** Open a *bash* shell into the PDP-D Control Loop container.
38
39     .. code-block:: bash
40
41         docker run --rm --env-file config/base.conf -p 9696:9696 -p 6969:6969 -it --name pdpd -h pdpd nexus3.onap.org:10001/onap/policy-pdpd-cl:1.4.1 bash
42
43 **Step 4:** Disable the distributed-locking feature, since this is a single CL PDP-D instance.
44
45     .. code-block:: bash
46
47         features disable distributed-locking
48
49 **Step 5:** If using simulators (see tutorials), enable the *controlloop-utils* feature.
50
51     .. code-block:: bash
52
53         features enable controlloop-utils
54
55 **Step 6:** To reduce error logs due to being unable to communicate with DMaaP, change the official configuration to use *noop* topics instead (no network IO involved).
56
57     .. code-block:: bash
58
59         cd $POLICY_HOME/config
60         sed -i "s/^dmaap/noop/g" *.properties
61
62 **Step 7:** Disable PDP-X guard functionality.
63
64     .. code-block:: bash
65
66         cd $POLICY_HOME/config
67         sed -i "s/^guard.disabled=*$/guard.disabled=true/g" $POLICY_HOME/config/controlloop.properties.environment
68         sed -i "s/^aai.customQuery=*$/aai.customQuery=false/g" $POLICY_HOME/config/controlloop.properties.environment
69
70 **Step 8:** Start the CL PDP-D.
71
72     .. code-block:: bash
73
74         policy start
75
76 **Step 9:** Place the CL PDP-D in *ACTIVE* mode.
77
78     .. code-block:: bash
79
80         cat pdp-state-change.json
81         {
82           "state": "ACTIVE",
83           "messageName": "PDP_STATE_CHANGE",
84           "requestId": "385146af-adeb-4157-b97d-6ae85c1ddcb3",
85           "timestampMs": 1555791893587,
86           "name": "pdpd",
87           "pdpGroup": "controlloop",
88           "pdpSubgroup": "drools"
89         }
90
91         http --verify=no -a "${TELEMETRY_USER}:${TELEMETRY_PASSWORD}" PUT https://localhost:9696/policy/pdp/engine/topics/sources/noop/POLICY-PDP-PAP/events @pdp-state-change.json Content-Type:'text/plain'
92
93         telemetry     # to verify
94         > get lifecycle/fsm/state   # verify that state is ACTIVE
95
96 Note that *name* in *pdp-state-change.json* can be obtained from running *hostname* in the container.
97
98 Proceed with testing your new policy as described in the specific tutorials:
99
100 • vCPE - `Tutorial: Testing the vCPE use case in a standalone PDP-D <tutorial_vCPE.html>`_
101 • vDNS - `Tutorial: Testing the vDNS Use Case in a standalone PDP-D <tutorial_vDNS.html>`_
102 • vFW - `Tutorial: Testing the vFW flow in a standalone PDP-D <tutorial_vFW.html>`_
103
104 .. seealso:: `Methods to run PDP-D <runningPDPD.html>`_.
105
106
107 End of Document