Update Dublin docs
[aai/aai-common.git] / docs / platform / Getting Started / AAI_Developer_Environment_Setup.rst
index 6f7871c..c8afd9c 100644 (file)
 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.
 
-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.
+1. Install openjdk 8
+--------------------
+ .. code-block:: bash
 
-Install openjdk 8
------------------
+   1. $ sudo apt install openjdk-8-jdk
 
-   .. code:: bash
+2. Install single node hadoop/janusgraph
+----------------------------------------
+ .. code-block:: bash
 
-      sudo apt install openjdk-8-jdk
+   1. $ wget http://github.com/JanusGraph/janusgraph/releases/download/v0.2.0/janusgraph-0.2.0-hadoop2.zip
+   2. $ unzip janusgraph-0.2.0-hadoop2.zip
+   3. $ cd janusgraph-0.2.0-hadoop2/
+   4. $ ./bin/janusgraph.sh start
 
-Install single node hadoop/titan
---------------------------------
+ Ensure you are not a root user as elasticsearch cannot be run as root.
+ Response looks like:
 
  .. code-block:: bash
+ .. code-block:: bash
 
-     wget http://s3.thinkaurelius.com/downloads/titan/titan-1.0.0-hadoop1.zip
+   Forking Cassandra...
+   Running `nodetool statusthrift`... OK (returned exit status 0 and printed string "running").
+   Forking Elasticsearch...
+   Connecting to Elasticsearch (127.0.0.1:9200)...... OK (connected to 127.0.0.1:9200).
+   Forking Gremlin-Server... 
+   Connecting to Gremlin-Server (127.0.0.1:8182).... OK (connected to 127.0.0.1:8182).
+   Run gremlin.sh to connect.
 
-     unzip titan-1.0.0-hadoop1.zip
+ You can verify whether everything is running by executing
 
-     cd titan-1.0.0-hadoop1
-     
-     sudo ./bin/titan.sh start
+ .. code-block:: bash
 
-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/
+   ./bin/janusgraph.sh status
 
-- Install this haproxy.cfg file in /etc/haproxy
+ And the output looks like:
 
-    `haproxy.cfg <https://wiki.onap.org/download/attachments/10782088/haproxy.cfg?version=2&modificationDate=1501018863000&api=v2>`__
+ .. code-block:: bash
 
-  .. code-block:: bash
-
-    sudo cp aai.pem /etc/ssl/private/aai.pem
+   Gremlin-Server (org.apache.tinkerpop.gremlin.server.GremlinServer) is running with pid 9835
+   Elasticsearch (org.elasticsearch.bootstrap.Elasticsearch) is running with pid 9567
+   Cassandra (org.apache.cassandra.service.CassandraDaemon) is running with pid 9207
 
-    sudo chmod 640 /etc/ssl/private/aai.pem
+3. Install haproxy
+------------------
 
-    sudo chown root:ssl-cert /etc/ssl/private/aai.pem
+ .. code-block:: bash
 
-  `aai.pem <https://wiki.onap.org/download/attachments/10782088/aai.pem?version=1&modificationDate=1501019585000&api=v2>`__
-
-  .. code-block:: bash
+    1. $ sudo apt-get -y install haproxy
+    2. $ <path-to-haproxy>/haproxy -v
 
-    sudo mkdir /usr/local/etc/haproxy
+ Response should be:       
 
-- Add these hostnames to the loopback interface in /etc/hosts
+ .. code-block:: bash
 
-   .. code-block:: bash
+   HA-Proxy version 1.6.3 2015/12/25
+   Copyright 2000-2015 Willy Tarreau <willy@haproxy.org>
 
-     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
+ Install the attached :download:`haproxy.cfg <media/haproxy.cfg>` in /etc/haproxy
 
-    mkdir -p ~/LF/AAI
+ .. code-block:: bash
 
-    cd ~/LF/AAI
+   $ sudo cp haproxy.cfg /etc/haproxy
+   $ sudo mkdir /usr/local/etc/haproxy
 
-    git clone ssh://<username>@gerrit.onap.org:29418/aai/aai-common
+ Install the attached :download:`aai.pem <media/aai.pem>` file in /etc/ssl/private
 
-    git clone ssh://<username>@gerrit.onap.org:29418/aai/traversal
+ .. code-block:: bash
 
