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