diff options
author | Jorge Hernandez <jh1730@att.com> | 2018-03-27 02:33:00 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-03-27 02:33:00 +0000 |
commit | 55599ffc8754a7657de4c3b0adb76407c13077b4 (patch) | |
tree | 48c80a34275fd780e287940e228f9a7eb8b1cb63 /controlloop/packages/basex/src/files/bin/push-policies-beijing | |
parent | a65513610152ff5e48ee8e528fd6c3706f5d3c45 (diff) | |
parent | ecd9dda6a3b4984ae287d36cfc9e26afb68f0ccd (diff) |
Merge "Create Drools Scripts for Beijing"
Diffstat (limited to 'controlloop/packages/basex/src/files/bin/push-policies-beijing')
-rw-r--r-- | controlloop/packages/basex/src/files/bin/push-policies-beijing | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/controlloop/packages/basex/src/files/bin/push-policies-beijing b/controlloop/packages/basex/src/files/bin/push-policies-beijing new file mode 100644 index 000000000..92259790a --- /dev/null +++ b/controlloop/packages/basex/src/files/bin/push-policies-beijing @@ -0,0 +1,122 @@ +#! /bin/bash + +### +# ============LICENSE_START======================================================= +# PDP-D APPS Base Package +# ================================================================================ +# Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +### + +# A script to insert policies using ControlLoopParams facts +# for a standalone PDP-D usage + +# Obtain the controller properties file +if [[ "${CONTROLLER_PROPERTIES}" != "" ]] ; then + # The user already exported CONTROLLER_PROPERTIES + configFile="${CONTROLLER_PROPERTIES}" +else + # CONTROL_LOOP_PROPERTIES are missing, ask the user for them + echo "What is the path to the controller properties file?" + read -e -i "${configFile}" -p "Controller properties file> " configFile + + # Ensure the user gave a path + if [ -z "${configFile}" ]; then echo "Aborting: No controller properties file was specified"; exit 1; fi + + # Ensure the controller properties file exists in the user specified path + if [[ ! -f "${configFile}" ]] ; then + echo "Aborting: Can't find controller properties file at: ${configFile}" + exit 1 + fi +fi + +echo +echo "Extracting properties from properties file..." +echo + +echo "Extracting the controller's name..." +CONTROLLER_NAME=$(egrep ".*controller.name=" \ + "${configFile}") +CONTROLLER_NAME=`echo ${CONTROLLER_NAME} | sed -e 's/.*controller\.name=\(.*\)/\1/'` +echo "The controller's name is: ${CONTROLLER_NAME}" +echo + +echo "Extracting the BRMSGW Topic..." +BRMSGW_TOPIC=$(egrep "^ *(ueb|dmaap)\.source\.topics\..*\.events=org.onap.policy.controlloop.params.ControlLoopParams" \ + "${configFile}") +BRMSGW_TOPIC=`echo ${BRMSGW_TOPIC} | sed -e 's/.*topics\.\(.*\)\.events=org.onap.policy.controlloop.params.ControlLoopParams/\1/'` +echo "The BRMSGW topic is: ${BRMSGW_TOPIC}" +echo + +if [ -z "${BRMSGW_TOPIC}" ]; then echo "Aborting: BRMSGW DMaaP Topic was not found in controller properties file"; exit 1; fi + +echo +echo "Inserting ControlLoopParams facts in to working memory..." +echo + +echo +echo "Inserting vCPE Policy..." +curl --silent --user @1b3rt:31nst31n -X PUT --header 'Content-Type: text/plain' -d '{ + "closedLoopControlName": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e", + "controlLoopYaml": "controlLoop%3A%0D%0A++version%3A+2.0.0%0D%0A++controlLoopName%3A+ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e%0D%0A++trigger_policy%3A+unique-policy-id-1-restart%0D%0A++timeout%3A+3600%0D%0A++abatement%3A+true%0D%0A+%0D%0Apolicies%3A%0D%0A++-+id%3A+unique-policy-id-1-restart%0D%0A++++name%3A+Restart+the+VM%0D%0A++++description%3A%0D%0A++++actor%3A+APPC%0D%0A++++recipe%3A+Restart%0D%0A++++target%3A%0D%0A++++++type%3A+VM%0D%0A++++retry%3A+3%0D%0A++++timeout%3A+1200%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", + "policyName": "vcpe", + "policyScope": "DCAE", + "policyVersion": "1.2.0" +}' "http://localhost:9696/policy/pdp/engine/topics/sources/ueb/${BRMSGW_TOPIC}/events" | python -m json.tool + +sleep 2 + +echo +echo "Inserting vFW Policy..." +curl --silent --user @1b3rt:31nst31n -X PUT --header 'Content-Type: text/plain' -d '{ + "closedLoopControlName": "ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a", + "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+Eace933104d443b496b8.nodes.heat.vpg%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", + "policyName": "vfw", + "policyScope": "DCAE", + "policyVersion": "1.2.0" +}' "http://localhost:9696/policy/pdp/engine/topics/sources/ueb/${BRMSGW_TOPIC}/events" | python -m json.tool + +sleep 2 + +echo +echo "Inserting vDNS Policy..." +curl --silent --user @1b3rt:31nst31n -X PUT --header 'Content-Type: text/plain' -d '{ + "closedLoopControlName": "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3", + "controlLoopYaml": "controlLoop%3A%0D%0A++version%3A+2.0.0%0D%0A++controlLoopName%3A+ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3%0D%0A++trigger_policy%3A+unique-policy-id-1-scale-up%0D%0A++timeout%3A+1200%0D%0A++abatement%3A+false%0D%0Apolicies%3A%0D%0A++-+id%3A+unique-policy-id-1-scale-up%0D%0A++++name%3A+Create+a+new+VF+Module%0D%0A++++description%3A%0D%0A++++actor%3A+SO%0D%0A++++recipe%3A+VF+Module+Create%0D%0A++++target%3A%0D%0A++++++type%3A+VNF%0D%0A++++retry%3A+0%0D%0A++++timeout%3A+1200%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", + "policyName": "vdns", + "policyScope": "DCAE", + "policyVersion": "1.2.0" +}' "http://localhost:9696/policy/pdp/engine/topics/sources/ueb/${BRMSGW_TOPIC}/events" | python -m json.tool + +sleep 2 + +echo +echo "Inserting VoLTE Policy..." +curl --silent --user @1b3rt:31nst31n -X PUT --header 'Content-Type: text/plain' -d '{ + "closedLoopControlName": "ControlLoop-VOLTE-2179b738-fd36-4843-a71a-a8c24c70c55b", + "controlLoopYaml": "controlLoop%3A%0D%0A++version%3A+2.0.0%0D%0A++controlLoopName%3A+ControlLoop-VOLTE-2179b738-fd36-4843-a71a-a8c24c70c55b%0D%0A++trigger_policy%3A+unique-policy-id-1-restart%0D%0A++timeout%3A+3600%0D%0A++abatement%3A+false%0D%0A+%0D%0Apolicies%3A%0D%0A++-+id%3A+unique-policy-id-1-restart%0D%0A++++name%3A+Restart+the+VM%0D%0A++++description%3A%0D%0A++++actor%3A+VFC%0D%0A++++recipe%3A+Restart%0D%0A++++target%3A%0D%0A++++++type%3A+VM%0D%0A++++retry%3A+3%0D%0A++++timeout%3A+1200%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", + "policyName": "volte", + "policyScope": "DCAE", + "policyVersion": "1.2.0" +}' "http://localhost:9696/policy/pdp/engine/topics/sources/ueb/${BRMSGW_TOPIC}/events" | python -m json.tool + +sleep 2 + +echo +echo "Policy insertions completed." +echo + +echo "The working memory is now: " +curl --silent --user @1b3rt:31nst31n -X GET http://localhost:9696/policy/pdp/engine/controllers/${CONTROLLER_NAME}/drools/facts/beijing | python -m json.tool |