5f504e2c65d5ea57819d102054067ebb641792ae
[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 distributed-locking
20
21 "${POLICY_HOME}"/bin/db-migrator -s pooling -o upgrade
22
23 # make sure the PDPD-CONFIGURATION anonymous topic is created
24 # so not to lose any configuration updates
25
26 echo
27 echo "testing publish to PDPD-CONFIGURATION topic"
28 echo
29
30 curl --silent --connect-timeout 15 -X POST --header "Content-Type: application/json" -d "{}"   http://message-router:3904/events/PDPD-CONFIGURATION
31
32 echo
33 echo "testing subscribe to PDPD-CONFIGURATION topic "
34 echo
35
36 curl --silent --connect-timeout 15 -X GET http://message-router:3904/events/PDPD-CONFIGURATION/1/1?timeout=5000
37
38 # for resiliency/scalability scenarios, check to see
39 # if there's an amsterdam artifact  already deployed
40 # by brmsgw.  If so, update the amsterdam controller
41 # coordinates.  In the future, a more sophisticated
42 # solution will be put in place, that will required
43 # coordination among policy components.
44
45 echo
46 echo "checking if there are amsterdam policies already deployed .."
47 echo
48
49 AMSTERDAM_VERSION=$(curl --silent --connect-timeout 20 -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>)")
50
51 if [[ -z ${AMSTERDAM_VERSION} ]]; then
52         echo "no amsterdam policies have been found .."
53         exit 0
54 fi
55
56 echo
57 echo "The latest deployed amsterdam artifact in nexus has version ${AMSTERDAM_VERSION}"
58 echo
59
60 sed -i.INSTALL -e "s/^rules.artifactId=.*/rules.artifactId=policy-amsterdam-rules/g" \
61                -e "s/^rules.groupId=.*/rules.groupId=org.onap.policy-engine.drools.amsterdam/g" \
62                -e "s/^rules.version=.*/rules.version=${AMSTERDAM_VERSION}/g" "${POLICY_HOME}"/config/amsterdam-controller.properties
63
64 echo
65 echo "amsterdam controller will be started brained with maven coordinates:"
66 echo
67
68 grep "^rules" "${POLICY_HOME}"/config/amsterdam-controller.properties
69
70 echo
71 echo