blob: d097b0a98f3d420682325e966c18f9cba6375495 [file] [log] [blame]
Pamela Dragosh5ed4e852017-09-22 12:26:16 -04001.. This work is licensed under a Creative Commons Attribution 4.0 International License.
2.. http://creativecommons.org/licenses/by/4.0
3
Saryu Shah5c437492018-03-26 21:50:41 +00004************
Pamela Dragosh5ed4e852017-09-22 12:26:16 -04005Installation
Saryu Shah5c437492018-03-26 21:50:41 +00006************
Saryu Shahba1936f2017-10-10 22:20:01 +00007
Saryu Shahb6209af2017-10-11 20:12:38 +00008.. contents::
9 :depth: 3
Saryu Shahba1936f2017-10-10 22:20:01 +000010
Saryu Shahb6209af2017-10-11 20:12:38 +000011The installation of ONAP Policy is **automated** by design and can be done via Docker as a standalone system.
Saryu Shahba1936f2017-10-10 22:20:01 +000012Various tools, including healthcheck, logs, and Swagger can be used to ensure proper operation.
13
Saryu Shahb6209af2017-10-11 20:12:38 +000014ONAP Policy Framework: Standalone Quick Start
15^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Saryu Shah5c437492018-03-26 21:50:41 +000016This article explains how to build the ONAP Policy Framework and get it running in Docker as a standalone system.
17This article assumes that:
Saryu Shahb6209af2017-10-11 20:12:38 +000018
19* You are using a *\*nix* operating system such as linux or macOS.
20* You are using a directory called *git* off your home directory *(~/git)* for your git repositories
21* Your local maven repository is in the location *~/.m2/repository*
Saryu Shah5c437492018-03-26 21:50:41 +000022* You have added settings to access the ONAP Nexus to your M2 configuration, see `Maven Settings Example <https://wiki.onap.org/display/DW/Setting+Up+Your+Development+Environment>`_ (bottom of the linked page)
Saryu Shahb6209af2017-10-11 20:12:38 +000023
Saryu Shah5c437492018-03-26 21:50:41 +000024The procedure documented in this article has been verified to work on a MacBook laptop running macOS Sierra Version 10.12.6 and a HP Z600 desktop running Ubuntu 16.04.3 LTS.
25
26Cloning the ONAP repositories
27-----------------------------
28
29Run a script such as the script below to clone the required modules from the `ONAP git repository <https://gerrit.onap.org/r/#/admin/projects/?filter=policy>`_. This script clones the ONAP policy code and also clones some modules that ONAP Policy is dependent on.
30
31ONAP Policy requires all the *policy* modules from the ONAP repository. It also requires the ONAP Parent *oparent* module and the ONAP ECOMP SDK *ecompsdkos* module.
Saryu Shahb6209af2017-10-11 20:12:38 +000032
33
Saryu Shahf45cebe2017-10-13 14:17:11 +000034.. code-block:: bash
35 :caption: Typical ONAP Policy Framework Clone Script
36 :linenos:
Saryu Shahb6209af2017-10-11 20:12:38 +000037
38 #!/usr/bin/env bash
Saryu Shah5c437492018-03-26 21:50:41 +000039
Saryu Shahb6209af2017-10-11 20:12:38 +000040 ## script name for output
41 MOD_SCRIPT_NAME=`basename $0`
Saryu Shah5c437492018-03-26 21:50:41 +000042
Saryu Shahb6209af2017-10-11 20:12:38 +000043 ## the ONAP clone directory, defaults to "onap"
44 clone_dir="onap"
Saryu Shah5c437492018-03-26 21:50:41 +000045
Saryu Shahb6209af2017-10-11 20:12:38 +000046 ## the ONAP repos to clone
47 onap_repos="\
Saryu Shahb6209af2017-10-11 20:12:38 +000048 policy/api \
49 policy/common \
50 policy/docker \
51 policy/drools-applications \
52 policy/drools-pdp \
53 policy/engine \
54 policy/gui \
55 policy/pap \
56 policy/pdp"
Saryu Shah5c437492018-03-26 21:50:41 +000057
Saryu Shahb6209af2017-10-11 20:12:38 +000058 ##
59 ## Help screen and exit condition (i.e. too few arguments)
60 ##
61 Help()
62 {
63 echo ""
64 echo "$MOD_SCRIPT_NAME - clones all required ONAP git repositories"
65 echo ""
66 echo " Usage: $MOD_SCRIPT_NAME [-options]"
67 echo ""
68 echo " Options"
69 echo " -d - the ONAP clone directory, defaults to '.'"
70 echo " -h - this help screen"
71 echo ""
72 exit 255;
73 }
Saryu Shah5c437492018-03-26 21:50:41 +000074
Saryu Shahb6209af2017-10-11 20:12:38 +000075 ##
76 ## read command line
77 ##
78 while [ $# -gt 0 ]
79 do
80 case $1 in
81 #-d ONAP clone directory
82 -d)
83 shift
84 if [ -z "$1" ]; then
85 echo "$MOD_SCRIPT_NAME: no clone directory"
86 exit 1
87 fi
88 clone_dir=$1
89 shift
90 ;;
Saryu Shah5c437492018-03-26 21:50:41 +000091
Saryu Shahb6209af2017-10-11 20:12:38 +000092 #-h prints help and exists
93 -h)
94 Help;exit 0;;
Saryu Shah5c437492018-03-26 21:50:41 +000095
Saryu Shahb6209af2017-10-11 20:12:38 +000096 *) echo "$MOD_SCRIPT_NAME: undefined CLI option - $1"; exit 255;;
97 esac
98 done
Saryu Shah5c437492018-03-26 21:50:41 +000099
Saryu Shahb6209af2017-10-11 20:12:38 +0000100 if [ -f "$clone_dir" ]; then
101 echo "$MOD_SCRIPT_NAME: requested clone directory '$clone_dir' exists as file"
102 exit 2
103 fi
104 if [ -d "$clone_dir" ]; then
105 echo "$MOD_SCRIPT_NAME: requested clone directory '$clone_dir' exists as directory"
106 exit 2
107 fi
Saryu Shah5c437492018-03-26 21:50:41 +0000108
Saryu Shahb6209af2017-10-11 20:12:38 +0000109 mkdir $clone_dir
110 if [ $? != 0 ]
111 then
112 echo cannot clone ONAP repositories, could not create directory '"'$clone_dir'"'
113 exit 3
114 fi
Saryu Shah5c437492018-03-26 21:50:41 +0000115
Saryu Shahb6209af2017-10-11 20:12:38 +0000116 for repo in $onap_repos
117 do
118 repoDir=`dirname "$repo"`
119 repoName=`basename "$repo"`
Saryu Shah5c437492018-03-26 21:50:41 +0000120
Saryu Shahb6209af2017-10-11 20:12:38 +0000121 if [ ! -z $dirName ]
122 then
Saryu Shah5c437492018-03-26 21:50:41 +0000123 mkdir "$clone_dir/$repoDir"
124 if [ $? != 0 ]
125 then
126 echo cannot clone ONAP repositories, could not create directory '"'$clone_dir/repoDir'"'
127 exit 4
128 fi
Saryu Shahb6209af2017-10-11 20:12:38 +0000129 fi
Saryu Shah5c437492018-03-26 21:50:41 +0000130
Saryu Shahb6209af2017-10-11 20:12:38 +0000131 git clone https://gerrit.onap.org/r/${repo} $clone_dir/$repo
132 done
Saryu Shah5c437492018-03-26 21:50:41 +0000133
Saryu Shahb6209af2017-10-11 20:12:38 +0000134 echo ONAP has been cloned into '"'$clone_dir'"'
135
Saryu Shah5c437492018-03-26 21:50:41 +0000136
Saryu Shahb6209af2017-10-11 20:12:38 +0000137Execution of the script above results in the following directory hierarchy in your *~/git* directory:
138
Saryu Shah3eddd582017-10-12 22:03:55 +0000139 * ~/git/onap
Saryu Shah3eddd582017-10-12 22:03:55 +0000140 * ~/git/onap/policy
141 * ~/git/onap/policy/api
142 * ~/git/onap/policy/common
143 * ~/git/onap/policy/docker
144 * ~/git/onap/policy/drools-applications
145 * ~/git/onap/policy/drools-pdp
146 * ~/git/onap/policy/engine
147 * ~/git/onap/policy/gui
148 * ~/git/onap/policy/pap
149 * ~/git/onap/policy/pdp
Saryu Shahb6209af2017-10-11 20:12:38 +0000150
151
Saryu Shahb6209af2017-10-11 20:12:38 +0000152Building ONAP
Saryu Shah5c437492018-03-26 21:50:41 +0000153-------------
Saryu Shahb6209af2017-10-11 20:12:38 +0000154
155**Step 1.** Optionally, for a completely clean build, remove the ONAP built modules from your local repository.
156
Saryu Shah5c437492018-03-26 21:50:41 +0000157 .. code-block:: bash
158
159 rm -fr ~/.m2/repository/org/onap
160 rm -fr ~/.m2/repository/org/openecomp
161 rm -fr ~/.m2/repisotory/com/att
Saryu Shahb6209af2017-10-11 20:12:38 +0000162
Saryu Shahf45cebe2017-10-13 14:17:11 +0000163
Saryu Shah5c437492018-03-26 21:50:41 +0000164**Step 2**. A pom such as the one below can be used to build the ONAP Policy Framework modules. Create the *pom.xml* file in the directory *~/git/onap/policy*.
Saryu Shahb6209af2017-10-11 20:12:38 +0000165
Saryu Shahf45cebe2017-10-13 14:17:11 +0000166.. code-block:: xml
167 :caption: Typical pom.xml to build the ONAP Policy Framework
168 :linenos:
Saryu Shahb6209af2017-10-11 20:12:38 +0000169
Saryu Shah5c437492018-03-26 21:50:41 +0000170 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
Saryu Shahb6209af2017-10-11 20:12:38 +0000171 <modelVersion>4.0.0</modelVersion>
172 <groupId>org.onap</groupId>
173 <artifactId>onap-policy</artifactId>
174 <version>1.0.0-SNAPSHOT</version>
175 <packaging>pom</packaging>
176 <name>${project.artifactId}</name>
177 <inceptionYear>2017</inceptionYear>
178 <organization>
179 <name>ONAP</name>
180 </organization>
Saryu Shah5c437492018-03-26 21:50:41 +0000181
Saryu Shahb6209af2017-10-11 20:12:38 +0000182 <modules>
183 <module>common</module>
184 <module>engine</module>
185 <module>pdp</module>
186 <module>pap</module>
187 <module>drools-pdp</module>
188 <module>drools-applications</module>
189 <module>api</module>
190 <module>gui</module>
191 <module>docker</module>
192 </modules>
193 </project>
194
Saryu Shahb6209af2017-10-11 20:12:38 +0000195
Saryu Shah5c437492018-03-26 21:50:41 +0000196**Step 3**. You can now build the ONAP framework
Saryu Shahb6209af2017-10-11 20:12:38 +0000197
Saryu Shah3eddd582017-10-12 22:03:55 +0000198 * On *Ubuntu*, just build the Policy Framework tests and all
Saryu Shahb6209af2017-10-11 20:12:38 +0000199
Saryu Shah5c437492018-03-26 21:50:41 +0000200 .. code-block:: bash
201
202 cd ~/git/onap
203 mvn clean install
Saryu Shahb6209af2017-10-11 20:12:38 +0000204
Saryu Shah3eddd582017-10-12 22:03:55 +0000205 * On *macOS*, you must build build the ONAP framework with tests turned off first. Then rebuild the framework with tests turned on and all tests will pass. Note: The reason for this behaviour will be explored later.
206
Saryu Shah5c437492018-03-26 21:50:41 +0000207 .. code-block:: bash
208
209 cd ~/git/onap
210 mvn clean install -DskipTests
211 mvn install
Saryu Shahb6209af2017-10-11 20:12:38 +0000212
213
214Building the ONAP Policy Framework Docker Images
Saryu Shah5c437492018-03-26 21:50:41 +0000215------------------------------------------------
216The instructions here are based on the instructions in the file *~/git/onap/policy/docker/README.md*.
Saryu Shahb6209af2017-10-11 20:12:38 +0000217
Saryu Shahb6209af2017-10-11 20:12:38 +0000218
Saryu Shah5c437492018-03-26 21:50:41 +0000219**Step 1.** Build the policy engine docker image:
Saryu Shahb6209af2017-10-11 20:12:38 +0000220
Saryu Shah5c437492018-03-26 21:50:41 +0000221 .. code-block:: bash
Saryu Shahb6209af2017-10-11 20:12:38 +0000222
Saryu Shah5c437492018-03-26 21:50:41 +0000223 cd ~/git/onap/policy/engine/packages/docker/target
224 docker build -t onap/policy-pe policy-pe
Saryu Shahb6209af2017-10-11 20:12:38 +0000225
Saryu Shahb6209af2017-10-11 20:12:38 +0000226
Saryu Shah5c437492018-03-26 21:50:41 +0000227**Step 2.** Build the Drools PDP docker image:
Saryu Shahb6209af2017-10-11 20:12:38 +0000228
Saryu Shah5c437492018-03-26 21:50:41 +0000229 .. code-block:: bash
Saryu Shahb6209af2017-10-11 20:12:38 +0000230
Saryu Shah5c437492018-03-26 21:50:41 +0000231 cd ~/git/onap/policy/drools-pdp/packages/docker/target
232 docker build -t onap/policy-drools policy-drools
233
234
235**Step 3.** Build the Policy Nexus docker image:
236
237 .. code-block:: bash
238
239 cd ~/git/onap/policy/docker
240 docker build -t onap/policy-nexus policy-nexus
241
Saryu Shahb6209af2017-10-11 20:12:38 +0000242
243Starting the ONAP Policy Framework Docker Images
Saryu Shah5c437492018-03-26 21:50:41 +0000244------------------------------------------------
245
Saryu Shahb6209af2017-10-11 20:12:38 +0000246In order to run the containers, you can use *docker-compose*. This uses the *docker-compose.yml* yaml file to bring up the ONAP Policy Framework.
247
Saryu Shah5c437492018-03-26 21:50:41 +0000248**Step 1.** Make the file config/drools/drools-tweaks.sh executable.
Saryu Shahb6209af2017-10-11 20:12:38 +0000249
Saryu Shah5c437492018-03-26 21:50:41 +0000250 .. code-block:: bash
Saryu Shahb6209af2017-10-11 20:12:38 +0000251
Saryu Shah5c437492018-03-26 21:50:41 +0000252 chmod +x config/drools/drools-tweaks.sh
Saryu Shahb6209af2017-10-11 20:12:38 +0000253
Saryu Shahb6209af2017-10-11 20:12:38 +0000254
Saryu Shah5c437492018-03-26 21:50:41 +0000255**Step 2.** Set the IP address to use to be an IP address of a suitable interface on your machine. Save the IP address into the file *config/pe/ip_addr.txt*.
Saryu Shahb6209af2017-10-11 20:12:38 +0000256
Saryu Shah5c437492018-03-26 21:50:41 +0000257
258**Step 3.** Set the environment variable *MTU* to be a suitable MTU size for the application.
259
260 .. code-block:: bash
261
262 export MTU=9126
263
264
265**Step 4.** Determine if you want policies pre-loaded or not. By default, all the configuration and operational policies will be pre-loaded by the docker compose script. If you do not wish for that to happen, then export this variable:
266
267 .. code-block:: bash
268
269 export PRELOAD_POLICIES=false
270
271
272**Step 5.** Run the system using *docker-compose*. Note that on some systems you may have to run the *docker-compose* command as root or using *sudo*. Note that this command takes a number of minutes to execute on a laptop or desktop computer.
273
274 .. code-block:: bash
275
276 docker-compose up
Saryu Shahb6209af2017-10-11 20:12:38 +0000277
278
279Installation Complete
Saryu Shah5c437492018-03-26 21:50:41 +0000280---------------------
Saryu Shahb6209af2017-10-11 20:12:38 +0000281
282**You now have a full standalone ONAP Policy framework up and running!**
283
284
Saryu Shahba1936f2017-10-10 22:20:01 +0000285.. _Standalone Quick Start : https://wiki.onap.org/display/DW/ONAP+Policy+Framework%3A+Standalone+Quick+Start
Pamela Dragosh5ed4e852017-09-22 12:26:16 -0400286
287
Saryu Shah3198d6d2017-11-07 21:40:27 +0000288
289End of Document
290