Pamela Dragosh | 5ed4e85 | 2017-09-22 12:26:16 -0400 | [diff] [blame] | 1 | .. This work is licensed under a Creative Commons Attribution 4.0 International License. |
| 2 | .. http://creativecommons.org/licenses/by/4.0 |
| 3 | |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 4 | ************ |
Pamela Dragosh | 5ed4e85 | 2017-09-22 12:26:16 -0400 | [diff] [blame] | 5 | Installation |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 6 | ************ |
Saryu Shah | ba1936f | 2017-10-10 22:20:01 +0000 | [diff] [blame] | 7 | |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 8 | .. contents:: |
| 9 | :depth: 3 |
Saryu Shah | ba1936f | 2017-10-10 22:20:01 +0000 | [diff] [blame] | 10 | |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 11 | The installation of ONAP Policy is **automated** by design and can be done via Docker as a standalone system. |
Saryu Shah | ba1936f | 2017-10-10 22:20:01 +0000 | [diff] [blame] | 12 | Various tools, including healthcheck, logs, and Swagger can be used to ensure proper operation. |
| 13 | |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 14 | ONAP Policy Framework: Standalone Quick Start |
| 15 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 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: |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 18 | |
| 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 Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 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) |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 23 | |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 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. |
| 25 | |
| 26 | Cloning the ONAP repositories |
| 27 | ----------------------------- |
| 28 | |
| 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. |
| 30 | |
| 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. |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 32 | |
| 33 | |
Saryu Shah | f45cebe | 2017-10-13 14:17:11 +0000 | [diff] [blame] | 34 | .. code-block:: bash |
| 35 | :caption: Typical ONAP Policy Framework Clone Script |
| 36 | :linenos: |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 37 | |
| 38 | #!/usr/bin/env bash |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 39 | |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 40 | ## script name for output |
| 41 | MOD_SCRIPT_NAME=`basename $0` |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 42 | |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 43 | ## the ONAP clone directory, defaults to "onap" |
| 44 | clone_dir="onap" |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 45 | |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 46 | ## the ONAP repos to clone |
| 47 | onap_repos="\ |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 48 | 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 Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 57 | |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 58 | ## |
| 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 Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 74 | |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 75 | ## |
| 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 Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 91 | |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 92 | #-h prints help and exists |
| 93 | -h) |
| 94 | Help;exit 0;; |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 95 | |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 96 | *) echo "$MOD_SCRIPT_NAME: undefined CLI option - $1"; exit 255;; |
| 97 | esac |
| 98 | done |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 99 | |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 100 | 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 Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 108 | |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 109 | 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 Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 115 | |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 116 | for repo in $onap_repos |
| 117 | do |
| 118 | repoDir=`dirname "$repo"` |
| 119 | repoName=`basename "$repo"` |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 120 | |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 121 | if [ ! -z $dirName ] |
| 122 | then |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 123 | 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 Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 129 | fi |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 130 | |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 131 | git clone https://gerrit.onap.org/r/${repo} $clone_dir/$repo |
| 132 | done |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 133 | |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 134 | echo ONAP has been cloned into '"'$clone_dir'"' |
| 135 | |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 136 | |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 137 | Execution of the script above results in the following directory hierarchy in your *~/git* directory: |
| 138 | |
Saryu Shah | 3eddd58 | 2017-10-12 22:03:55 +0000 | [diff] [blame] | 139 | * ~/git/onap |
Saryu Shah | 3eddd58 | 2017-10-12 22:03:55 +0000 | [diff] [blame] | 140 | * ~/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 Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 150 | |
| 151 | |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 152 | Building ONAP |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 153 | ------------- |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 154 | |
| 155 | **Step 1.** Optionally, for a completely clean build, remove the ONAP built modules from your local repository. |
| 156 | |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 157 | .. 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 Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 162 | |
Saryu Shah | f45cebe | 2017-10-13 14:17:11 +0000 | [diff] [blame] | 163 | |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 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*. |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 165 | |
Saryu Shah | f45cebe | 2017-10-13 14:17:11 +0000 | [diff] [blame] | 166 | .. code-block:: xml |
| 167 | :caption: Typical pom.xml to build the ONAP Policy Framework |
| 168 | :linenos: |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 169 | |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 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"> |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 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> |
| 178 | <organization> |
| 179 | <name>ONAP</name> |
| 180 | </organization> |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 181 | |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 182 | <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 Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 195 | |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 196 | **Step 3**. You can now build the ONAP framework |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 197 | |
Saryu Shah | 3eddd58 | 2017-10-12 22:03:55 +0000 | [diff] [blame] | 198 | * On *Ubuntu*, just build the Policy Framework tests and all |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 199 | |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 200 | .. code-block:: bash |
| 201 | |
| 202 | cd ~/git/onap |
| 203 | mvn clean install |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 204 | |
Saryu Shah | 3eddd58 | 2017-10-12 22:03:55 +0000 | [diff] [blame] | 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. |
| 206 | |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 207 | .. code-block:: bash |
| 208 | |
| 209 | cd ~/git/onap |
| 210 | mvn clean install -DskipTests |
| 211 | mvn install |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 212 | |
| 213 | |
| 214 | Building the ONAP Policy Framework Docker Images |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 215 | ------------------------------------------------ |
| 216 | The instructions here are based on the instructions in the file *~/git/onap/policy/docker/README.md*. |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 217 | |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 218 | |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 219 | **Step 1.** Build the policy engine docker image: |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 220 | |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 221 | .. code-block:: bash |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 222 | |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 223 | cd ~/git/onap/policy/engine/packages/docker/target |
| 224 | docker build -t onap/policy-pe policy-pe |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 225 | |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 226 | |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 227 | **Step 2.** Build the Drools PDP docker image: |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 228 | |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 229 | .. code-block:: bash |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 230 | |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 231 | 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 Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 242 | |
| 243 | Starting the ONAP Policy Framework Docker Images |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 244 | ------------------------------------------------ |
| 245 | |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 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. |
| 247 | |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 248 | **Step 1.** Make the file config/drools/drools-tweaks.sh executable. |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 249 | |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 250 | .. code-block:: bash |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 251 | |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 252 | chmod +x config/drools/drools-tweaks.sh |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 253 | |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 254 | |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 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*. |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 256 | |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 257 | |
| 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 Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 277 | |
| 278 | |
| 279 | Installation Complete |
Saryu Shah | 5c43749 | 2018-03-26 21:50:41 +0000 | [diff] [blame] | 280 | --------------------- |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 281 | |
| 282 | **You now have a full standalone ONAP Policy framework up and running!** |
| 283 | |
| 284 | |
Saryu Shah | ba1936f | 2017-10-10 22:20:01 +0000 | [diff] [blame] | 285 | .. _Standalone Quick Start : https://wiki.onap.org/display/DW/ONAP+Policy+Framework%3A+Standalone+Quick+Start |
Pamela Dragosh | 5ed4e85 | 2017-09-22 12:26:16 -0400 | [diff] [blame] | 286 | |
| 287 | |
Saryu Shah | 3198d6d | 2017-11-07 21:40:27 +0000 | [diff] [blame] | 288 | |
| 289 | End of Document |
| 290 | |