Add ability to turn off policy preload 89/18089/2
authorPamela Dragosh <pdragosh@research.att.com>
Tue, 10 Oct 2017 20:18:27 +0000 (16:18 -0400)
committerPamela Dragosh <pdragosh@research.att.com>
Wed, 11 Oct 2017 13:42:57 +0000 (09:42 -0400)
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>
.env [new file with mode: 0644]
README.md
config/pe/push-policies.sh [changed mode: 0644->0755]
docker-compose-integration.yml
docker-compose.yml

diff --git a/.env b/.env
new file mode 100644 (file)
index 0000000..0916ff2
--- /dev/null
+++ b/.env
@@ -0,0 +1,2 @@
+PRELOAD_POLICIES=true
+
index 662800c..28936ca 100644 (file)
--- a/README.md
+++ b/README.md
@@ -12,6 +12,14 @@ To build it using Maven 3, first build 'policy/common', 'policy/engine', 'policy
        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 @@ If you want to call the docker-compose, the following needs to be setup before d
 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.
+
old mode 100644 (file)
new mode 100755 (executable)
index 77f94c0..d50706d
@@ -12,6 +12,12 @@ sleep 2
 
 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"
index 5d1056c..042971d 100644 (file)
@@ -1,4 +1,4 @@
-version: '2'
+version: '3'
 services:
    mariadb:
       image: onap/policy/policy-db
@@ -12,6 +12,8 @@ services:
       hostname: nexus
    pap:
       image: onap/policy/policy-pe
+      environment:
+       - PRELOAD_POLICIES=${PRELOAD_POLICIES}
       container_name: pap
       depends_on: 
        - mariadb
index 2de9ffe..6091dd9 100644 (file)
@@ -1,4 +1,4 @@
-version: '2'
+version: '3'
 networks:
   default:
     driver: bridge
@@ -17,6 +17,8 @@ services:
       hostname: nexus
    pap:
       image: onap/policy/policy-pe
+      environment:
+       - PRELOAD_POLICIES=${PRELOAD_POLICIES}
       container_name: pap
       depends_on: 
        - mariadb