Fix tox test loop in mvn-phase-script.sh
[modeling/etsicatalog.git] / docs / developer-guide.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. http://creativecommons.org/licenses/by/4.0
3
4 Developer Guide
5 ===============
6
7 Etsicatalog is a web application based on python3 and Django framework.
8
9 Pre-requisites
10 --------------
11
12 * Python3 & pip
13 * MariaDB
14
15 Etsicatalog can run standalone. However, if you want to try the whole functionality, you should have other components like SDC, DMaap(Non-mandatory), MSB(Non-mandatory) running.
16
17 You should set the component information in the environment variables as followed:
18 ::
19
20     SDC_ADDR=https://{SDC_IP}:30204
21     MSB_ENABLED=true
22     MSB_ADDR=https://{MSB_IP}:30283
23     DMAAP_ENABLED=true
24     DMAAP_ADDR=https://{DMAAP_IP}:30226
25
26 Note:
27
28 * The default value of MSB_ENABLED is **false**. Since Guilin Release, MSB is a **Non-mandatory** component. If you have no MSB installed or intention to use it, you can just omit MSB_ADDR and MSB_ENABLED.
29 * The default value of DMAAP_ENABLED is **false**. If you want to use SDC subscription and notification function, you should set it true and set DMAAP_ADDR properly.
30
31 Build & Run
32 -----------
33
34 **Clone repository**:
35 ::
36
37     $ git clone https://gerrit.onap.org/r/modeling/etsicatalog
38     $ cd etsicatalog
39
40 **Create database**::
41
42   $ cd /resources/dbscripts/mysql
43
44 Run modeling-etsicatalog-createdb.sql to create database.
45
46 Run commands followed to init database::
47
48   $ python manage.py makemigrations
49   $ python manage.py makemigrations database
50   $ python manage.py migrate
51   $ python manage.py migrate database
52
53 Review and edit \catalog\pub\config\config.py
54
55 MySQL default configuration is as follows::
56
57     DB_IP = "127.0.0.1"
58     DB_PORT = 3306
59     DB_NAME = "etsicatalog"
60     DB_USER = "etsicatalog"
61     DB_PASSWD = "etsicatalog"
62
63 **Start server**::
64
65   $ python manage.py runserver 8806
66
67
68
69 Test
70 ----
71
72 **Run Healthcheck**::
73
74     GET /api/catalog/v1/health_check
75
76 You should get::
77
78     {
79         "status": "active"
80     }
81
82 **View API document**:
83
84 http://127.0.0.1:8806/api/catalog/v1/swagger
85
86
87 Run from Docker image
88 ----------------------
89
90 You can run Modeling/etsicatalog directly from the docker image by following commands:
91 ::
92
93     $ docker run -d -p 3306:3306 --name etsicatalog-db -v /var/lib/mysql -e MYSQL_USER="etsicatalog" -e MYSQL_PASSWORD="etsicatalog" -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE="etsicatalog" nexus3.onap.org:10001/library/mariadb
94
95     $ docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' etsicatalog-db
96     Get the IP of etsicatalog-db
97
98     $ docker run -d --name modeling-etsicatalog -v /var/lib/mysql -e DB_IP=<ip address> -e SDC_ADDR=<ip address> nexus3.onap.org:10001/onap/modeling/etsicatalog
99
100 **Note**:
101
102 You can also build the docker image instead of using the existed image from nexus3.onap.org:10001.
103 ::
104
105     $ cd docker
106     $ docker build -t ${IMAGE_NAME} .