Saryu Shah | 82b62ca | 2018-03-19 22:18:13 +0000 | [diff] [blame] | 1 | |
| 2 | .. This work is licensed under a Creative Commons Attribution 4.0 International License. |
| 3 | .. http://creativecommons.org/licenses/by/4.0 |
| 4 | |
Saryu Shah | ab8bc20 | 2018-04-23 21:54:37 +0000 | [diff] [blame] | 5 | *************** |
| 6 | Policy Cookbook |
| 7 | *************** |
Saryu Shah | 82b62ca | 2018-03-19 22:18:13 +0000 | [diff] [blame] | 8 | |
Jorge Hernandez | 5a91dc3 | 2018-11-05 15:34:55 -0600 | [diff] [blame] | 9 | Openstack Heat Installation - Policy VM/Docker Recipes |
| 10 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Saryu Shah | 82b62ca | 2018-03-19 22:18:13 +0000 | [diff] [blame] | 11 | |
| 12 | .. code-block:: bash |
Jorge Hernandez | 5a91dc3 | 2018-11-05 15:34:55 -0600 | [diff] [blame] | 13 | :caption: Get the latest images in an already setup policy VM |
Saryu Shah | 82b62ca | 2018-03-19 22:18:13 +0000 | [diff] [blame] | 14 | :linenos: |
| 15 | |
| 16 | /opt/policy_vm_init.sh |
| 17 | |
| 18 | |
| 19 | .. code-block:: bash |
| 20 | :caption: Install/start docker policy containers with no policies preloaded |
| 21 | :linenos: |
| 22 | |
| 23 | echo "PRELOAD_POLICIES=false" > /opt/policy/.env |
| 24 | /opt/policy_vm_init.sh |
| 25 | |
| 26 | |
| 27 | .. code-block:: bash |
| 28 | :caption: Install/start docker policy containers with policies preloaded |
| 29 | :linenos: |
| 30 | |
| 31 | # This is the current default mode of instantiation. |
| 32 | # These operations are unnecessary unless PRELOAD_POLICIES |
| 33 | # was previously set to true |
Jorge Hernandez | 5a91dc3 | 2018-11-05 15:34:55 -0600 | [diff] [blame] | 34 | |
Saryu Shah | 82b62ca | 2018-03-19 22:18:13 +0000 | [diff] [blame] | 35 | echo "PRELOAD_POLICIES=true" > /opt/policy/.env |
| 36 | /opt/policy_vm_init.sh |
| 37 | |
| 38 | |
| 39 | .. code-block:: bash |
Jorge Hernandez | 5a91dc3 | 2018-11-05 15:34:55 -0600 | [diff] [blame] | 40 | :caption: Access the PDP-D container as the policy user |
Saryu Shah | 82b62ca | 2018-03-19 22:18:13 +0000 | [diff] [blame] | 41 | :linenos: |
| 42 | |
| 43 | docker exec -it drools bash |
| 44 | |
| 45 | |
| 46 | .. code-block:: bash |
Jorge Hernandez | 5a91dc3 | 2018-11-05 15:34:55 -0600 | [diff] [blame] | 47 | :caption: Access the PDP-X container as the policy user |
Saryu Shah | 82b62ca | 2018-03-19 22:18:13 +0000 | [diff] [blame] | 48 | :linenos: |
| 49 | |
| 50 | docker exec -it -u 0 pdp su - policy |
| 51 | |
| 52 | |
| 53 | .. code-block:: bash |
Jorge Hernandez | 5a91dc3 | 2018-11-05 15:34:55 -0600 | [diff] [blame] | 54 | :caption: Access the BRMSGW container as the policy user |
Saryu Shah | 82b62ca | 2018-03-19 22:18:13 +0000 | [diff] [blame] | 55 | :linenos: |
| 56 | |
| 57 | docker exec -it -u 0 brmsgw su - policy |
| 58 | |
| 59 | |
| 60 | .. code-block:: bash |
Jorge Hernandez | 5a91dc3 | 2018-11-05 15:34:55 -0600 | [diff] [blame] | 61 | :caption: Access PAP container as the policy user |
Saryu Shah | 82b62ca | 2018-03-19 22:18:13 +0000 | [diff] [blame] | 62 | :linenos: |
| 63 | |
| 64 | docker exec -it -u 0 pap su - policy |
| 65 | |
| 66 | |
| 67 | .. code-block:: bash |
Jorge Hernandez | 5a91dc3 | 2018-11-05 15:34:55 -0600 | [diff] [blame] | 68 | :caption: Access the CONSOLE container the a policy user |
Saryu Shah | 82b62ca | 2018-03-19 22:18:13 +0000 | [diff] [blame] | 69 | :linenos: |
| 70 | |
| 71 | docker exec -it -u 0 console su - policy |
| 72 | |
| 73 | |
| 74 | .. code-block:: bash |
Jorge Hernandez | 5a91dc3 | 2018-11-05 15:34:55 -0600 | [diff] [blame] | 75 | :caption: Command line Healthcheck invokation |
Saryu Shah | 82b62ca | 2018-03-19 22:18:13 +0000 | [diff] [blame] | 76 | :linenos: |
| 77 | |
Saryu Shah | 82b62ca | 2018-03-19 22:18:13 +0000 | [diff] [blame] | 78 | source /opt/app/policy/config/feature-healthcheck.conf.environment |
Jorge Hernandez | 5a91dc3 | 2018-11-05 15:34:55 -0600 | [diff] [blame] | 79 | curl --silent --user "${HEALTHCHECK_USER}:${HEALTHCHECK_PASSWORD}" |
| 80 | -X GET https://localhost:6969/healthcheck | python -m json.tool |
Saryu Shah | 82b62ca | 2018-03-19 22:18:13 +0000 | [diff] [blame] | 81 | |
| 82 | |
Jorge Hernandez | 5a91dc3 | 2018-11-05 15:34:55 -0600 | [diff] [blame] | 83 | OOM Installation - Policy Kubernetes Recipes |
| 84 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 85 | |
| 86 | .. code-block:: bash |
| 87 | :caption: List the policy pods |
| 88 | :linenos: |
| 89 | |
| 90 | kubectl get pods -n onap -o wide | grep policy |
| 91 | |
| 92 | |
| 93 | .. code-block:: bash |
| 94 | :caption: Access the PAP container |
| 95 | :linenos: |
| 96 | |
jhh | ffd7241 | 2019-10-02 22:35:40 -0500 | [diff] [blame] | 97 | kubectl exec -it <pap-pod> -c pap -n onap -- bash --login |
Jorge Hernandez | 5a91dc3 | 2018-11-05 15:34:55 -0600 | [diff] [blame] | 98 | |
| 99 | |
| 100 | .. code-block:: bash |
| 101 | :caption: Access a PDPD-D container |
| 102 | :linenos: |
| 103 | |
| 104 | # <policy-deployment-prefix> depends on the deployment configuration |
| 105 | |
| 106 | kubectl exec -it <policy-deployment-prefix>-drools-0 -c drools -n onap bash |
| 107 | |
| 108 | |
| 109 | .. code-block:: bash |
| 110 | :caption: Access the PDP container |
| 111 | :linenos: |
| 112 | |
| 113 | # <policy-deployment-prefix> depends on the deployment configuration |
| 114 | |
jhh | ffd7241 | 2019-10-02 22:35:40 -0500 | [diff] [blame] | 115 | kubectl exec -it <policy-deployment-prefix>-pdp-0 -c pdp -n onap -- bash --login |
Jorge Hernandez | 5a91dc3 | 2018-11-05 15:34:55 -0600 | [diff] [blame] | 116 | |
| 117 | |
| 118 | .. code-block:: bash |
| 119 | :caption: Push Default Policies |
| 120 | :linenos: |
| 121 | |
| 122 | kubectl exec -it <pap-pod> -c pap -n onap -- bash -c "export PRELOAD_POLICIES=true; /tmp/policy-install/config/push-policies.sh" |
| 123 | |
| 124 | |
| 125 | .. code-block:: bash |
| 126 | :caption: Standalone Policy Web UI URL access |
| 127 | :linenos: |
| 128 | |
| 129 | http://<pap-vm>:30219/onap/login.htm |
| 130 | |
| 131 | |
| 132 | PDP-D Recipes (inside the "drools" container) |
| 133 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Saryu Shah | 82b62ca | 2018-03-19 22:18:13 +0000 | [diff] [blame] | 134 | |
| 135 | .. code-block:: bash |
| 136 | :caption: Stop the PDP-D |
| 137 | :linenos: |
| 138 | |
| 139 | policy stop |
| 140 | |
| 141 | |
| 142 | .. code-block:: bash |
| 143 | :caption: Start the PDP-D |
| 144 | :linenos: |
| 145 | |
| 146 | policy start |
| 147 | |
| 148 | |
| 149 | .. code-block:: bash |
| 150 | :caption: Manual Healthcheck Invokation |
| 151 | :linenos: |
| 152 | |
Saryu Shah | 82b62ca | 2018-03-19 22:18:13 +0000 | [diff] [blame] | 153 | source ${POLICY_HOME}/config/feature-healthcheck.conf |
Jorge Hernandez | 5a91dc3 | 2018-11-05 15:34:55 -0600 | [diff] [blame] | 154 | curl --silent --user "${HEALTHCHECK_USER}:${HEALTHCHECK_PASSWORD}" |
| 155 | -X GET https://localhost:6969/healthcheck | python -m json.tool |
| 156 | |
| 157 | |
| 158 | .. code-block:: bash |
| 159 | :caption: Start a telemetry shell |
| 160 | :linenos: |
| 161 | |
| 162 | telemetry |
| 163 | |
| 164 | |
| 165 | .. code-block:: bash |
| 166 | :caption: See all the configured loggers |
| 167 | :linenos: |
| 168 | |
| 169 | curl -k --silent --user "${ENGINE_MANAGEMENT_USER}:${ENGINE_MANAGEMENT_PASSWORD}" |
| 170 | https://localhost:9696/policy/pdp/engine/tools/loggers |
| 171 | |
| 172 | |
| 173 | .. code-block:: bash |
| 174 | :caption: See the logging level for a given logger (for example the network logger): |
| 175 | :linenos: |
| 176 | |
| 177 | curl -k --silent --user"${ENGINE_MANAGEMENT_USER}:${ENGINE_MANAGEMENT_PASSWORD}" |
| 178 | https://localhost:9696/policy/pdp/engine/tools/loggers/network |
| 179 | |
| 180 | |
| 181 | .. code-block:: bash |
| 182 | :caption: Modify the logging level for a given logger (for example the network logger): |
| 183 | :linenos: |
| 184 | |
| 185 | curl -k --silent --user"${ENGINE_MANAGEMENT_USER}:${ENGINE_MANAGEMENT_PASSWORD}" |
| 186 | -X PUT https://localhost:9696/policy/pdp/engine/tools/loggers/network/WARN |
| 187 | |
Saryu Shah | 82b62ca | 2018-03-19 22:18:13 +0000 | [diff] [blame] | 188 | |
Jorge Hernandez | a4c3b2d | 2018-11-06 12:05:41 -0600 | [diff] [blame] | 189 | PAP Recipes (inside the "pap" container) |
| 190 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 191 | |
| 192 | .. code-block:: bash |
| 193 | :caption: Bypass Portal Authentication with the Policy Web UI |
| 194 | :linenos: |
| 195 | |
jhh | ffd7241 | 2019-10-02 22:35:40 -0500 | [diff] [blame] | 196 | sed -i "s/^role_access_centralized.*$/#role_access_centralized=remote/g" /opt/app/policy/servers/console/webapps/onap/WEB-INF/classes/portal.properties |
| 197 | cd /opt/app/policy/servers/pap |
| 198 | /opt/app/policy/etc/init.d/pap stop; /opt/app/policy/etc/init.d/pap start |
| 199 | policy.sh status |
Jorge Hernandez | a4c3b2d | 2018-11-06 12:05:41 -0600 | [diff] [blame] | 200 | |
| 201 | |
| 202 | .. code-block:: bash |
| 203 | :caption: Access the Policy Web UI without going through the Portal UI |
| 204 | :linenos: |
| 205 | |
jhh | ffd7241 | 2019-10-02 22:35:40 -0500 | [diff] [blame] | 206 | https://policy.api.simpledemo.onap.org:30219/onap/policy (Kubernetes) |
Jorge Hernandez | a4c3b2d | 2018-11-06 12:05:41 -0600 | [diff] [blame] | 207 | |
| 208 | |
Saryu Shah | 82b62ca | 2018-03-19 22:18:13 +0000 | [diff] [blame] | 209 | End of Document |
| 210 | |
| 211 | .. SSNote: Wiki page ref. https://wiki.onap.org/display/DW/Policy+Cookbook |
| 212 | |
| 213 | |
| 214 | |