blob: 987c69511d6e05ee0e17f9990050953976a8f099 [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 Shahb0c7e3b2018-05-01 01:12:23 +00004Standalone Quick Start Installation
5^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Saryu Shahba1936f2017-10-10 22:20:01 +00006
Saryu Shahb6209af2017-10-11 20:12:38 +00007.. contents::
Saryu Shahb0c7e3b2018-05-01 01:12:23 +00008 :depth: 2
Saryu Shahba1936f2017-10-10 22:20:01 +00009
Saryu Shahb6209af2017-10-11 20:12:38 +000010The 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 +000011Various tools, including healthcheck, logs, and Swagger can be used to ensure proper operation.
12
Saryu Shah5c437492018-03-26 21:50:41 +000013This article explains how to build the ONAP Policy Framework and get it running in Docker as a standalone system.
14This article assumes that:
Saryu Shahb6209af2017-10-11 20:12:38 +000015
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*
Saryu Shah5c437492018-03-26 21:50:41 +000019* 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 +000020
Saryu Shah5c437492018-03-26 21:50:41 +000021The 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.
22
23Cloning the ONAP repositories
24-----------------------------
25
26Run 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.
27
28ONAP 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 +000029
30
Saryu Shahf45cebe2017-10-13 14:17:11 +000031.. code-block:: bash
32 :caption: Typical ONAP Policy Framework Clone Script
33 :linenos:
Saryu Shahb6209af2017-10-11 20:12:38 +000034
35 #!/usr/bin/env bash
Saryu Shah5c437492018-03-26 21:50:41 +000036
Saryu Shahb6209af2017-10-11 20:12:38 +000037 ## script name for output
38 MOD_SCRIPT_NAME=`basename $0`
Saryu Shah5c437492018-03-26 21:50:41 +000039
Saryu Shahb6209af2017-10-11 20:12:38 +000040 ## the ONAP clone directory, defaults to "onap"
41 clone_dir="onap"
Saryu Shah5c437492018-03-26 21:50:41 +000042
Saryu Shahb6209af2017-10-11 20:12:38 +000043 ## the ONAP repos to clone
44 onap_repos="\
Pamela Dragoshcf6e8fd2018-10-30 14:10:40 -040045 policy/parent \
Saryu Shahb6209af2017-10-11 20:12:38 +000046 policy/common \
47 policy/docker \
48 policy/drools-applications \
49 policy/drools-pdp \
50 policy/engine \
Pamela Dragoshcf6e8fd2018-10-30 14:10:40 -040051 policy/apex-pdp \
52 policy/distribution"
Saryu Shah5c437492018-03-26 21:50:41 +000053
Saryu Shahb6209af2017-10-11 20:12:38 +000054 ##
55 ## Help screen and exit condition (i.e. too few arguments)
56 ##
57 Help()
58 {
59 echo ""
60 echo "$MOD_SCRIPT_NAME - clones all required ONAP git repositories"
61 echo ""
62 echo " Usage: $MOD_SCRIPT_NAME [-options]"
63 echo ""
64 echo " Options"
65 echo " -d - the ONAP clone directory, defaults to '.'"
66 echo " -h - this help screen"
67 echo ""
68 exit 255;
69 }
Saryu Shah5c437492018-03-26 21:50:41 +000070
Saryu Shahb6209af2017-10-11 20:12:38 +000071 ##
72 ## read command line
73 ##
74 while [ $# -gt 0 ]
75 do
76 case $1 in
77 #-d ONAP clone directory
78 -d)
79 shift
80 if [ -z "$1" ]; then
81 echo "$MOD_SCRIPT_NAME: no clone directory"
82 exit 1
83 fi
84 clone_dir=$1
85 shift
86 ;;
Saryu Shah5c437492018-03-26 21:50:41 +000087
Saryu Shahb6209af2017-10-11 20:12:38 +000088 #-h prints help and exists
89 -h)
90 Help;exit 0;;
Saryu Shah5c437492018-03-26 21:50:41 +000091
Saryu Shahb6209af2017-10-11 20:12:38 +000092 *) echo "$MOD_SCRIPT_NAME: undefined CLI option - $1"; exit 255;;
93 esac
94 done
Saryu Shah5c437492018-03-26 21:50:41 +000095
Saryu Shahb6209af2017-10-11 20:12:38 +000096 if [ -f "$clone_dir" ]; then
97 echo "$MOD_SCRIPT_NAME: requested clone directory '$clone_dir' exists as file"
98 exit 2
99 fi
100 if [ -d "$clone_dir" ]; then
101 echo "$MOD_SCRIPT_NAME: requested clone directory '$clone_dir' exists as directory"
102 exit 2
103 fi
Saryu Shah5c437492018-03-26 21:50:41 +0000104
Saryu Shahb6209af2017-10-11 20:12:38 +0000105 mkdir $clone_dir
106 if [ $? != 0 ]
107 then
108 echo cannot clone ONAP repositories, could not create directory '"'$clone_dir'"'
109 exit 3
110 fi
Saryu Shah5c437492018-03-26 21:50:41 +0000111
Saryu Shahb6209af2017-10-11 20:12:38 +0000112 for repo in $onap_repos
113 do
114 repoDir=`dirname "$repo"`
115 repoName=`basename "$repo"`
Saryu Shah5c437492018-03-26 21:50:41 +0000116
Saryu Shahb6209af2017-10-11 20:12:38 +0000117 if [ ! -z $dirName ]
118 then
Saryu Shah5c437492018-03-26 21:50:41 +0000119 mkdir "$clone_dir/$repoDir"
120 if [ $? != 0 ]
121 then
122 echo cannot clone ONAP repositories, could not create directory '"'$clone_dir/repoDir'"'
123 exit 4
124 fi
Saryu Shahb6209af2017-10-11 20:12:38 +0000125 fi
Saryu Shah5c437492018-03-26 21:50:41 +0000126
Saryu Shahb6209af2017-10-11 20:12:38 +0000127 git clone https://gerrit.onap.org/r/${repo} $clone_dir/$repo
128 done
Saryu Shah5c437492018-03-26 21:50:41 +0000129
Saryu Shahb6209af2017-10-11 20:12:38 +0000130 echo ONAP has been cloned into '"'$clone_dir'"'
131
Saryu Shah5c437492018-03-26 21:50:41 +0000132
Saryu Shahb6209af2017-10-11 20:12:38 +0000133Execution of the script above results in the following directory hierarchy in your *~/git* directory:
134
Saryu Shah3eddd582017-10-12 22:03:55 +0000135 * ~/git/onap
Saryu Shah3eddd582017-10-12 22:03:55 +0000136 * ~/git/onap/policy
Pamela Dragoshcf6e8fd2018-10-30 14:10:40 -0400137 * ~/git/onap/policy/parent
Saryu Shah3eddd582017-10-12 22:03:55 +0000138 * ~/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
Pamela Dragoshcf6e8fd2018-10-30 14:10:40 -0400143 * ~/git/onap/policy/apex-pdp
144 * ~/git/onap/policy/distribution
Saryu Shahb6209af2017-10-11 20:12:38 +0000145
146
Saryu Shahb6209af2017-10-11 20:12:38 +0000147Building ONAP
Saryu Shah5c437492018-03-26 21:50:41 +0000148-------------
Saryu Shahb6209af2017-10-11 20:12:38 +0000149
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000150**Step 1:** Optionally, for a completely clean build, remove the ONAP built modules from your local repository.
Saryu Shahb6209af2017-10-11 20:12:38 +0000151
Saryu Shah5c437492018-03-26 21:50:41 +0000152 .. code-block:: bash
153
154 rm -fr ~/.m2/repository/org/onap
155 rm -fr ~/.m2/repository/org/openecomp
156 rm -fr ~/.m2/repisotory/com/att
Saryu Shahb6209af2017-10-11 20:12:38 +0000157
Saryu Shahf45cebe2017-10-13 14:17:11 +0000158
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000159**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 +0000160
Saryu Shahf45cebe2017-10-13 14:17:11 +0000161.. code-block:: xml
162 :caption: Typical pom.xml to build the ONAP Policy Framework
163 :linenos:
Saryu Shahb6209af2017-10-11 20:12:38 +0000164
Saryu Shah5c437492018-03-26 21:50:41 +0000165 <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 +0000166 <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>
173 <organization>
174 <name>ONAP</name>
175 </organization>
Saryu Shah5c437492018-03-26 21:50:41 +0000176
Saryu Shahb6209af2017-10-11 20:12:38 +0000177 <modules>
Pamela Dragoshcf6e8fd2018-10-30 14:10:40 -0400178 <module>parent</module>
Saryu Shahb6209af2017-10-11 20:12:38 +0000179 <module>common</module>
Saryu Shahb6209af2017-10-11 20:12:38 +0000180 <module>drools-pdp</module>
181 <module>drools-applications</module>
Pamela Dragoshcf6e8fd2018-10-30 14:10:40 -0400182 <module>engine</module>
183 <module>apex-pdp</module>
184 <module>distribution</module>
Saryu Shahb6209af2017-10-11 20:12:38 +0000185 </modules>
186 </project>
187
Saryu Shahb6209af2017-10-11 20:12:38 +0000188
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000189**Step 3:** You can now build the ONAP framework
Saryu Shahb6209af2017-10-11 20:12:38 +0000190
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000191 .. code-block:: bash
Saryu Shahb6209af2017-10-11 20:12:38 +0000192
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000193 cd ~/git/onap
194 mvn clean install
Saryu Shahb6209af2017-10-11 20:12:38 +0000195
196
197Building the ONAP Policy Framework Docker Images
Saryu Shah5c437492018-03-26 21:50:41 +0000198------------------------------------------------
199The instructions here are based on the instructions in the file *~/git/onap/policy/docker/README.md*.
Saryu Shahb6209af2017-10-11 20:12:38 +0000200
Saryu Shahb6209af2017-10-11 20:12:38 +0000201
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000202**Step 1:** Build the policy engine docker image:
Saryu Shahb6209af2017-10-11 20:12:38 +0000203
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000204 .. code-block:: bash
Saryu Shahb6209af2017-10-11 20:12:38 +0000205
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000206 cd ~/git/onap/policy/engine/packages/docker/target
207 docker build -t onap/policy-pe policy-pe
Saryu Shahb6209af2017-10-11 20:12:38 +0000208
Saryu Shahb6209af2017-10-11 20:12:38 +0000209
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000210**Step 2:** Build the Drools PDP docker image:
Saryu Shahb6209af2017-10-11 20:12:38 +0000211
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000212 .. code-block:: bash
Saryu Shahb6209af2017-10-11 20:12:38 +0000213
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000214 cd ~/git/onap/policy/drools-pdp/packages/docker/target
215 docker build -t onap/policy-drools policy-drools
Saryu Shah5c437492018-03-26 21:50:41 +0000216
Saryu Shahb6209af2017-10-11 20:12:38 +0000217
Pamela Dragoshcf6e8fd2018-10-30 14:10:40 -0400218**Step 3:** Build the Policy SDC Distribution docker image:
219
220 .. code-block:: bash
221
222 cd ~/git/onap/policy/distribution/packages
223 mvn clean install -Pdocker
224
225**Step 4:** Build the Apex PDP docker image:
226
227 .. code-block:: bash
228
229 cd ~/git/onap/policy/apex-pdp/packages/apex-pdp-docker/target
230 docker build -t onap/policy-apex-pdp policy-apex-pdp
231
232
Saryu Shahb6209af2017-10-11 20:12:38 +0000233Starting the ONAP Policy Framework Docker Images
Saryu Shah5c437492018-03-26 21:50:41 +0000234------------------------------------------------
235
Pamela Dragoshcf6e8fd2018-10-30 14:10:40 -0400236In 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.
Saryu Shahb6209af2017-10-11 20:12:38 +0000237
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000238**Step 1:** Make the file config/drools/drools-tweaks.sh executable.
Saryu Shahb6209af2017-10-11 20:12:38 +0000239
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000240 .. code-block:: bash
Saryu Shahb6209af2017-10-11 20:12:38 +0000241
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000242 chmod +x config/drools/drools-tweaks.sh
Saryu Shahb6209af2017-10-11 20:12:38 +0000243
Saryu Shahb6209af2017-10-11 20:12:38 +0000244
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000245**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 +0000246
Saryu Shah5c437492018-03-26 21:50:41 +0000247
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000248**Step 3:** Set the environment variable *MTU* to be a suitable MTU size for the application.
Saryu Shah5c437492018-03-26 21:50:41 +0000249
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000250 .. code-block:: bash
Saryu Shah5c437492018-03-26 21:50:41 +0000251
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000252 export MTU=9126
Saryu Shah5c437492018-03-26 21:50:41 +0000253
254
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000255**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:
Saryu Shah5c437492018-03-26 21:50:41 +0000256
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000257 .. code-block:: bash
Saryu Shah5c437492018-03-26 21:50:41 +0000258
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000259 export PRELOAD_POLICIES=false
Saryu Shah5c437492018-03-26 21:50:41 +0000260
261
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000262**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.
Saryu Shah5c437492018-03-26 21:50:41 +0000263
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000264 .. code-block:: bash
Saryu Shah5c437492018-03-26 21:50:41 +0000265
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000266 docker-compose up
Saryu Shahb6209af2017-10-11 20:12:38 +0000267
268
Saryu Shahb6209af2017-10-11 20:12:38 +0000269**You now have a full standalone ONAP Policy framework up and running!**
270
271
Pamela Dragoshcf6e8fd2018-10-30 14:10:40 -0400272Installation of Drools Controllers and Policies
273-----------------------------------------------
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000274
Pamela Dragoshcf6e8fd2018-10-30 14:10:40 -0400275You may now install a controller and policies on the ONAP Policy Framework. Follow the HowTos below to install the Amsterdam controller and policies.
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000276
277 * `Installation of Amsterdam Controller and vCPE Policy <installAmsterController.html>`_
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000278
279
280
Saryu Shahba1936f2017-10-10 22:20:01 +0000281.. _Standalone Quick Start : https://wiki.onap.org/display/DW/ONAP+Policy+Framework%3A+Standalone+Quick+Start
Pamela Dragosh5ed4e852017-09-22 12:26:16 -0400282
283
Saryu Shah3198d6d2017-11-07 21:40:27 +0000284
285End of Document
286