aboutsummaryrefslogtreecommitdiffstats
path: root/docs/platform/Getting Started/AAI_Developer_Environment_Setup.rst
blob: 6f7871cc652ecb6620cb397296f9f2e7fc8d4800 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
.. contents::
   :depth: 3
.. _dev-setup:


AAI Developer Environment Setup
================================

This guide will illustrate setting up an A&AI development environment in
Ubuntu 16.04.  

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.

Install openjdk 8
-----------------

   .. code:: bash

      sudo apt install openjdk-8-jdk

Install single node hadoop/titan
--------------------------------

   .. code-block:: bash

     wget http://s3.thinkaurelius.com/downloads/titan/titan-1.0.0-hadoop1.zip

     unzip titan-1.0.0-hadoop1.zip

     cd titan-1.0.0-hadoop1
     
     sudo ./bin/titan.sh start

Install haproxy
---------------

   .. code-block:: bash

     sudo apt-get -y install haproxy

     haproxy -v
       HA-Proxy version 1.6.3 2015/12/25
       Copyright 2000-2015 Willy Tarreau
        willy@haproxy.org http://haproxy.org/

- Install this haproxy.cfg file in /etc/haproxy

    `haproxy.cfg <https://wiki.onap.org/download/attachments/10782088/haproxy.cfg?version=2&modificationDate=1501018863000&api=v2>`__

  .. code-block:: bash

    sudo cp aai.pem /etc/ssl/private/aai.pem

    sudo chmod 640 /etc/ssl/private/aai.pem

    sudo chown root:ssl-cert /etc/ssl/private/aai.pem

  `aai.pem <https://wiki.onap.org/download/attachments/10782088/aai.pem?version=1&modificationDate=1501019585000&api=v2>`__

  .. code-block:: bash

    sudo mkdir /usr/local/etc/haproxy

- Add these hostnames to the loopback interface in /etc/hosts

   .. code-block:: bash

     127.0.0.1 localhost aai-traversal.api.simpledemo.openecomp.org aai-resouces.api.simpledemo.openecomp.org

- Restart haproxy

   .. code-block:: bash

     sudo service haproxy restart

Set up repos
------------

- First, follow the initial setup instructions in 
  `Setting Up Your Development Environment <https://wiki.onap.org/display/DW/Setting+Up+Your+Development+Environment>`__

  .. code-block:: bash

    mkdir -p ~/LF/AAI

    cd ~/LF/AAI

    git clone ssh://<username>@gerrit.onap.org:29418/aai/aai-common

    git clone ssh://<username>@gerrit.onap.org:29418/aai/traversal

    git clone ssh://<username>@gerrit.onap.org:29418/aai/resources

    git clone ssh://<username>@gerrit.onap.org:29418/aai/logging-service

- If you did not originally create a settings.xml file when setting
  up the dev environment, you may get an error on some of the repos
  saying that oparent is unresolvable.  Using the example
  settings.xml file should solve this problem:
  `Setting Up Your Development Environment#MavenExamplesettings.xml <https://wiki.onap.org/display/DW/Setting+Up+Your+Development+Environment#SettingUpYourDevelopmentEnvironment-MavenExamplesettings.xml>`__

Build aai-common, traversal, and resources
------------------------------------------

   .. code-block:: bash
     
     cd ~/LF/AAI/aai-common

     mvn clean install # Should result in BUILD SUCCESS

     cd ~/LF/AAI/resources

     mvn clean install # Should result in BUILD SUCCESS

     cd ~/LF/AAI/logging-service

     mvn clean install # Should result in BUILD SUCCESS

     cd ~/LF/AAI/traversal

You might need to add the following to traversal/pom.xml to get traversal to build: 

       .. code-block:: xml

        <repositories><repository><id>maven-restlet</id><name>Restlet repository</name><url>https://maven.restlet.com</url></repository></repositories>

   .. code-block:: bash

     mvn clean install # Should result in BUILD SUCCESS