-    git clone ssh://<username>@gerrit.onap.org:29418/aai/resources
+   $ 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 
 
-    git clone ssh://<username>@gerrit.onap.org:29418/aai/logging-service
+ Add these hostnames to the loopback interface in /etc/hosts: 
 
-- 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>`__
+ 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
 
-Build aai-common, traversal, and resources
-------------------------------------------
+ .. code-block:: bash
 
-   .. code-block:: bash
-     
-     cd ~/LF/AAI/aai-common
+   $ sudo service haproxy restart
 
-     mvn clean install # Should result in BUILD SUCCESS
+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.
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ .. code-block:: bash
 
-     cd ~/LF/AAI/resources
+   $ sudo apt-get install git
+   $ sudo apt-get install npm
+   $ sudo apt-get install maven
+   $ sudo apt-get install docker.io
+   $ wget https://git.onap.org/oparent/plain/settings.xml
+   $ mkdir ~/.m2
+   $ cp settings.xml ~/.m2
 
-     mvn clean install # Should result in BUILD SUCCESS
+ If you 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>`__
 
-     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
+5. Set Up Repos
+---------------
 
-Titan setup
------------
+ .. code-block:: bash
 
-   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
+   $ mkdir -p ~/src/aai
+   $ 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
 
-         storage.backend=\ *cassandra*
-         storage.hostname=\ *localhost*
+6. Checkout the 'dublin' branch
+-------------------------------
 
-   2. update
-      ~/LF/AAI/resources/aai-resources/bundleconfig-local/etc/appprops/titan-cached.properties
+ .. code-block:: bash
 
-   3. update
-      ~/LF/AAI/resources/aai-resources/bundleconfig-local/etc/appprops/titan-realtime.properties
+    $ 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
 
-   4. update
-      ~/LF/AAI/traversal/aai-traversal/bundleconfig-local/etc/appprops/titan-cached.properties
+7. Janus Setup (part 1)
+-----------------------
 
-   5. update
-      ~/LF/AAI/traversal/aai-traversal/bundleconfig-local/etc/appprops/titan-realtime.properties
+ Modify both janus-cached.properties and janus-realtime.properties to the following (for all MS’s that will connect to the local Cassandra backend)
 
-   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:: 
+   
+   storage.backend=cassandra
+   storage.hostname=localhost
+   storage.cassandra.keyspace=onap # or different keyspace name of your choosing
+
+ Edit the following files:
+
+ .. code::
+
+   ~/src/aai/resources/aai-resources/src/main/resources/etc/appprops/janusgraph-cached.properties
+   ~/src/aai/resources/aai-resources/src/main/resources/etc/appprops/janusgraph-realtime.properties
+   ~/src/aai/traversal/aai-traversal/src/main/resources/etc/appprops/janusgraph-cached.properties
+   ~/src/aai/traversal/aai-traversal/src/main/resources/etc/appprops/janusgraph-realtime.properties
+   ~/src/aai/graphadmin/src/main/resources/etc/appprops/janusgraph-cached.properties
+   ~/src/aai/graphadmin/src/main/resources/etc/appprops/janusgraph-realtime.properties
+
+8. Build all the modules
+------------------------
+
+ .. code-block:: bash
+
+   $ 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
+
+   $ grep -e "SUCCESS" -e "FAILURE" log.txt
+
+ And you should see:
+
+ .. code::
+
+   [INFO] aai-schema ......................................... SUCCESS [ 32.504 s]
+   [INFO] aai-queries ........................................ SUCCESS [ 6.461 s]
+   [INFO] aai-schema-service ................................. SUCCESS [02:17 min]
+   [INFO] BUILD SUCCESS
+   [INFO] aai-resources ...................................... SUCCESS [ 1.190 s]
+   [INFO] BUILD SUCCESS
+   [INFO] aai-resources ...................................... SUCCESS [ 3.210 s]
+   [INFO] aai-resources ...................................... SUCCESS [ 41.213 s]
+   [INFO] BUILD SUCCESS
+   [INFO] aai-traversal ...................................... SUCCESS [ 1.090 s]
+   [INFO] BUILD SUCCESS
+   [INFO] aai-traversal ...................................... SUCCESS [ 3.181 s]
+   [INFO] aai-traversal ...................................... SUCCESS [ 58.001 s]
+   [INFO] BUILD SUCCESS
+   [INFO] BUILD SUCCESS
+   [INFO] BUILD SUCCESS
+   [INFO] aai-logging-service ................................ SUCCESS [ 1.101 s]
+   [INFO] BUILD SUCCESS
+   [INFO] aai-logging-service ................................ SUCCESS [ 5.230 s]
+   [INFO] Common Logging API ................................. SUCCESS [ 1.995 s]
+   [INFO] EELF Logging Implementation ........................ SUCCESS [ 4.235 s]
+   [INFO] Common Logging Distribution ........................ SUCCESS [ 0.530 s]
+   [INFO] BUILD SUCCESS
+
+9. Janus setup (part 2)
+-----------------------
+   
+ Run this on the local instance on your first time running AAI and whenever using new keyspace or after wiping the data.
 
