1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. http://creativecommons.org/licenses/by/4.0
11 The installation of ONAP Policy is **automated** by design and can be done via Docker as a standalone system.
12 Various tools, including healthcheck, logs, and Swagger can be used to ensure proper operation.
14 ONAP Policy Framework: Standalone Quick Start
15 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
16 This article explains how to build the ONAP Policy Framework and get it running in Docker as a standalone system.
17 This article assumes that:
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*
22 * 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)
24 The 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.
26 Cloning the ONAP repositories
27 -----------------------------
29 Run 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.
31 ONAP 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.
35 :caption: Typical ONAP Policy Framework Clone Script
40 ## script name for output
41 MOD_SCRIPT_NAME=`basename $0`
43 ## the ONAP clone directory, defaults to "onap"
46 ## the ONAP repos to clone
51 policy/drools-applications \
59 ## Help screen and exit condition (i.e. too few arguments)
64 echo "$MOD_SCRIPT_NAME - clones all required ONAP git repositories"
66 echo " Usage: $MOD_SCRIPT_NAME [-options]"
69 echo " -d - the ONAP clone directory, defaults to '.'"
70 echo " -h - this help screen"
81 #-d ONAP clone directory
85 echo "$MOD_SCRIPT_NAME: no clone directory"
92 #-h prints help and exists
96 *) echo "$MOD_SCRIPT_NAME: undefined CLI option - $1"; exit 255;;
100 if [ -f "$clone_dir" ]; then
101 echo "$MOD_SCRIPT_NAME: requested clone directory '$clone_dir' exists as file"
104 if [ -d "$clone_dir" ]; then
105 echo "$MOD_SCRIPT_NAME: requested clone directory '$clone_dir' exists as directory"
112 echo cannot clone ONAP repositories, could not create directory '"'$clone_dir'"'
116 for repo in $onap_repos
118 repoDir=`dirname "$repo"`
119 repoName=`basename "$repo"`
123 mkdir "$clone_dir/$repoDir"
126 echo cannot clone ONAP repositories, could not create directory '"'$clone_dir/repoDir'"'
131 git clone https://gerrit.onap.org/r/${repo} $clone_dir/$repo
134 echo ONAP has been cloned into '"'$clone_dir'"'
137 Execution of the script above results in the following directory hierarchy in your *~/git* directory:
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
155 **Step 1.** Optionally, for a completely clean build, remove the ONAP built modules from your local repository.
159 rm -fr ~/.m2/repository/org/onap
160 rm -fr ~/.m2/repository/org/openecomp
161 rm -fr ~/.m2/repisotory/com/att
164 **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*.
167 :caption: Typical pom.xml to build the ONAP Policy Framework
170 <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">
171 <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>
183 <module>common</module>
184 <module>engine</module>
187 <module>drools-pdp</module>
188 <module>drools-applications</module>
191 <module>docker</module>
196 **Step 3**. You can now build the ONAP framework
198 * On *Ubuntu*, just build the Policy Framework tests and all
205 * 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.
210 mvn clean install -DskipTests
214 Building the ONAP Policy Framework Docker Images
215 ------------------------------------------------
216 The instructions here are based on the instructions in the file *~/git/onap/policy/docker/README.md*.
219 **Step 1.** Build the policy engine docker image:
223 cd ~/git/onap/policy/engine/packages/docker/target
224 docker build -t onap/policy-pe policy-pe
227 **Step 2.** Build the Drools PDP docker image:
231 cd ~/git/onap/policy/drools-pdp/packages/docker/target
232 docker build -t onap/policy-drools policy-drools
235 **Step 3.** Build the Policy Nexus docker image:
239 cd ~/git/onap/policy/docker
240 docker build -t onap/policy-nexus policy-nexus
243 Starting the ONAP Policy Framework Docker Images
244 ------------------------------------------------
246 In 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.
248 **Step 1.** Make the file config/drools/drools-tweaks.sh executable.
252 chmod +x config/drools/drools-tweaks.sh
255 **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*.
258 **Step 3.** Set the environment variable *MTU* to be a suitable MTU size for the application.
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:
269 export PRELOAD_POLICIES=false
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.
279 Installation Complete
280 ---------------------
282 **You now have a full standalone ONAP Policy framework up and running!**
285 .. _Standalone Quick Start : https://wiki.onap.org/display/DW/ONAP+Policy+Framework%3A+Standalone+Quick+Start