aboutsummaryrefslogtreecommitdiffstats
path: root/docs/platform/cookbook.rst
blob: 0a834b40acd2edee70f5e990c04918534d51fc9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
.. This work is licensed under a Creative Commons Attribution 4.0 International License.
.. http://creativecommons.org/licenses/by/4.0

***************
Policy Cookbook
***************

Openstack Heat Installation - Policy VM/Docker Recipes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    .. code-block:: bash
       :caption: Get the latest images in an already setup policy VM
       :linenos:

        /opt/policy_vm_init.sh


    .. code-block:: bash
       :caption: Install/start docker policy containers with no policies preloaded
       :linenos:

        echo "PRELOAD_POLICIES=false" > /opt/policy/.env
        /opt/policy_vm_init.sh


    .. code-block:: bash
       :caption: Install/start docker policy containers with policies preloaded
       :linenos:

        # This is the current default mode of instantiation.
        # These operations are unnecessary unless PRELOAD_POLICIES
        # was previously set to true

        echo "PRELOAD_POLICIES=true" > /opt/policy/.env
        /opt/policy_vm_init.sh


    .. code-block:: bash
       :caption: Access the PDP-D container as the policy user
       :linenos:

        docker exec -it drools bash


    .. code-block:: bash
       :caption: Access the PDP-X container as the policy user
       :linenos:

        docker exec -it -u 0 pdp su - policy


    .. code-block:: bash
       :caption: Access the BRMSGW container as the policy user
       :linenos:

        docker exec -it -u 0 brmsgw su - policy


    .. code-block:: bash
       :caption: Access PAP container as the policy user
       :linenos:

        docker exec -it -u 0 pap su - policy


    .. code-block:: bash
       :caption: Access the CONSOLE container the a policy user
       :linenos:

        docker exec -it -u 0 console su - policy


    .. code-block:: bash
       :caption: Command line Healthcheck invokation
       :linenos:

        source /opt/app/policy/config/feature-healthcheck.conf.environment
        curl --silent --user "${HEALTHCHECK_USER}:${HEALTHCHECK_PASSWORD}"
             -X GET https://localhost:6969/healthcheck | python -m json.tool


OOM Installation - Policy Kubernetes Recipes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    .. code-block:: bash
       :caption: List the policy pods
       :linenos:

        kubectl get pods -n onap -o wide | grep policy


    .. code-block:: bash
       :caption: Access the PAP container
       :linenos:

        kubectl exec -it <pap-pod> -c pap -n onap -- bash --login


    .. code-block:: bash
       :caption: Access a PDPD-D container
       :linenos:

        # <policy-deployment-prefix> depends on the deployment configuration

        kubectl exec -it <policy-deployment-prefix>-drools-0 -c drools -n onap bash


    .. code-block:: bash
       :caption: Access the PDP container
       :linenos:

        # <policy-deployment-prefix> depends on the deployment configuration

        kubectl exec -it <policy-deployment-prefix>-pdp-0 -c pdp -n onap -- bash --login


    .. code-block:: bash
       :caption: Push Default Policies
       :linenos:

        kubectl exec -it <pap-pod> -c pap -n onap -- bash -c "export PRELOAD_POLICIES=true; /tmp/policy-install/config/push-policies.sh"


    .. code-block:: bash
       :caption: Standalone Policy Web UI URL access
       :linenos:

        http://<pap-vm>:30219/onap/login.htm


PDP-D Recipes (inside the "drools" container)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    .. code-block:: bash
       :caption: Stop the PDP-D
       :linenos:

        policy stop


    .. code-block:: bash
       :caption: Start the PDP-D
       :linenos:

        policy start


    .. code-block:: bash
       :caption: Manual Healthcheck Invokation
       :linenos:

        source ${POLICY_HOME}/config/feature-healthcheck.conf
        curl --silent --user "${HEALTHCHECK_USER}:${HEALTHCHECK_PASSWORD}"
             -X GET https://localhost:6969/healthcheck | python -m json.tool


    .. code-block:: bash
       :caption: Start a telemetry shell
       :linenos:

        telemetry


    .. code-block:: bash
       :caption: See all the configured loggers
       :linenos:

       curl -k --silent --user "${ENGINE_MANAGEMENT_USER}:${ENGINE_MANAGEMENT_PASSWORD}"
            https://localhost:9696/policy/pdp/engine/tools/loggers


    .. code-block:: bash
       :caption: See the logging level for a given logger (for example the network logger):
       :linenos:

       curl -k --silent --user"${ENGINE_MANAGEMENT_USER}:${ENGINE_MANAGEMENT_PASSWORD}"
            https://localhost:9696/policy/pdp/engine/tools/loggers/network


    .. code-block:: bash
       :caption: Modify the logging level for a given logger (for example the network logger):
       :linenos:

       curl -k --silent --user"${ENGINE_MANAGEMENT_USER}:${ENGINE_MANAGEMENT_PASSWORD}"
            -X PUT https://localhost:9696/policy/pdp/engine/tools/loggers/network/WARN


PAP Recipes (inside the "pap" container)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    .. code-block:: bash
       :caption: Bypass Portal Authentication with the Policy Web UI
       :linenos:

        sed -i "s/^role_access_centralized.*$/#role_access_centralized=remote/g" /opt/app/policy/servers/console/webapps/onap/WEB-INF/classes/portal.properties
        cd /opt/app/policy/servers/pap
        /opt/app/policy/etc/init.d/pap stop; /opt/app/policy/etc/init.d/pap start
        policy.sh status


    .. code-block:: bash
       :caption: Access the Policy Web UI without going through the Portal UI
       :linenos:

       https://policy.api.simpledemo.onap.org:30219/onap/policy  (Kubernetes)


End of Document

.. SSNote: Wiki page ref. https://wiki.onap.org/display/DW/Policy+Cookbook