218cd8aeaddc9f458d7b569154343d0e5d5cddc8
[oom.git] / kubernetes / policy / charts / drools / resources / config / opt / policy / config / drools / drools-tweaks.sh
1 #! /bin/bash -xv
2
3 # Copyright © 2017-2018 Amdocs, Bell Canada, AT&T
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #       http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17
18 "${POLICY_HOME}"/bin/features enable healthcheck
19 "${POLICY_HOME}"/bin/features enable pooling-dmaap
20 "${POLICY_HOME}"/bin/features enable distributed-locking
21
22 "${POLICY_HOME}"/bin/db-migrator -s pooling -o upgrade
23
24 # make sure the PDPD-CONFIGURATION anonymous topic is created
25 # so not to lose any configuration updates
26
27 echo
28 echo "creating PDPD-CONFIGURATION topic"
29 echo
30
31 curl --silent --connect-timeout 60 -X POST --header "Content-Type: application/json" -d "{}"   http://message-router:3904/events/PDPD-CONFIGURATION
32
33 echo
34 echo "removing PDPD-CONFIGURATION topic dummy message"
35 echo
36
37 curl --silent --connect-timeout 60 -X GET http://message-router:3904/events/PDPD-CONFIGURATION/1/1?timeout=15000
38
39 # for resiliency/scalability scenarios, check to see
40 # if there's an amsterdam artifact  already deployed
41 # by brmsgw.  If so, update the amsterdam controller
42 # coordinates.  In the future, a more sophisticated
43 # solution will be put in place, that will required
44 # coordination among policy components.
45
46 echo
47 echo "checking if there are amsterdam policies already deployed .."
48 echo
49
50 AMSTERDAM_VERSION=$(curl --silent --connect-timeout 60 -X GET "http://nexus:8081/nexus/service/local/artifact/maven/resolve?r=releases&g=org.onap.policy-engine.drools.amsterdam&a=policy-amsterdam-rules&v=RELEASE" | grep -Po "(?<=<version>).*(?=</version>)")
51
52 if [[ -z ${AMSTERDAM_VERSION} ]]; then
53         echo "no amsterdam policies have been found .."
54         exit 0
55 fi
56
57 echo
58 echo "The latest deployed amsterdam artifact in nexus has version ${AMSTERDAM_VERSION}"
59 echo
60
61 sed -i.INSTALL -e "s/^rules.artifactId=.*/rules.artifactId=policy-amsterdam-rules/g" \
62                -e "s/^rules.groupId=.*/rules.groupId=org.onap.policy-engine.drools.amsterdam/g" \
63                -e "s/^rules.version=.*/rules.version=${AMSTERDAM_VERSION}/g" "${POLICY_HOME}"/config/amsterdam-controller.properties
64
65 echo
66 echo "amsterdam controller will be started brained with maven coordinates:"
67 echo
68
69 grep "^rules" "${POLICY_HOME}"/config/amsterdam-controller.properties
70
71 echo
72 echo