1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. http://creativecommons.org/licenses/by/4.0
4 Standalone Quick Start Installation
5 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10 The installation of ONAP Policy is **automated** by design and can be done via Docker as a standalone system.
11 Various tools, including healthcheck, logs, and Swagger can be used to ensure proper operation.
13 This article explains how to build the ONAP Policy Framework and get it running in Docker as a standalone system.
14 This article assumes that:
16 * You are using a *\*nix* operating system such as linux or macOS.
17 * You are using a directory called *git* off your home directory *(~/git)* for your git repositories
18 * Your local maven repository is in the location *~/.m2/repository*
19 * 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)
21 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.
23 Cloning the ONAP repositories
24 -----------------------------
26 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.
28 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.
32 :caption: Typical ONAP Policy Framework Clone Script
37 ## script name for output
38 MOD_SCRIPT_NAME=`basename $0`
40 ## the ONAP clone directory, defaults to "onap"
43 ## the ONAP repos to clone
48 policy/drools-applications \
55 ## Help screen and exit condition (i.e. too few arguments)
60 echo "$MOD_SCRIPT_NAME - clones all required ONAP git repositories"
62 echo " Usage: $MOD_SCRIPT_NAME [-options]"
65 echo " -d - the ONAP clone directory, defaults to '.'"
66 echo " -h - this help screen"
77 #-d ONAP clone directory
81 echo "$MOD_SCRIPT_NAME: no clone directory"
88 #-h prints help and exists
92 *) echo "$MOD_SCRIPT_NAME: undefined CLI option - $1"; exit 255;;
96 if [ -f "$clone_dir" ]; then
97 echo "$MOD_SCRIPT_NAME: requested clone directory '$clone_dir' exists as file"
100 if [ -d "$clone_dir" ]; then
101 echo "$MOD_SCRIPT_NAME: requested clone directory '$clone_dir' exists as directory"
108 echo cannot clone ONAP repositories, could not create directory '"'$clone_dir'"'
112 for repo in $onap_repos
114 repoDir=`dirname "$repo"`
115 repoName=`basename "$repo"`
119 mkdir "$clone_dir/$repoDir"
122 echo cannot clone ONAP repositories, could not create directory '"'$clone_dir/repoDir'"'
127 git clone https://gerrit.onap.org/r/${repo} $clone_dir/$repo
130 echo ONAP has been cloned into '"'$clone_dir'"'
133 Execution of the script above results in the following directory hierarchy in your *~/git* directory:
137 * ~/git/onap/policy/parent
138 * ~/git/onap/policy/common
139 * ~/git/onap/policy/docker
140 * ~/git/onap/policy/drools-applications
141 * ~/git/onap/policy/drools-pdp
142 * ~/git/onap/policy/engine
143 * ~/git/onap/policy/apex-pdp
144 * ~/git/onap/policy/distribution
150 **Step 1:** Optionally, for a completely clean build, remove the ONAP built modules from your local repository.
154 rm -fr ~/.m2/repository/org/onap
155 rm -fr ~/.m2/repository/org/openecomp
156 rm -fr ~/.m2/repisotory/com/att
159 **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*.
162 :caption: Typical pom.xml to build the ONAP Policy Framework
165 <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">
166 <modelVersion>4.0.0</modelVersion>
167 <groupId>org.onap</groupId>
168 <artifactId>onap-policy</artifactId>
169 <version>1.0.0-SNAPSHOT</version>
170 <packaging>pom</packaging>
171 <name>${project.artifactId}</name>
172 <inceptionYear>2017</inceptionYear>
178 <module>parent</module>
179 <module>common</module>
180 <module>drools-pdp</module>
181 <module>drools-applications</module>
182 <module>engine</module>
183 <module>apex-pdp</module>
184 <module>distribution</module>
189 **Step 3:** You can now build the ONAP framework
197 Building the ONAP Policy Framework Docker Images
198 ------------------------------------------------
199 The instructions here are based on the instructions in the file *~/git/onap/policy/docker/README.md*.
202 **Step 1:** Build the policy engine docker image:
206 cd ~/git/onap/policy/engine/packages/docker/target
207 docker build -t onap/policy-pe policy-pe
210 **Step 2:** Build the Drools PDP docker image:
214 cd ~/git/onap/policy/drools-pdp/packages/docker/target
215 docker build -t onap/policy-drools policy-drools
218 **Step 3:** Build the Policy SDC Distribution docker image:
222 cd ~/git/onap/policy/distribution/packages
223 mvn clean install -Pdocker
225 **Step 4:** Build the Apex PDP docker image:
229 cd ~/git/onap/policy/apex-pdp/packages/apex-pdp-docker/target
230 docker build -t onap/policy-apex-pdp policy-apex-pdp
233 Starting the ONAP Policy Framework Docker Images
234 ------------------------------------------------
236 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. This file is located in the policy/docker repository.
238 **Step 1:** Make the file config/drools/drools-tweaks.sh executable.
242 chmod +x config/drools/drools-tweaks.sh
245 **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*.
248 **Step 3:** Set the environment variable *MTU* to be a suitable MTU size for the application.
255 **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:
259 export PRELOAD_POLICIES=false
262 **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.
269 **You now have a full standalone ONAP Policy framework up and running!**
272 Installation of Drools Controllers and Policies
273 -----------------------------------------------
275 You may now install a controller and policies on the ONAP Policy Framework. Follow the HowTos below to install the Amsterdam controller and policies.
277 * `Installation of Amsterdam Controller and vCPE Policy <installAmsterController.html>`_
281 .. _Standalone Quick Start : https://wiki.onap.org/display/DW/ONAP+Policy+Framework%3A+Standalone+Quick+Start