Add ability to turn off policy preload
You can now set environment variable to override whether or not the
policies are pre-loaded by the engines during docker image startup.
The README.md is updated with instructions. Each docker-compose has
a different default set.
The .env file is set to load policies by default to true. You can override
by either changing this file or setting the environment:
export PRELOAD_POLICIES=false
Issue-ID: POLICY-304
Change-Id: Ia96788ac3b8d47814eea1046d96c4e3e4a0b9664
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
diff --git a/.env b/.env
new file mode 100644
index 0000000..0916ff2
--- /dev/null
+++ b/.env
@@ -0,0 +1,2 @@
+PRELOAD_POLICIES=true
+
diff --git a/README.md b/README.md
index 662800c..28936ca 100644
--- a/README.md
+++ b/README.md
@@ -12,6 +12,14 @@
target/policy-pe
target/policy-drools
+For example:
+docker build -t onap/policy/policy-os policy-os
+docker build -t onap/policy/policy-db policy-db
+docker build -t onap/policy/policy-nexus policy-nexus
+docker build -t onap/policy/policy-base policy-base
+docker build -t onap/policy/policy-pe target/policy-pe
+docker build -t onap/policy/policy-drools target/policy-drools
+
In addition, the 'config' directory contains configuration files that are read during the startup of the containers; this directory is referenced by the docker-compose.yml file.
If you want to call the docker-compose, the following needs to be setup before doing so:
@@ -19,3 +27,10 @@
chmod +x config/drools/drools-tweaks.sh
IP_ADDRESS=$(ifconfig eth0 | grep "inet addr" | tr -s ' ' | cut -d' ' -f3 | cut -d':' -f2)
echo $IP_ADDRESS > config/pe/ip_addr.txt
+
+If you do not want the policies pre-loaded, then set this environment variable to false:
+
+export PRELOAD_POLICIES=false
+
+It will override the settings in the .env file. Which is set to true.
+
diff --git a/config/pe/push-policies.sh b/config/pe/push-policies.sh
old mode 100644
new mode 100755
index 77f94c0..d50706d
--- a/config/pe/push-policies.sh
+++ b/config/pe/push-policies.sh
@@ -12,6 +12,12 @@
curl -v --silent -X POST --header 'Content-Type: multipart/form-data' --header 'Accept: text/plain' --header 'ClientAuth: cHl0aG9uOnRlc3Q=' --header 'Authorization: Basic dGVzdHBkcDphbHBoYTEyMw==' --header 'Environment: TEST' -F "file=@cl-amsterdam-template.drl" -F "importParametersJson={\"serviceName\":\"ClosedLoopControlName\",\"serviceType\":\"BRMSPARAM\"}" 'http://pdp:8081/pdp/api/policyEngineImport'
+echo "PRELOAD_POLICIES is $PRELOAD_POLICIES"
+
+if [ "$PRELOAD_POLICIES" == "false" ]; then
+ exit 0
+fi
+
#########################################Create BRMS Param policies##########################################
echo "Create BRMSParam Operational Policies"
diff --git a/docker-compose-integration.yml b/docker-compose-integration.yml
index 5d1056c..042971d 100644
--- a/docker-compose-integration.yml
+++ b/docker-compose-integration.yml
@@ -1,4 +1,4 @@
-version: '2'
+version: '3'
services:
mariadb:
image: onap/policy/policy-db
@@ -12,6 +12,8 @@
hostname: nexus
pap:
image: onap/policy/policy-pe
+ environment:
+ - PRELOAD_POLICIES=${PRELOAD_POLICIES}
container_name: pap
depends_on:
- mariadb
diff --git a/docker-compose.yml b/docker-compose.yml
index 2de9ffe..6091dd9 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,4 +1,4 @@
-version: '2'
+version: '3'
networks:
default:
driver: bridge
@@ -17,6 +17,8 @@
hostname: nexus
pap:
image: onap/policy/policy-pe
+ environment:
+ - PRELOAD_POLICIES=${PRELOAD_POLICIES}
container_name: pap
depends_on:
- mariadb