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