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 | |
| 4 | Installation |
| 5 | ------------ |
Saryu Shah | ba1936f | 2017-10-10 22:20:01 +0000 | [diff] [blame] | 6 | |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 7 | .. contents:: |
| 8 | :depth: 3 |
Saryu Shah | ba1936f | 2017-10-10 22:20:01 +0000 | [diff] [blame] | 9 | |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 10 | 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] | 11 | Various tools, including healthcheck, logs, and Swagger can be used to ensure proper operation. |
| 12 | |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 13 | ONAP Policy Framework: Standalone Quick Start |
| 14 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
Saryu Shah | 3eddd58 | 2017-10-12 22:03:55 +0000 | [diff] [blame] | 15 | This procedure explains how build the ONAP Policy Framework and get it running in Docker as a standalone system. |
| 16 | This procedure assumes that: |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 17 | |
| 18 | * You are using a *\*nix* operating system such as linux or macOS. |
| 19 | * You are using a directory called *git* off your home directory *(~/git)* for your git repositories |
| 20 | * Your local maven repository is in the location *~/.m2/repository* |
| 21 | |
Saryu Shah | 3eddd58 | 2017-10-12 22:03:55 +0000 | [diff] [blame] | 22 | The procedure documented here 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. |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 23 | |
| 24 | |
Saryu Shah | f45cebe | 2017-10-13 14:17:11 +0000 | [diff] [blame^] | 25 | .. code-block:: bash |
| 26 | :caption: Typical ONAP Policy Framework Clone Script |
| 27 | :linenos: |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 28 | |
| 29 | #!/usr/bin/env bash |
| 30 | |
| 31 | ## script name for output |
| 32 | MOD_SCRIPT_NAME=`basename $0` |
| 33 | |
| 34 | ## the ONAP clone directory, defaults to "onap" |
| 35 | clone_dir="onap" |
| 36 | |
| 37 | ## the ONAP repos to clone |
| 38 | onap_repos="\ |
| 39 | oparent \ |
| 40 | ecompsdkos \ |
| 41 | policy/api \ |
| 42 | policy/common \ |
| 43 | policy/docker \ |
| 44 | policy/drools-applications \ |
| 45 | policy/drools-pdp \ |
| 46 | policy/engine \ |
| 47 | policy/gui \ |
| 48 | policy/pap \ |
| 49 | policy/pdp" |
| 50 | |
| 51 | ## |
| 52 | ## Help screen and exit condition (i.e. too few arguments) |
| 53 | ## |
| 54 | Help() |
| 55 | { |
| 56 | echo "" |
| 57 | echo "$MOD_SCRIPT_NAME - clones all required ONAP git repositories" |
| 58 | echo "" |
| 59 | echo " Usage: $MOD_SCRIPT_NAME [-options]" |
| 60 | echo "" |
| 61 | echo " Options" |
| 62 | echo " -d - the ONAP clone directory, defaults to '.'" |
| 63 | echo " -h - this help screen" |
| 64 | echo "" |
| 65 | exit 255; |
| 66 | } |
| 67 | |
| 68 | ## |
| 69 | ## read command line |
| 70 | ## |
| 71 | while [ $# -gt 0 ] |
| 72 | do |
| 73 | case $1 in |
| 74 | #-d ONAP clone directory |
| 75 | -d) |
| 76 | shift |
| 77 | if [ -z "$1" ]; then |
| 78 | echo "$MOD_SCRIPT_NAME: no clone directory" |
| 79 | exit 1 |
| 80 | fi |
| 81 | clone_dir=$1 |
| 82 | shift |
| 83 | ;; |
| 84 | |
| 85 | #-h prints help and exists |
| 86 | -h) |
| 87 | Help;exit 0;; |
| 88 | |
| 89 | *) echo "$MOD_SCRIPT_NAME: undefined CLI option - $1"; exit 255;; |
| 90 | esac |
| 91 | done |
| 92 | |
| 93 | if [ -f "$clone_dir" ]; then |
| 94 | echo "$MOD_SCRIPT_NAME: requested clone directory '$clone_dir' exists as file" |
| 95 | exit 2 |
| 96 | fi |
| 97 | if [ -d "$clone_dir" ]; then |
| 98 | echo "$MOD_SCRIPT_NAME: requested clone directory '$clone_dir' exists as directory" |
| 99 | exit 2 |
| 100 | fi |
| 101 | |
| 102 | mkdir $clone_dir |
| 103 | if [ $? != 0 ] |
| 104 | then |
| 105 | echo cannot clone ONAP repositories, could not create directory '"'$clone_dir'"' |
| 106 | exit 3 |
| 107 | fi |
| 108 | |
| 109 | for repo in $onap_repos |
| 110 | do |
| 111 | repoDir=`dirname "$repo"` |
| 112 | repoName=`basename "$repo"` |
| 113 | |
| 114 | if [ ! -z $dirName ] |
| 115 | then |
| 116 | mkdir "$clone_dir/$repoDir" |
| 117 | if [ $? != 0 ] |
| 118 | then |
| 119 | echo cannot clone ONAP repositories, could not create directory '"'$clone_dir/repoDir'"' |
| 120 | exit 4 |
| 121 | fi |
| 122 | fi |
| 123 | |
| 124 | git clone https://gerrit.onap.org/r/${repo} $clone_dir/$repo |
| 125 | done |
| 126 | |
| 127 | echo ONAP has been cloned into '"'$clone_dir'"' |
| 128 | |
| 129 | Execution of the script above results in the following directory hierarchy in your *~/git* directory: |
| 130 | |
Saryu Shah | 3eddd58 | 2017-10-12 22:03:55 +0000 | [diff] [blame] | 131 | * ~/git/onap |
| 132 | * ~/git/onap/ecompsdkos |
| 133 | * ~/git/onap/oparent |
| 134 | * ~/git/onap/policy |
| 135 | * ~/git/onap/policy/api |
| 136 | * ~/git/onap/policy/common |
| 137 | * ~/git/onap/policy/docker |
| 138 | * ~/git/onap/policy/drools-applications |
| 139 | * ~/git/onap/policy/drools-pdp |
| 140 | * ~/git/onap/policy/engine |
| 141 | * ~/git/onap/policy/gui |
| 142 | * ~/git/onap/policy/pap |
| 143 | * ~/git/onap/policy/pdp |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 144 | |
| 145 | |
| 146 | |
| 147 | Building ONAP |
| 148 | ^^^^^^^^^^^^^ |
| 149 | |
| 150 | **Step 1.** Optionally, for a completely clean build, remove the ONAP built modules from your local repository. |
| 151 | |
| 152 | * rm -fr ~/.m2/repository/org/onap |
| 153 | * rm -fr ~/.m2/repository/org/openecomp |
| 154 | |
Saryu Shah | f45cebe | 2017-10-13 14:17:11 +0000 | [diff] [blame^] | 155 | |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 156 | **Step 2**. A pom such as the one below can be used to build all the ONAP policy modules and their dependencies. Create the *pom.xml* file in the directory *~/git/onap*. |
| 157 | |
Saryu Shah | f45cebe | 2017-10-13 14:17:11 +0000 | [diff] [blame^] | 158 | .. code-block:: xml |
| 159 | :caption: Typical pom.xml to build the ONAP Policy Framework |
| 160 | :linenos: |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 161 | |
Saryu Shah | f45cebe | 2017-10-13 14:17:11 +0000 | [diff] [blame^] | 162 | <project xmlns="http://maven.apache.org/POM/4.0.0" |
| 163 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 164 | 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] | 165 | |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 166 | <modelVersion>4.0.0</modelVersion> |
| 167 | <groupId>org.onap</groupId> |
| 168 | <artifactId>onap-policy_standalone</artifactId> |
| 169 | <version>1.0.0-SNAPSHOT</version> |
| 170 | <packaging>pom</packaging> |
| 171 | <name>${project.artifactId}</name> |
| 172 | <inceptionYear>2017</inceptionYear> |
| 173 | <organization> |
| 174 | <name>ONAP</name> |
| 175 | </organization> |
| 176 | |
| 177 | <profiles> |
| 178 | <profile> |
| 179 | <id>policy-dependencies</id> |
| 180 | <activation> |
| 181 | <property> |
| 182 | <name>policyDeps</name> |
| 183 | </property> |
| 184 | </activation> |
| 185 | <modules> |
| 186 | <module>oparent</module> |
| 187 | <module>ecompsdkos/ecomp-sdk</module> |
| 188 | </modules> |
| 189 | </profile> |
| 190 | <profile> |
| 191 | <id>policy</id> |
| 192 | <activation> |
| 193 | <activeByDefault>true</activeByDefault> |
| 194 | </activation> |
| 195 | <modules> |
| 196 | <module>oparent</module> |
| 197 | <module>ecompsdkos/ecomp-sdk</module> |
| 198 | <module>policy</module> |
| 199 | </modules> |
| 200 | </profile> |
| 201 | </profiles> |
| 202 | </project> |
| 203 | |
| 204 | |
| 205 | |
| 206 | **Step 3**. 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* |
| 207 | |
Saryu Shah | f45cebe | 2017-10-13 14:17:11 +0000 | [diff] [blame^] | 208 | .. code-block:: xml |
| 209 | :caption: Typical pom.xml to build the ONAP Policy Framework Policy Modules |
| 210 | :linenos: |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 211 | |
Saryu Shah | f45cebe | 2017-10-13 14:17:11 +0000 | [diff] [blame^] | 212 | <project xmlns="http://maven.apache.org/POM/4.0.0" |
| 213 | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 214 | 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] | 215 | |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 216 | <modelVersion>4.0.0</modelVersion> |
| 217 | <groupId>org.onap</groupId> |
| 218 | <artifactId>onap-policy</artifactId> |
| 219 | <version>1.0.0-SNAPSHOT</version> |
| 220 | <packaging>pom</packaging> |
| 221 | <name>${project.artifactId}</name> |
| 222 | <inceptionYear>2017</inceptionYear> |
| 223 | <organization> |
| 224 | <name>ONAP</name> |
| 225 | </organization> |
| 226 | |
| 227 | <modules> |
| 228 | <module>common</module> |
| 229 | <module>engine</module> |
| 230 | <module>pdp</module> |
| 231 | <module>pap</module> |
| 232 | <module>drools-pdp</module> |
| 233 | <module>drools-applications</module> |
| 234 | <module>api</module> |
| 235 | <module>gui</module> |
| 236 | <module>docker</module> |
| 237 | </modules> |
| 238 | </project> |
| 239 | |
Saryu Shah | 3eddd58 | 2017-10-12 22:03:55 +0000 | [diff] [blame] | 240 | **Step 4**. The build cannot currently find the *org.onap.oparent:version-check-maven-plugin* plugin so, for now, comment that plugin out in the POMs *policy/drools-pdp/pom.xml* and *policy/drools-applications/pom.xml*. |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 241 | |
| 242 | **Step 5**. Build the ONAP dependencies that are required for the ONAP policy framework and which must be built first to be available to the ONAP Policy Framework proper. |
| 243 | |
| 244 | * cd ~/git/onap |
| 245 | * mvn clean install -DpolicyDeps |
| 246 | |
| 247 | **Step 6**. You can now build the ONAP framework |
| 248 | |
Saryu Shah | 3eddd58 | 2017-10-12 22:03:55 +0000 | [diff] [blame] | 249 | * On *Ubuntu*, just build the Policy Framework tests and all |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 250 | |
Saryu Shah | 3eddd58 | 2017-10-12 22:03:55 +0000 | [diff] [blame] | 251 | - cd ~/git/onap |
| 252 | - mvn clean install |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 253 | |
Saryu Shah | 3eddd58 | 2017-10-12 22:03:55 +0000 | [diff] [blame] | 254 | * 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. |
| 255 | |
| 256 | - cd ~/git/onap |
| 257 | - mvn clean install -DskipTests |
| 258 | - mvn install |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 259 | |
| 260 | |
| 261 | Building the ONAP Policy Framework Docker Images |
| 262 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 263 | The instructions here are based on the instructions in the file *~/git/onap/policy/docker/README*. |
| 264 | |
| 265 | **Step 1.** Prepare the Docker packages. This will pull the installation zip files needed for building the policy-pe and policy-drools Docker images into the target directory. It will not actually build the docker images; the additional steps below must be followed to actually build the Docker images. |
| 266 | |
| 267 | * cd ~/git/onap/policy/docker |
| 268 | * mvn prepare-package |
| 269 | |
| 270 | **Step 2**. Copy the files under *policy-pe* to *target/policy-pe*. |
| 271 | |
| 272 | * cp policy-pe/* target/policy-pe |
| 273 | |
| 274 | **Step 3**. Copy the files under *policy-drools* to *target/policy-drools*. |
| 275 | |
| 276 | * cp policy-drools/* target/policy-drools |
| 277 | |
Saryu Shah | 3eddd58 | 2017-10-12 22:03:55 +0000 | [diff] [blame] | 278 | **Step 4**. Run the *docker build* command on the following directories in the order below. |
| 279 | Note that on some systems you may have to run the *docker* command as root or using *sudo*. |
Saryu Shah | b6209af | 2017-10-11 20:12:38 +0000 | [diff] [blame] | 280 | |
| 281 | * docker build -t onap/policy/policy-os policy-os |
| 282 | * docker build -t onap/policy/policy-db policy-db |
| 283 | * docker build -t onap/policy/policy-nexus policy-nexus |
| 284 | * docker build -t onap/policy/policy-base policy-base |
| 285 | * docker build -t onap/policy/policy-pe target/policy-pe |
| 286 | * docker build -t onap/policy/policy-drools target/policy-drools |
| 287 | |
| 288 | Starting the ONAP Policy Framework Docker Images |
| 289 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 290 | 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. |
| 291 | |
| 292 | **Step 1.** Make the file *config/drools/drools-tweaks.sh* executable |
| 293 | |
| 294 | * chmod +x config/drools/drools-tweaks.sh |
| 295 | |
| 296 | **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*. |
| 297 | |
| 298 | **Step 3**. Set the environment variable *MTU* to be a suitable MTU size for the application. |
| 299 | |
| 300 | * export MTU=9126 |
| 301 | |
| 302 | **Step 4**. 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. |
| 303 | |
| 304 | * docker-compose up |
| 305 | |
| 306 | |
| 307 | Installation Complete |
| 308 | ^^^^^^^^^^^^^^^^^^^^^ |
| 309 | |
| 310 | **You now have a full standalone ONAP Policy framework up and running!** |
| 311 | |
| 312 | |
Saryu Shah | ba1936f | 2017-10-10 22:20:01 +0000 | [diff] [blame] | 313 | .. _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] | 314 | |
| 315 | |