Titan setup
-----------

   1. Modify both titan-cached.properties and
        titan-realtime.properties to the following (for all MS’s that
        will connect to the local Cassandra backend)
      
	.. code-block:: bash

	  storage.backend=\ *cassandra*
	  storage.hostname=\ *localhost*

   2. update
      ~/LF/AAI/resources/aai-resources/bundleconfig-local/etc/appprops/titan-cached.properties

   3. update
      ~/LF/AAI/resources/aai-resources/bundleconfig-local/etc/appprops/titan-realtime.properties

   4. update
      ~/LF/AAI/traversal/aai-traversal/bundleconfig-local/etc/appprops/titan-cached.properties

   5. update
      ~/LF/AAI/traversal/aai-traversal/bundleconfig-local/etc/appprops/titan-realtime.properties

   6. The following property can be added to specify the keyspace
        name, each time you do this step (g) should be done. If not
        specified Titan will try to create/use a defaulted keyspace
        named titan.

	.. code-block:: bash

	  storage.cassandra.keyspace=<keyspace name>

   7. From the resources MS run the create db schema standalone program.

   8. ***NOTE***: The first thing that would need to be done is adding
      the schema to the local instance. (this will need to be done
      whenever using a new keyspace or after wiping the data).

    Runnable class org.onap.aai.dbgen.GenTester with the following vm
    args.

    .. code-block:: bash

      -DAJSC_HOME=~/LF/AAI/resources -DBUNDLECONFIG\_DIR="bundleconfig-local"

   9. Here's the command I used, and it worked:

      .. code-block:: bash

        cd ~/LF/AAI; java -DAJSC_HOME=/home/jimmy/LF/AAI/resources/aai-resources
        -DBUNDLECONFIG_DIR="bundleconfig-local" -cp
        aai-common/aai-core/target/aai-core-1.1.0-SNAPSHOT.jar:resources/aai-resources/target/aai-resources.jar:resources/aai-resources/target/userjars/\*
        org.onap.aai.dbgen.GenTester

Start the "resources" microservice
----------------------------------

   1. Resources runs on port 8446.  Go to the resources directory
   
      .. code-block:: bash

       $ cd ~/LF/AAI/resources

   2. Set the debug port to 9446

      .. code-block:: bash

          export MAVEN_OPTS="-Xms1024m -Xmx5120m -XX:PermSize=2024m
          -Xdebug -Xnoagent -Djava.compiler=NONE
          -Xrunjdwp:transport=dt_socket,address=9446,server=y,suspend=n"

   3. Start the microservice

      .. code-block::bash

        $ mvn -P runAjsc

Verify the resources microservice (this example uses Postman utility for Google Chrome)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

   1.  Use basic auth, user = AAI, pw = AAI

   2.  Set the X-TransactionId header (in the example below, the value is
       9999)

   3.  Set the X-FromAppId header (in the example below, the value is
       jimmy-postman)

   4.  Perform a GET of https://127.0.0.1:8443/aai/v11/network/vces

   5.  You should see an error as below, 404 Not Found, ERR.5.4.6114. 
       This indicates that the service is functioning normally:

+------------------------------------------+
| |image1|                                 |
+------------------------------------------+

Start the "traversal" microservice
----------------------------------

   1. Traversal runs on port 8447.  Go to the traversal directory:

      .. code-block:: bash

       $ cd ~/LF/AAI/traversal
      
   2.  Set the debug port to 9447

       $ export MAVEN_OPTS="-Xms1024m -Xmx5120m -XX:PermSize=2024m
        -Xdebug -Xnoagent -Djava.compiler=NONE
        -Xrunjdwp:transport=dt_socket,address=9447,server=y,suspend=n"

   3.  Start the microservice

      .. code-block:: bash

       $ mvn -P runAjsc

      You should see something like this:

      .. code-block:: bash

       2017-07-26
       12:46:35.524:INFO:oejs.Server:com.att.ajsc.runner.Runner.main():
       Started @25827ms

Verify the traversal microservice
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

   1.  Set up the widget models
       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>`__

   2.  Create a runner using this file:
       `models.csv <https://wiki.onap.org/download/attachments/10782088/models.csv?version=1&modificationDate=1501100140000&api=v2>`__

   3.  Run the test runner
       |image2|

   4.  Add a named query called "getComponentList" (this named query is used by VID):

       `NamedQuery.postman_collection.json <ificationDate=1501102582000&api=v2>`__
       
       |image3|

   5.  Add objects:

       `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>`__ 

   6.  Execute named-query:
       `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>`__
       You should see something like the following:
       |image4|

- Your A&AI instance is now running, both the resources and traversal microservices are working properly with a local titan graph.

- Next: `Tutorial: Making and Testing a Schema Change in A&AI <https://wiki.onap.org/pages/viewpage.action?pageId=10783023>`__

.. |image1| image:: media/image1.png
   :width: 4.87500in
   :height: 2.87500in
.. |image2| image:: media/image2.png
   :width: 4.87500in
   :height: 3.75000in
.. |image3| image:: media/image3.png
   :width: 4.87500in
   :height: 4.15000in
.. |image4| image:: media/image4.png
   :width: 4.87500in
   :height: 4.15000in