mayankg2703 | ced8514 | 2018-03-20 05:42:53 +0000 | [diff] [blame] | 1 | # Copyright © 2017 Amdocs, Bell Canada, AT&T |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
Alexis de Talhouët | 5ce713e | 2017-12-07 15:58:25 -0500 | [diff] [blame] | 15 | #!/bin/bash |
| 16 | |
| 17 | if [ "$#" -ne 4 ]; then |
| 18 | echo "Usage: $(basename $0) <k8s-host> <policy-pdp-node-port> <policy-drools-node-port> <resource-id>" |
| 19 | exit 1 |
| 20 | fi |
| 21 | |
| 22 | K8S_HOST=$1 |
| 23 | POLICY_PDP_PORT=$2 |
| 24 | POLICY_DROOLS_PORT=$3 |
| 25 | RESOURCE_ID=$4 |
| 26 | |
| 27 | echo |
| 28 | echo |
| 29 | echo "Removing the vFW Policy from PDP.." |
| 30 | echo |
| 31 | echo |
| 32 | |
Jorge Hernandez | f30d5c2 | 2018-09-12 07:30:36 -0500 | [diff] [blame] | 33 | curl -v -k -X DELETE --header 'Content-Type: application/json' --header 'Accept: text/plain' --header 'ClientAuth: cHl0aG9uOnRlc3Q=' --header 'Authorization: Basic dGVzdHBkcDphbHBoYTEyMw==' --header 'Environment: TEST' -d '{ |
Alexis de Talhouët | 5ce713e | 2017-12-07 15:58:25 -0500 | [diff] [blame] | 34 | "pdpGroup": "default", |
| 35 | "policyComponent" : "PDP", |
| 36 | "policyName": "com.BRMSParamvFirewall", |
| 37 | "policyType": "BRMS_Param" |
Jorge Hernandez | f30d5c2 | 2018-09-12 07:30:36 -0500 | [diff] [blame] | 38 | }' https://${K8S_HOST}:${POLICY_PDP_PORT}/pdp/api/deletePolicy |
Alexis de Talhouët | 5ce713e | 2017-12-07 15:58:25 -0500 | [diff] [blame] | 39 | |
| 40 | sleep 20 |
| 41 | |
| 42 | echo |
| 43 | |
| 44 | echo |
| 45 | echo "Updating vFW Operational Policy .." |
| 46 | echo |
| 47 | |
Jorge Hernandez | f30d5c2 | 2018-09-12 07:30:36 -0500 | [diff] [blame] | 48 | curl -v -k -X PUT --header 'Content-Type: application/json' --header 'Accept: text/plain' --header 'ClientAuth: cHl0aG9uOnRlc3Q=' --header 'Authorization: Basic dGVzdHBkcDphbHBoYTEyMw==' --header 'Environment: TEST' -d '{ |
Alexis de Talhouët | 5ce713e | 2017-12-07 15:58:25 -0500 | [diff] [blame] | 49 | "policyConfigType": "BRMS_PARAM", |
| 50 | "policyName": "com.BRMSParamvFirewall", |
| 51 | "policyDescription": "BRMS Param vFirewall policy", |
| 52 | "policyScope": "com", |
| 53 | "attributes": { |
| 54 | "MATCHING": { |
| 55 | "controller": "amsterdam" |
| 56 | }, |
| 57 | "RULE": { |
| 58 | "templateName": "ClosedLoopControlName", |
| 59 | "closedLoopControlName": "ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a", |
| 60 | "controlLoopYaml": "controlLoop%3A%0D%0A++version%3A+2.0.0%0D%0A++controlLoopName%3A+ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a%0D%0A++trigger_policy%3A+unique-policy-id-1-modifyConfig%0D%0A++timeout%3A+1200%0D%0A++abatement%3A+false%0D%0A+%0D%0Apolicies%3A%0D%0A++-+id%3A+unique-policy-id-1-modifyConfig%0D%0A++++name%3A+modify+packet+gen+config%0D%0A++++description%3A%0D%0A++++actor%3A+APPC%0D%0A++++recipe%3A+ModifyConfig%0D%0A++++target%3A%0D%0A++++++%23+TBD+-+Cannot+be+known+until+instantiation+is+done%0D%0A++++++resourceID%3A+'${RESOURCE_ID}'%0D%0A++++++type%3A+VNF%0D%0A++++retry%3A+0%0D%0A++++timeout%3A+300%0D%0A++++success%3A+final_success%0D%0A++++failure%3A+final_failure%0D%0A++++failure_timeout%3A+final_failure_timeout%0D%0A++++failure_retries%3A+final_failure_retries%0D%0A++++failure_exception%3A+final_failure_exception%0D%0A++++failure_guard%3A+final_failure_guard" |
| 61 | } |
| 62 | } |
Jorge Hernandez | f30d5c2 | 2018-09-12 07:30:36 -0500 | [diff] [blame] | 63 | }' https://${K8S_HOST}:${POLICY_PDP_PORT}/pdp/api/updatePolicy |
Alexis de Talhouët | 5ce713e | 2017-12-07 15:58:25 -0500 | [diff] [blame] | 64 | |
| 65 | sleep 5 |
| 66 | |
| 67 | echo |
| 68 | echo |
| 69 | echo "Pushing the vFW Policy .." |
| 70 | echo |
| 71 | echo |
| 72 | |
Jorge Hernandez | f30d5c2 | 2018-09-12 07:30:36 -0500 | [diff] [blame] | 73 | curl -v -k --silent -X PUT --header 'Content-Type: application/json' --header 'Accept: text/plain' --header 'ClientAuth: cHl0aG9uOnRlc3Q=' --header 'Authorization: Basic dGVzdHBkcDphbHBoYTEyMw==' --header 'Environment: TEST' -d '{ |
Alexis de Talhouët | 5ce713e | 2017-12-07 15:58:25 -0500 | [diff] [blame] | 74 | "pdpGroup": "default", |
| 75 | "policyName": "com.BRMSParamvFirewall", |
| 76 | "policyType": "BRMS_Param" |
Jorge Hernandez | f30d5c2 | 2018-09-12 07:30:36 -0500 | [diff] [blame] | 77 | }' https://${K8S_HOST}:${POLICY_PDP_PORT}/pdp/api/pushPolicy |
Alexis de Talhouët | 5ce713e | 2017-12-07 15:58:25 -0500 | [diff] [blame] | 78 | |
| 79 | sleep 20 |
| 80 | |
| 81 | echo |
| 82 | echo |
| 83 | echo "Restarting PDP-D .." |
| 84 | echo |
| 85 | echo |
| 86 | |
Abdelmuhaimen Seaudi | 3c23ce0 | 2018-09-08 05:36:20 +0000 | [diff] [blame] | 87 | POD=$(kubectl --namespace {{ include "common.namespace" . }} get pods | sed 's/ .*//'| grep drools) |
| 88 | kubectl --namespace {{ include "common.namespace" . }} exec -it ${POD} -- bash -c "source /opt/app/policy/etc/profile.d/env.sh && policy stop && sleep 5 && policy start" |
Alexis de Talhouët | 5ce713e | 2017-12-07 15:58:25 -0500 | [diff] [blame] | 89 | |
| 90 | sleep 20 |
| 91 | |
| 92 | echo |
| 93 | echo |
| 94 | echo "PDP-D amsterdam maven coordinates .." |
| 95 | echo |
| 96 | echo |
| 97 | |
Jorge Hernandez | e6adf04 | 2018-09-28 15:08:08 -0500 | [diff] [blame] | 98 | curl -vvv -k --silent --user "demo@people.osaaf.org:demo123456!" -X GET https://${K8S_HOST}:${POLICY_DROOLS_PORT}/policy/pdp/engine/controllers/amsterdam/drools | python -m json.tool |
Alexis de Talhouët | 5ce713e | 2017-12-07 15:58:25 -0500 | [diff] [blame] | 99 | |
| 100 | |
| 101 | echo |
| 102 | echo |
| 103 | echo "PDP-D control loop updated .." |
| 104 | echo |
| 105 | echo |
| 106 | |
Jorge Hernandez | e6adf04 | 2018-09-28 15:08:08 -0500 | [diff] [blame] | 107 | curl -v -k --silent --user "demo@people.osaaf.org:demo123456!" -X GET https://${K8S_HOST}:${POLICY_DROOLS_PORT}/policy/pdp/engine/controllers/amsterdam/drools/facts/closedloop-amsterdam/org.onap.policy.controlloop.Params | python -m json.tool |