-       .. code-block:: bash
+ Install the schema
 
-         storage.cassandra.keyspace=<keyspace name>
+ .. code-block:: bash
 
-   7. From the resources MS run the create db schema standalone program.
+    $ (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)
 
-   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).
+ You should see:
 
-    Runnable class org.onap.aai.dbgen.GenTester with the following vm
-    args.
+ .. code:: 
 
-    .. code-block:: bash
+   ---- NOTE --- about to open graph (takes a little while)--------;
+   -- Loading new schema elements into JanusGraph --
+   -- graph commit
+   -- graph shutdown
 
-      -DAJSC_HOME=~/LF/AAI/resources -DBUNDLECONFIG\_DIR="bundleconfig-local"
+10. Start the "resources" microservice
+--------------------------------------
 
-   9. Here's the command I used, and it worked:
+ Resources runs on port 8447.  Go to the resources directory
 
     .. code-block:: bash
+ .. 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
+    $ cd ~/src/aai/resources
 
-Start the "resources" microservice
-----------------------------------
+ Set the debug port to 9447
 
-   1. Resources runs on port 8446.  Go to the resources directory
-   
-      .. code-block:: bash
+  .. code-block:: bash
 
-       $ cd ~/LF/AAI/resources
+     $ export MAVEN_OPTS="-Xms1024m -Xmx5120m -XX:PermSize=2024m -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=9447,server=y,suspend=n"
 
-   2. Set the debug port to 9446
+ Start the microservice - adjust your build version accordingly
 
     .. code-block:: bash
+ .. 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"
+     $ 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
 
-   3. Start the microservice
+ Should see something like this: Resources Microservice Started
 
-      .. code-block::bash
 
-        $ mvn -P runAjsc
+11. Verify the resources microservice
+-------------------------------------
 
-Verify the resources microservice (this example uses Postman utility for Google Chrome)
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ This example uses curl from commandline
 
-   1.  Use basic auth, user = AAI, pw = AAI
+ .. code-block:: bash
 
-   2.  Set the X-TransactionId header (in the example below, the value is
-       9999)
+    $ sudo apt-get install jq  # for pretty output
 
-   3.  Set the X-FromAppId header (in the example below, the value is
-       jimmy-postman)
+ Download :download:`script - test-complex <media/test-complex>`
+ Download :download:`data - data-complex.json <media/data-complex.json>`
 
-   4.  Perform a GET of https://127.0.0.1:8443/aai/v11/network/vces
+ .. code-block:: bash
 
-   5.  You should see an error as below, 404 Not Found, ERR.5.4.6114. 
-       This indicates that the service is functioning normally:
+   $ sh ./test-complex 2>&1 | tee log.txt
 
-+------------------------------------------+
-| |image1|                                 |
-+------------------------------------------+
+ Confirm log.txt contains:
 
-Start the "traversal" microservice
-----------------------------------
+ .. code-block:: bash
 
-   1. Traversal runs on port 8447.  Go to the traversal directory:
+    > GET /aai/v16/cloud-infrastructure/complexes HTTP/1.1
 
-      .. code-block:: bash
+ .. code-block:: json
 
