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