4122a9e0aa44b761436df7f1451167b098e30a3d
[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 For this exercise, I set up a new instance of Ubuntu in Virtualbox and gave it 16G RAM, 200GB dynamically allocated storage, and 3 processors.
11
12 1. Install openjdk 8
13 --------------------
14  .. code-block:: bash
15
16    1. $ sudo apt install openjdk-8-jdk
17
18 2. Install single node hadoop/janusgraph
19 ----------------------------------------
20  .. code-block:: bash
21
22    1. $ wget http://github.com/JanusGraph/janusgraph/releases/download/v0.2.0/janusgraph-0.2.0-hadoop2.zip
23    2. $ unzip janusgraph-0.2.0-hadoop2.zip
24    3. $ cd janusgraph-0.2.0-hadoop2/
25    4. $ ./bin/janusgraph.sh start
26
27  Ensure you are not a root user as elasticsearch cannot be run as root.
28  Response looks like:
29
30  .. code-block:: bash
31
32    Forking Cassandra...
33    Running `nodetool statusthrift`... OK (returned exit status 0 and printed string "running").
34    Forking Elasticsearch...
35    Connecting to Elasticsearch (127.0.0.1:9200)...... OK (connected to 127.0.0.1:9200).
36    Forking Gremlin-Server...
37    Connecting to Gremlin-Server (127.0.0.1:8182).... OK (connected to 127.0.0.1:8182).
38    Run gremlin.sh to connect.
39
40  You can verify whether everything is running by executing
41
42  .. code-block:: bash
43
44    ./bin/janusgraph.sh status
45
46  And the output looks like:
47
48  .. code-block:: bash
49
50    Gremlin-Server (org.apache.tinkerpop.gremlin.server.GremlinServer) is running with pid 9835
51    Elasticsearch (org.elasticsearch.bootstrap.Elasticsearch) is running with pid 9567
52    Cassandra (org.apache.cassandra.service.CassandraDaemon) is running with pid 9207
53
54 3. Install haproxy
55 ------------------
56
57  .. code-block:: bash
58
59     1. $ sudo apt-get -y install haproxy
60     2. $ <path-to-haproxy>/haproxy -v
61
62  Response should be:
63
64  .. code-block:: bash
65
66    HA-Proxy version 1.6.3 2015/12/25
67    Copyright 2000-2015 Willy Tarreau <willy@haproxy.org>
68
69  Install the attached :download:`haproxy.cfg <media/haproxy.cfg>` in /etc/haproxy
70
71  .. code-block:: bash
72
73    $ sudo cp haproxy.cfg /etc/haproxy
74    $ sudo mkdir /usr/local/etc/haproxy
75
76  Install the attached :download:`aai.pem <media/aai.pem>` file in /etc/ssl/private
77
78  .. code-block:: bash
79
80    $ sudo cp aai.pem /etc/ssl/private/aai.pem
81    $ sudo chmod 640 /etc/ssl/private/aai.pem
82    $ sudo chown root:ssl-cert /etc/ssl/private/aai.pem
83
84  Add these hostnames to the loopback interface in /etc/hosts:
85
86  127.0.0.1 localhost aai-traversal.api.simpledemo.openecomp.org aai-resources.api.simpledemo.openecomp.org aai-traversal.api.simpledemo.onap.org aai-resources.api.simpledemo.onap.org
87
88  .. code-block:: bash
89
90    $ sudo service haproxy restart
91
92 4. Follow the initial setup instructions in `Setting Up Your Development Environment <https://wiki.onap.org/display/DW/Setting+Up+Your+Development+Environment>`__ e.g.
93 -----------------------------------------------------------------------------------------------------------------------------------------------------------------------
94  .. code-block:: bash
95
96    $ sudo apt-get install git
97    $ sudo apt-get install npm
98    $ sudo apt-get install maven
99    $ sudo apt-get install docker.io
100    $ wget https://git.onap.org/oparent/plain/settings.xml
101    $ mkdir ~/.m2
102    $ cp settings.xml ~/.m2
103
104 5. Set Up Repos
105 ---------------
106
107  .. code-block:: bash
108
109    $ mkdir -p ~/src/aai
110    $ cd ~/src/aai ; for f in aai-common schema-service resources traversal graphadmin logging-service ; do git clone ssh://<username>@gerrit.onap.org:29418/aai/$f; done
111
112 6. Checkout the 'dublin' branch
113 -------------------------------
114
115  .. code-block:: bash
116
117     $ cd ~/src/aai ; for f in aai-common schema-service resources traversal graphadmin logging-service ; do (cd $f ; git checkout dublin) done | tee checkoutlog.txt
118
119 7. Janus Setup (part 1)
120 -----------------------
121
122  Modify both janus-cached.properties and janus-realtime.properties to the following (for all MS’s that will connect to the local Cassandra backend)
123
124  .. code::
125
126    storage.backend=cassandra
127    storage.hostname=localhost
128    storage.cassandra.keyspace=onap # or different keyspace name of your choosing
129
130  Edit the following files:
131
132  .. code::
133
134    ~/src/aai/resources/aai-resources/src/main/resources/etc/appprops/janusgraph-cached.properties
135    ~/src/aai/resources/aai-resources/src/main/resources/etc/appprops/janusgraph-realtime.properties
136    ~/src/aai/traversal/aai-traversal/src/main/resources/etc/appprops/janusgraph-cached.properties
137    ~/src/aai/traversal/aai-traversal/src/main/resources/etc/appprops/janusgraph-realtime.properties
138    ~/src/aai/graphadmin/src/main/resources/etc/appprops/janusgraph-cached.properties
139    ~/src/aai/graphadmin/src/main/resources/etc/appprops/janusgraph-realtime.properties
140
141 8. Build all the modules
142 ------------------------
143
144  .. code-block:: bash
145
146    $ cd ~/src/aai ; for f in aai-common schema-service resources traversal graphadmin logging-service ; do (cd $f ; mvn versions:set -DnewVersion=0.0.1-TEST-SNAPSHOT && mvn -DskipTests clean install -Daai.schema.version=0.0.1-TEST-SNAPSHOT) done | tee log.txt 2>&1
147
148    $ grep -e "SUCCESS" -e "FAILURE" log.txt
149
150  And you should see:
151
152  .. code::
153
154    [INFO] aai-schema ......................................... SUCCESS [ 32.504 s]
155    [INFO] aai-queries ........................................ SUCCESS [ 6.461 s]
156    [INFO] aai-schema-service ................................. SUCCESS [02:17 min]
157    [INFO] BUILD SUCCESS
158    [INFO] aai-resources ...................................... SUCCESS [ 1.190 s]
159    [INFO] BUILD SUCCESS
160    [INFO] aai-resources ...................................... SUCCESS [ 3.210 s]
161    [INFO] aai-resources ...................................... SUCCESS [ 41.213 s]
162    [INFO] BUILD SUCCESS
163    [INFO] aai-traversal ...................................... SUCCESS [ 1.090 s]
164    [INFO] BUILD SUCCESS
165    [INFO] aai-traversal ...................................... SUCCESS [ 3.181 s]
166    [INFO] aai-traversal ...................................... SUCCESS [ 58.001 s]
167    [INFO] BUILD SUCCESS
168    [INFO] BUILD SUCCESS
169    [INFO] BUILD SUCCESS
170    [INFO] aai-logging-service ................................ SUCCESS [ 1.101 s]
171    [INFO] BUILD SUCCESS
172    [INFO] aai-logging-service ................................ SUCCESS [ 5.230 s]
173    [INFO] Common Logging API ................................. SUCCESS [ 1.995 s]
174    [INFO] EELF Logging Implementation ........................ SUCCESS [ 4.235 s]
175    [INFO] Common Logging Distribution ........................ SUCCESS [ 0.530 s]
176    [INFO] BUILD SUCCESS
177
178 9. Janus setup (part 2)
179 -----------------------
180
181  Run this on the local instance on your first time running AAI and whenever using new keyspace or after wiping the data.
182
183  Install the schema
184
185  .. code-block:: bash
186
187     $ (cd ~/src/aai/graphadmin/ && mvn -PrunAjsc -Dstart-class=org.onap.aai.schema.GenTester -Daai.schema.version=0.0.1-TEST-SNAPSHOT -Daai.schema.ingest.version=0.0.1-TEST-SNAPSHOT -DskipTests -Dcheckstyle.skip=true -DAJSC_HOME=$HOME/src/aai/graphadmin -DBUNDLECONFIG_DIR=src/main/resources)
188
189  You should see:
190
191  .. code::
192
193    ---- NOTE --- about to open graph (takes a little while)--------;
194    -- Loading new schema elements into JanusGraph --
195    -- graph commit
196    -- graph shutdown
197
198 10. Start the "resources" microservice
199 --------------------------------------
200
201  Resources runs on port 8447.  Go to the resources directory
202
203  .. code-block:: bash
204
205     $ cd ~/src/aai/resources
206
207  Set the debug port to 9447
208
209   .. code-block:: bash
210
211      $ export MAVEN_OPTS="-Xms1024m -Xmx5120m -XX:PermSize=2024m -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=9447,server=y,suspend=n"
212
213  Start the microservice - adjust your build version accordingly
214
215  .. code-block:: bash
216
217      $ mvn -pl aai-resources -PrunAjsc -Daai.schema.version=0.0.1-TEST-SNAPSHOT -Daai.schema.ingest.version=0.0.1-TEST-SNAPSHOT -DskipTests -Dcheckstyle.skip=true
218
219  Should see something like this: Resources Microservice Started
220
221
222 11. Verify the resources microservice
223 -------------------------------------
224
225  This example uses curl from commandline
226
227  .. code-block:: bash
228
229     $ sudo apt-get install jq  # for pretty output
230
231  Download :download:`script - test-complex <media/test-complex>`
232  Download :download:`data - data-complex.json <media/data-complex.json>`
233
234  .. code-block:: bash
235
236    $ sh ./test-complex 2>&1 | tee log.txt
237
238  Confirm log.txt contains:
239
240  .. code-block:: bash
241
242     > GET /aai/v16/cloud-infrastructure/complexes HTTP/1.1
243
244  .. code-block:: json
245
246     {
247      "requestError": {
248        "serviceException": {
249          "messageId": "SVC3001",
250          "text": "Resource not found for %1 using id %2 (msg=%3) (ec=%4)",
251          "variables": [
252            "GET",
253            "cloud-infrastructure/complexes",
254            "Node Not Found:No Node of type complex found at: cloud-infrastructure/complexes",
255            "ERR.5.4.6114"
256          ]
257        }
258      }
259     }
260
261  Then followed by:
262
263  .. code-block:: bash
264
265     > PUT /aai/v16/cloud-infrastructure/complexes/complex/clli2 HTTP/1.1
266     > GET /aai/v16/cloud-infrastructure/complexes/complex/clli2 HTTP/1.1
267
268  With payload:
269
270  .. code-block:: json
271
272    {
273      "physical-location-id": "clli2",
274      "data-center-code": "example-data-center-code-val-6667",
275      "complex-name": "clli2",
276      "identity-url": "example-identity-url-val-28399",
277      "resource-version": "1543408364646",
278      "physical-location-type": "example-physical-location-type-val-28399",
279      "street1": "example-street1-val-28399",
280      "street2": "example-street2-val-28399",
281      "city": "example-city-val-28399",
282      "state": "example-state-val-28399",
283      "postal-code": "example-postal-code-val-28399",
284      "country": "example-country-val-28399",
285      "region": "example-region-val-28399",
286      "latitude": "1111",
287      "longitude": "2222",
288      "elevation": "example-elevation-val-28399",
289      "lata": "example-lata-val-28399"
290    }
291
292  And finishes with:
293
294  .. code-block:: bash
295
296     > DELETE /aai/v16/cloud-infrastructure/complexes/complex/clli2?resource-version=1543408364646 HTTP/1.1
297     > GET /aai/v16/cloud-infrastructure/complexes HTTP/1.1
298
299  With the following:
300
301  .. code-block:: json
302
303      {
304      "requestError": {
305        "serviceException": {
306          "messageId": "SVC3001",
307          "text": "Resource not found for %1 using id %2 (msg=%3) (ec=%4)",
308          "variables": [
309            "GET",
310            "cloud-infrastructure/complexes",
311            "Node Not Found:No Node of type complex found at: cloud-infrastructure/complexes",
312            "ERR.5.4.6114"
313          ]
314        }
315      }
316    }
317
318 12. Start the "traversal" microservice
319 --------------------------------------
320
321  Traversal runs on port 8446.  Go to the traversal directory
322
323  .. code-block:: bash
324
325     $ cd ~/src/aai/traversal
326
327  Set the debug port to 9446
328
329     $ export MAVEN_OPTS="-Xms1024m -Xmx5120m -XX:PermSize=2024m -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=9446,server=y,suspend=n"
330
331   Start the microservice - adjust your build version accordingly
332
333   .. code-block:: bash
334
335       $ mvn -pl aai-traversal -PrunAjsc -Daai.schema.version=0.0.1-TEST-SNAPSHOT -Daai.schema.ingest.version=0.0.1-TEST-SNAPSHOT -DskipTests -Dcheckstyle.skip=true
336
337   Should see something like this: Traversal Microservice Started
338