-       $ cd ~/LF/AAI/traversal
-      
-   2.  Set the debug port to 9447
+    {
+     "requestError": {
+       "serviceException": {
+         "messageId": "SVC3001",
+         "text": "Resource not found for %1 using id %2 (msg=%3) (ec=%4)",
+         "variables": [
+           "GET",
+           "cloud-infrastructure/complexes",
+           "Node Not Found:No Node of type complex found at: cloud-infrastructure/complexes",
+           "ERR.5.4.6114"
+         ]
+       }
+     }
+    }
 
-       $ export MAVEN_OPTS="-Xms1024m -Xmx5120m -XX:PermSize=2024m
-        -Xdebug -Xnoagent -Djava.compiler=NONE
-        -Xrunjdwp:transport=dt_socket,address=9447,server=y,suspend=n"
+ Then followed by:
 
-   3.  Start the microservice
+ .. code-block:: bash
 
-      .. code-block:: bash
+    > PUT /aai/v16/cloud-infrastructure/complexes/complex/clli2 HTTP/1.1
+    > GET /aai/v16/cloud-infrastructure/complexes/complex/clli2 HTTP/1.1
 
-       $ mvn -P runAjsc
+ With payload: 
 
-      You should see something like this:
+ .. code-block:: json
+  
+   {
+     "physical-location-id": "clli2",
+     "data-center-code": "example-data-center-code-val-6667",
+     "complex-name": "clli2",
+     "identity-url": "example-identity-url-val-28399",
+     "resource-version": "1543408364646",
+     "physical-location-type": "example-physical-location-type-val-28399",
+     "street1": "example-street1-val-28399",
+     "street2": "example-street2-val-28399",
+     "city": "example-city-val-28399",
+     "state": "example-state-val-28399",
+     "postal-code": "example-postal-code-val-28399",
+     "country": "example-country-val-28399",
+     "region": "example-region-val-28399",
+     "latitude": "1111",
+     "longitude": "2222",
+     "elevation": "example-elevation-val-28399",
+     "lata": "example-lata-val-28399"
+   }
+   
+ And finishes with:
 
     .. code-block:: bash
+ .. code-block:: bash
 
-       2017-07-26
-       12:46:35.524:INFO:oejs.Server:com.att.ajsc.runner.Runner.main():
-       Started @25827ms
+    > DELETE /aai/v16/cloud-infrastructure/complexes/complex/clli2?resource-version=1543408364646 HTTP/1.1
+    > GET /aai/v16/cloud-infrastructure/complexes HTTP/1.1
 
-Verify the traversal microservice
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ With the following:
+  
+ .. code-block:: json
 
-   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>`__
+     {
+     "requestError": {
+       "serviceException": {
+         "messageId": "SVC3001",
+         "text": "Resource not found for %1 using id %2 (msg=%3) (ec=%4)",
+         "variables": [
+           "GET",
+           "cloud-infrastructure/complexes",
+           "Node Not Found:No Node of type complex found at: cloud-infrastructure/complexes",
+           "ERR.5.4.6114"
+         ]
+       }
+     }
+   }     
 
-   2.  Create a runner using this file:
-       `models.csv <https://wiki.onap.org/download/attachments/10782088/models.csv?version=1&modificationDate=1501100140000&api=v2>`__
+12. Start the "traversal" microservice
+--------------------------------------    
 
-   3.  Run the test runner
-       |image2|
+ Traversal runs on port 8446.  Go to the traversal directory
 
-   4.  Add a named query called "getComponentList" (this named query is used by VID):
+ .. code-block:: bash
 
-       `NamedQuery.postman_collection.json <ificationDate=1501102582000&api=v2>`__
-       
-       |image3|
+    $ cd ~/src/aai/traversal
 
-   5.  Add objects:
+ Set the debug port to 9446
+    $ export MAVEN_OPTS="-Xms1024m -Xmx5120m -XX:PermSize=2024m -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=9446,server=y,suspend=n"
 
-       `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>`__ 
+  Start the microservice - adjust your build version accordingly
 
-   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|
+  .. code-block:: bash
 
-- Your A&AI instance is now running, both the resources and traversal microservices are working properly with a local titan graph.
+      $ 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
 
-- Next: `Tutorial: Making and Testing a Schema Change in A&AI <https://wiki.onap.org/pages/viewpage.action?pageId=10783023>`__
+  Should see something like this: Traversal Microservice Started
 
-.. |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