Fix dev setup guide to include images
[aai/aai-common.git] / docs / platform / Getting Started / AAI_Developer_Environment_Setup.rst
1
2 .. contents::
3    :depth: 3
4 .. _dev-setup:
5
6
7 AAI Developer Environment Setup
8 ================================
9
10 This guide will illustrate setting up an A&AI development environment in
11 Ubuntu 16.04.  
12
13 For this exercise, I set up a new instance of Ubuntu in Virtualbox and
14 gave it 16G RAM, 200GB dynamically allocated storage, and 3 processors.
15
16 - install openjdk 8
17
18    ..code:: bash
19
20        sudo apt install openjdk-8-jdk
21
22 - Install single node hadoop/titan
23
24    ..code:: bash
25
26      wget http://s3.thinkaurelius.com/downloads/titan/titan-1.0.0-hadoop1.zip
27
28      unzip titan-1.0.0-hadoop1.zip
29
30      cd titan-1.0.0-hadoop1
31      
32      sudo ./bin/titan.sh start
33
34 - Install haproxy
35
36    ..code:: bash
37
38      sudo apt-get -y install haproxy
39
40      haproxy -v
41        HA-Proxy version 1.6.3 2015/12/25
42        Copyright 2000-2015 Willy Tarreau
43         willy@haproxy.org http://haproxy.org/
44
45 - Install this haproxy.cfg file in /etc/haproxy
46
47     `haproxy.cfg <https://wiki.onap.org/download/attachments/10782088/haproxy.cfg?version=2&modificationDate=1501018863000&api=v2>`__
48
49   ..code:: bash
50
51     sudo cp aai.pem /etc/ssl/private/aai.pem
52
53     sudo chmod 640 /etc/ssl/private/aai.pem
54
55     sudo chown root:ssl-cert /etc/ssl/private/aai.pem
56
57   `aai.pem <https://wiki.onap.org/download/attachments/10782088/aai.pem?version=1&modificationDate=1501019585000&api=v2>`__
58
59   ..code::bash
60
61     sudo mkdir /usr/local/etc/haproxy
62
63 - Add these hostnames to the loopback interface in /etc/hosts: 
64
65    ..code:: bash
66
67      127.0.0.1 localhost aai-traversal.api.simpledemo.openecomp.org aai-resouces.api.simpledemo.openecomp.org
68
69 - Restart haproxy
70
71    ..code:: bash
72
73      sudo service haproxy restart
74
75 - Set up repos. First, follow the initial setup instructions in 
76   `Setting Up Your Development Environment <https://wiki.onap.org/display/DW/Setting+Up+Your+Development+Environment>`__
77
78   ..code:: bash
79
80     mkdir -p ~/LF/AAI
81
82     cd ~/LF/AAI
83
84     git clone ssh://<username>@gerrit.onap.org:29418/aai/aai-common
85
86     git clone ssh://<username>@gerrit.onap.org:29418/aai/traversal
87
88     git clone ssh://<username>@gerrit.onap.org:29418/aai/resources
89
90     git clone ssh://<username>@gerrit.onap.org:29418/aai/logging-service
91
92 - If you did not originally create a settings.xml file when setting
93   up the dev environment, you may get an error on some of the repos
94   saying that oparent is unresolvable.  Using the example
95   settings.xml file should solve this problem:
96   `Setting Up Your Development Environment#MavenExamplesettings.xml <https://wiki.onap.org/display/DW/Setting+Up+Your+Development+Environment#SettingUpYourDevelopmentEnvironment-MavenExamplesettings.xml>`__
97
98 - Build aai-common, traversal, and resources
99
100    ..code:: bash
101      
102      cd ~/LF/AAI/aai-common
103
104      mvn clean install # Should result in BUILD SUCCESS
105
106      cd ~/LF/AAI/resources
107
108      mvn clean install # Should result in BUILD SUCCESS
109
110      cd ~/LF/AAI/logging-service
111
112      mvn clean install # Should result in BUILD SUCCESS
113
114      cd ~/LF/AAI/traversal # I had to add the following to traversal/pom.xml to get
115          traversal to build: 
116
117        ..code:: xml
118         <repositories><repository><id>maven-restlet</id><name>Restlet repository</name><url>https://maven.restlet.com</url></repository></repositories>
119
120      mvn clean install # Should result in BUILD SUCCESS
121
122 - Titan setup
123
124    1. Modify both titan-cached.properties and
125         titan-realtime.properties to the following (for all MS’s that
126         will connect to the local Cassandra backend)
127       
128         ..code:: bash
129
130           storage.backend=\ *cassandra*
131           storage.hostname=\ *localhost*
132
133    2. update
134       ~/LF/AAI/resources/aai-resources/bundleconfig-local/etc/appprops/titan-cached.properties
135
136    3. update
137       ~/LF/AAI/resources/aai-resources/bundleconfig-local/etc/appprops/titan-realtime.properties
138
139    4. update
140       ~/LF/AAI/traversal/aai-traversal/bundleconfig-local/etc/appprops/titan-cached.properties
141
142    5. update
143       ~/LF/AAI/traversal/aai-traversal/bundleconfig-local/etc/appprops/titan-realtime.properties
144
145    6. The following property can be added to specify the keyspace
146         name, each time you do this step (g) should be done. If not
147         specified Titan will try to create/use a defaulted keyspace
148         named titan.
149
150         ..code:: bash
151
152           storage.cassandra.keyspace=<keyspace name>
153
154    7. From the resources MS run the create db schema standalone program.
155
156    8. ***NOTE***: The first thing that would need to be done is adding
157       the schema to the local instance. (this will need to be done
158       whenever using a new keyspace or after wiping the data).
159
160     Runnable class org.onap.aai.dbgen.GenTester with the following vm
161     args.
162
163     ..code:: bash
164
165       -DAJSC_HOME=~/LF/AAI/resources -DBUNDLECONFIG\_DIR="bundleconfig-local"
166
167    9. Here's the command I used, and it worked:
168
169       ..code:: bash
170
171         cd ~/LF/AAI; java -DAJSC_HOME=/home/jimmy/LF/AAI/resources/aai-resources
172         -DBUNDLECONFIG_DIR="bundleconfig-local" -cp
173         aai-common/aai-core/target/aai-core-1.1.0-SNAPSHOT.jar:resources/aai-resources/target/aai-resources.jar:resources/aai-resources/target/userjars/\*
174         org.onap.aai.dbgen.GenTester
175
176 - Start the "resources" microservice
177
178    1. Resources runs on port 8446.  Go to the resources directory
179    
180       ..code:: bash
181         cd ~/LF/AAI/resources
182
183    2. Set the debug port to 9446
184
185       ..code:: bash
186       
187         export MAVEN_OPTS="-Xms1024m -Xmx5120m -XX:PermSize=2024m
188           -Xdebug -Xnoagent -Djava.compiler=NONE
189           -Xrunjdwp:transport=dt_socket,address=9446,server=y,suspend=n"
190
191    3. Start the microservice
192
193       ..code::bash
194
195         mvn -P runAjsc
196
197 16. Verify the resources microservice (this example uses Postman utility
198    for Google Chrome)
199
200    1. | Use basic auth, user = AAI, pw = AAI
201
202    2. | Set the X-TransactionId header (in the example below, the value is
203       | 9999)
204
205    3. | Set the X-FromAppId header (in the example below, the value is
206       | jimmy-postman)
207
208    4. | Perform a GET of https://127.0.0.1:8443/aai/v11/network/vces
209
210    5. | You should see an error as below, 404 Not Found, ERR.5.4.6114. 
211       | This indicates that the service is functioning normally:
212
213 +------------------------------------------+
214 | |image1|   |
215 +------------------------------------------+
216
217
218 18. Start the "traversal" microservice
219
220    1. | Traversal runs on port 8447.  Go to the traversal directory
221       ..code:: bash
222       $ cd ~/LF/AAI/traversal
223
224    2. | Set the debug port to 9447
225       | $ export MAVEN_OPTS="-Xms1024m -Xmx5120m -XX:PermSize=2024m
226         -Xdebug -Xnoagent -Djava.compiler=NONE
227         -Xrunjdwp:transport=dt_socket,address=9447,server=y,suspend=n"
228
229    3. | Start the microservice
230       | $ mvn -P runAjsc
231       | Should see something like this: 2017-07-26
232         12:46:35.524:INFO:oejs.Server:com.att.ajsc.runner.Runner.main():
233         Started @25827ms
234
235 - Verify the traversal microservice
236
237    1. | Set up the widget models
238       | This will set up the postman to add widget models: `Add Widget Models.postman_collection.json <https://wiki.onap.org/download/attachments/10782088/Add%20Widget%20Models.postman_collection.json?version=2&modificationDate=1501102559000&api=v2>`__ `NamedQuery.postman_collection.json <https://wiki.onap.org/download/attachments/10782088/NamedQuery.postman_collection.json?version=2&modificationDate=1501102582000&api=v2>`__
239
240    2. | Create a runner using this file:
241        `models.csv <https://wiki.onap.org/download/attachments/10782088/models.csv?version=1&modificationDate=1501100140000&api=v2>`__
242
243    3. | Run the test runner
244       | |image2|
245
246    4. | Add a named query called "getComponentList" (this named query is used by VID): 
247       `NamedQuery.postman_collection.json <ificationDate=1501102582000&api=v2>`__
248       | |image3|
249
250    5. | Add objects:
251         `Add Instances for Named Query.postman_collection.json <https://wiki.onap.org/download/attachments/10782088/Add%20Instances%20for%20Named%20Query.postman_collection.json?version=1&modificationDate=1501102617000&api=v2>`__ 
252
253    6. | Execute named-query:
254       `Execute Named Query.postman_collection.json <https://wiki.onap.org/download/attachments/10782088/Execute%20Named%20Query.postman_collection.json?version=1&modificationDate=1501102658000&api=v2>`__
255       | You should see something like the following:
256       | |image4|
257
258 - Your A&AI instance is now running, both the resources and traversal
259    microservices are working properly with a local titan graph.
260
261 - Next: `Tutorial: Making and Testing a Schema Change in A&AI <https://wiki.onap.org/pages/viewpage.action?pageId=10783023>`__
262
263 .. |image1| image:: media/image1.png
264    :width: 4.87500in
265    :height: 2.87500in
266 .. |image2| image:: media/image2.png
267    :width: 4.87500in
268    :height: 3.75000in
269 .. |image3| image:: media/image3.png
270    :width: 4.87500in
271    :height: 4.15000in
272 .. |image4| image:: media/image4.png
273    :width: 4.87500in
274    :height: 4.15000in