blob: 0f068ea8f3f50612cbfbae4cfb01f4750e7120b9 [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="\
Saryu Shahb6209af2017-10-11 20:12:38 +000045 policy/api \
46 policy/common \
47 policy/docker \
48 policy/drools-applications \
49 policy/drools-pdp \
50 policy/engine \
51 policy/gui \
52 policy/pap \
53 policy/pdp"
Saryu Shah5c437492018-03-26 21:50:41 +000054
Saryu Shahb6209af2017-10-11 20:12:38 +000055 ##
56 ## Help screen and exit condition (i.e. too few arguments)
57 ##
58 Help()
59 {
60 echo ""
61 echo "$MOD_SCRIPT_NAME - clones all required ONAP git repositories"
62 echo ""
63 echo " Usage: $MOD_SCRIPT_NAME [-options]"
64 echo ""
65 echo " Options"
66 echo " -d - the ONAP clone directory, defaults to '.'"
67 echo " -h - this help screen"
68 echo ""
69 exit 255;
70 }
Saryu Shah5c437492018-03-26 21:50:41 +000071
Saryu Shahb6209af2017-10-11 20:12:38 +000072 ##
73 ## read command line
74 ##
75 while [ $# -gt 0 ]
76 do
77 case $1 in
78 #-d ONAP clone directory
79 -d)
80 shift
81 if [ -z "$1" ]; then
82 echo "$MOD_SCRIPT_NAME: no clone directory"
83 exit 1
84 fi
85 clone_dir=$1
86 shift
87 ;;
Saryu Shah5c437492018-03-26 21:50:41 +000088
Saryu Shahb6209af2017-10-11 20:12:38 +000089 #-h prints help and exists
90 -h)
91 Help;exit 0;;
Saryu Shah5c437492018-03-26 21:50:41 +000092
Saryu Shahb6209af2017-10-11 20:12:38 +000093 *) echo "$MOD_SCRIPT_NAME: undefined CLI option - $1"; exit 255;;
94 esac
95 done
Saryu Shah5c437492018-03-26 21:50:41 +000096
Saryu Shahb6209af2017-10-11 20:12:38 +000097 if [ -f "$clone_dir" ]; then
98 echo "$MOD_SCRIPT_NAME: requested clone directory '$clone_dir' exists as file"
99 exit 2
100 fi
101 if [ -d "$clone_dir" ]; then
102 echo "$MOD_SCRIPT_NAME: requested clone directory '$clone_dir' exists as directory"
103 exit 2
104 fi
Saryu Shah5c437492018-03-26 21:50:41 +0000105
Saryu Shahb6209af2017-10-11 20:12:38 +0000106 mkdir $clone_dir
107 if [ $? != 0 ]
108 then
109 echo cannot clone ONAP repositories, could not create directory '"'$clone_dir'"'
110 exit 3
111 fi
Saryu Shah5c437492018-03-26 21:50:41 +0000112
Saryu Shahb6209af2017-10-11 20:12:38 +0000113 for repo in $onap_repos
114 do
115 repoDir=`dirname "$repo"`
116 repoName=`basename "$repo"`
Saryu Shah5c437492018-03-26 21:50:41 +0000117
Saryu Shahb6209af2017-10-11 20:12:38 +0000118 if [ ! -z $dirName ]
119 then
Saryu Shah5c437492018-03-26 21:50:41 +0000120 mkdir "$clone_dir/$repoDir"
121 if [ $? != 0 ]
122 then
123 echo cannot clone ONAP repositories, could not create directory '"'$clone_dir/repoDir'"'
124 exit 4
125 fi
Saryu Shahb6209af2017-10-11 20:12:38 +0000126 fi
Saryu Shah5c437492018-03-26 21:50:41 +0000127
Saryu Shahb6209af2017-10-11 20:12:38 +0000128 git clone https://gerrit.onap.org/r/${repo} $clone_dir/$repo
129 done
Saryu Shah5c437492018-03-26 21:50:41 +0000130
Saryu Shahb6209af2017-10-11 20:12:38 +0000131 echo ONAP has been cloned into '"'$clone_dir'"'
132
Saryu Shah5c437492018-03-26 21:50:41 +0000133
Saryu Shahb6209af2017-10-11 20:12:38 +0000134Execution of the script above results in the following directory hierarchy in your *~/git* directory:
135
Saryu Shah3eddd582017-10-12 22:03:55 +0000136 * ~/git/onap
Saryu Shah3eddd582017-10-12 22:03:55 +0000137 * ~/git/onap/policy
138 * ~/git/onap/policy/api
139 * ~/git/onap/policy/common
140 * ~/git/onap/policy/docker
141 * ~/git/onap/policy/drools-applications
142 * ~/git/onap/policy/drools-pdp
143 * ~/git/onap/policy/engine
144 * ~/git/onap/policy/gui
145 * ~/git/onap/policy/pap
146 * ~/git/onap/policy/pdp
Saryu Shahb6209af2017-10-11 20:12:38 +0000147
148
Saryu Shahb6209af2017-10-11 20:12:38 +0000149Building ONAP
Saryu Shah5c437492018-03-26 21:50:41 +0000150-------------
Saryu Shahb6209af2017-10-11 20:12:38 +0000151
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000152**Step 1:** Optionally, for a completely clean build, remove the ONAP built modules from your local repository.
Saryu Shahb6209af2017-10-11 20:12:38 +0000153
Saryu Shah5c437492018-03-26 21:50:41 +0000154 .. code-block:: bash
155
156 rm -fr ~/.m2/repository/org/onap
157 rm -fr ~/.m2/repository/org/openecomp
158 rm -fr ~/.m2/repisotory/com/att
Saryu Shahb6209af2017-10-11 20:12:38 +0000159
Saryu Shahf45cebe2017-10-13 14:17:11 +0000160
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000161**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 +0000162
Saryu Shahf45cebe2017-10-13 14:17:11 +0000163.. code-block:: xml
164 :caption: Typical pom.xml to build the ONAP Policy Framework
165 :linenos:
Saryu Shahb6209af2017-10-11 20:12:38 +0000166
Saryu Shah5c437492018-03-26 21:50:41 +0000167 <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 +0000168 <modelVersion>4.0.0</modelVersion>
169 <groupId>org.onap</groupId>
170 <artifactId>onap-policy</artifactId>
171 <version>1.0.0-SNAPSHOT</version>
172 <packaging>pom</packaging>
173 <name>${project.artifactId}</name>
174 <inceptionYear>2017</inceptionYear>
175 <organization>
176 <name>ONAP</name>
177 </organization>
Saryu Shah5c437492018-03-26 21:50:41 +0000178
Saryu Shahb6209af2017-10-11 20:12:38 +0000179 <modules>
180 <module>common</module>
181 <module>engine</module>
182 <module>pdp</module>
183 <module>pap</module>
184 <module>drools-pdp</module>
185 <module>drools-applications</module>
186 <module>api</module>
187 <module>gui</module>
188 <module>docker</module>
189 </modules>
190 </project>
191
Saryu Shahb6209af2017-10-11 20:12:38 +0000192
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000193**Step 3:** You can now build the ONAP framework
Saryu Shahb6209af2017-10-11 20:12:38 +0000194
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000195 .. code-block:: bash
Saryu Shahb6209af2017-10-11 20:12:38 +0000196
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000197 cd ~/git/onap
198 mvn clean install
Saryu Shahb6209af2017-10-11 20:12:38 +0000199
200
201Building the ONAP Policy Framework Docker Images
Saryu Shah5c437492018-03-26 21:50:41 +0000202------------------------------------------------
203The instructions here are based on the instructions in the file *~/git/onap/policy/docker/README.md*.
Saryu Shahb6209af2017-10-11 20:12:38 +0000204
Saryu Shahb6209af2017-10-11 20:12:38 +0000205
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000206**Step 1:** Build the policy engine docker image:
Saryu Shahb6209af2017-10-11 20:12:38 +0000207
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000208 .. code-block:: bash
Saryu Shahb6209af2017-10-11 20:12:38 +0000209
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000210 cd ~/git/onap/policy/engine/packages/docker/target
211 docker build -t onap/policy-pe policy-pe
Saryu Shahb6209af2017-10-11 20:12:38 +0000212
Saryu Shahb6209af2017-10-11 20:12:38 +0000213
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000214**Step 2:** Build the Drools PDP docker image:
Saryu Shahb6209af2017-10-11 20:12:38 +0000215
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000216 .. code-block:: bash
Saryu Shahb6209af2017-10-11 20:12:38 +0000217
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000218 cd ~/git/onap/policy/drools-pdp/packages/docker/target
219 docker build -t onap/policy-drools policy-drools
Saryu Shah5c437492018-03-26 21:50:41 +0000220
Saryu Shahb6209af2017-10-11 20:12:38 +0000221
222Starting the ONAP Policy Framework Docker Images
Saryu Shah5c437492018-03-26 21:50:41 +0000223------------------------------------------------
224
Saryu Shahb6209af2017-10-11 20:12:38 +0000225In 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.
226
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000227**Step 1:** Make the file config/drools/drools-tweaks.sh executable.
Saryu Shahb6209af2017-10-11 20:12:38 +0000228
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000229 .. code-block:: bash
Saryu Shahb6209af2017-10-11 20:12:38 +0000230
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000231 chmod +x config/drools/drools-tweaks.sh
Saryu Shahb6209af2017-10-11 20:12:38 +0000232
Saryu Shahb6209af2017-10-11 20:12:38 +0000233
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000234**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 +0000235
Saryu Shah5c437492018-03-26 21:50:41 +0000236
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000237**Step 3:** Set the environment variable *MTU* to be a suitable MTU size for the application.
Saryu Shah5c437492018-03-26 21:50:41 +0000238
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000239 .. code-block:: bash
Saryu Shah5c437492018-03-26 21:50:41 +0000240
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000241 export MTU=9126
Saryu Shah5c437492018-03-26 21:50:41 +0000242
243
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000244**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 +0000245
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000246 .. code-block:: bash
Saryu Shah5c437492018-03-26 21:50:41 +0000247
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000248 export PRELOAD_POLICIES=false
Saryu Shah5c437492018-03-26 21:50:41 +0000249
250
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000251**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 +0000252
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000253 .. code-block:: bash
Saryu Shah5c437492018-03-26 21:50:41 +0000254
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000255 docker-compose up
Saryu Shahb6209af2017-10-11 20:12:38 +0000256
257
Saryu Shahb6209af2017-10-11 20:12:38 +0000258**You now have a full standalone ONAP Policy framework up and running!**
259
260
Saryu Shahb0c7e3b2018-05-01 01:12:23 +0000261Installation of Controllers and Policies
262----------------------------------------
263
264You may now install a controller and policies on the ONAP Policy Framework. Follow either of the HowTos below to install either the Amsterdam or Beijing controller and policies.
265
266 * `Installation of Amsterdam Controller and vCPE Policy <installAmsterController.html>`_
267 * `Installation of Beijing Controller and Policies <installBeijingController.html>`_
268
269
270
Saryu Shahba1936f2017-10-10 22:20:01 +0000271.. _Standalone Quick Start : https://wiki.onap.org/display/DW/ONAP+Policy+Framework%3A+Standalone+Quick+Start
Pamela Dragosh5ed4e852017-09-22 12:26:16 -0400272
273
Saryu Shah3198d6d2017-11-07 21:40:27 +0000274
275End of Document
276