update link to upper-constraints.txt
[dcaegen2.git] / docs / sections / services / heartbeat-ms / build_setup.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.\r
2 .. http://creativecommons.org/licenses/by/4.0\r
3 \r
4 Build and Setup procedure\r
5 =========================\r
6 \r
7 ONAP Repository\r
8 ---------------\r
9 \r
10 Use the below repository for Heartbeat Microservice.\r
11 \r
12    https://gerrit.onap.org/r/#/admin/projects/dcaegen2/services/heartbeat\r
13 \r
14 POD 25 access\r
15 -------------\r
16 \r
17 To run heartbeat Micro Service in development environment, POD25\r
18 access is required. Please get the access and install Openvpn.\r
19 \r
20 Connect to POD25 setup using Openvpn and the credentials obtained.\r
21 \r
22 Docker build procedure\r
23 ----------------------\r
24 \r
25 Clone the code using below command\r
26 \r
27 ::\r
28       git clone --depth 1 https://gerrit.onap.org/r/dcaegen2/services/heartbeat\r
29 \r
30 give executable permission to mvn-phase-script.sh if not there\r
31 already\r
32 \r
33 ::\r
34       chmod +x mvn-phase-script.sh\r
35 \r
36 **Setting up the postgres DB, group/consumer IDs, CBS download and\r
37 CBS polling. The following environment variables are to be set.**\r
38 \r
39    For postgres and CBS download, the environment setting file to be\r
40    passed while running the Docker. The file would contain following\r
41    parameters. The sample values are shown for reference.\r
42 \r
43     ::\r
44            pg_ipAddress=10.0.4.1\r
45            pg_portNum=5432\r
46            pg_userName=postgres\r
47            pg_passwd=abc\r
48            #Below parameters for CBS download\r
49            SERVICE_NAME=mvp-dcaegen2-heartbeat-static\r
50            CONSUL_HOST=10.12.6.50\r
51            HOSTNAME=mvp-dcaegen2-heartbeat-static\r
52            #Below parameter for heartbeat worker process to receive message\r
53            groupID=group1\r
54            consumerID=1\r
55 \r
56    If the postgres parameters are not there in environment setting file,\r
57    then it takes the values from    miss_htbt_service/config/hbproperties.yaml\r
58    file. Make sure that postgres running in the machine where pg_ipAddress\r
59    parameter is mentioned.\r
60 \r
61    Run below netstat command to check postgres port number and IP address are fine.\r
62 \r
63 ::\r
64 \r
65       netstat -ant\r
66 \r
67    If CBS parameters are not there in the environment setting file, then\r
68    local config file (etc/config.json) is considered as a default\r
69    configuration file.\r
70 \r
71    For CBS polling CBS_polling_allowed & CBS_polling_interval to be set\r
72    appropriately in miss_htbt_service/config/hbproperties.yaml file\r
73 \r
74    The sample values in miss_htbt_service/config/hbproperties.yaml file\r
75    are as follows\r
76 \r
77 ::\r
78 \r
79            pg_ipAddress: 10.0.4.1\r
80            pg_portNum: 5432\r
81            pg_userName: postgres\r
82            pg_passwd: postgres\r
83            pg_dbName: hb_vnf\r
84            CBS_polling_allowed: True\r
85            CBS_polling_interval: 300\r
86 \r
87    PS: Change the groupID and consumerID in the environment accordingly\r
88    for each HB instance so that HB worker process receive the HB event\r
89    correctly. Usually groupID remains the same for all instance of HB\r
90    where as consumerID would be changed for each instance of HB Micro\r
91    service. If groupID and consumerID is not provided, then it takes\r
92    "DefaultGroup" and "1" respectively.\r
93 \r
94 **Setting CBS configuration parameters using the consule KV URL.**\r
95 \r
96    The sample consul KV is as below.\r
97    ::\r
98 \r
99      http://10.12.6.50:8500/ui/#/dc1/kv/mvp-dcaegen2-heartbeat-static\r
100 \r
101    Go to the above link and click on KEY/VALUE tab\r
102 \r
103    Click on mvp-dcaegen2-heartbeat-static\r
104 \r
105    Copy the configuration in the box provided and click on update.\r
106 \r
107    The sample configuration is as below\r
108 \r
109    .. code-block:: json\r
110 \r
111                 {\r
112                         "heartbeat_config": {\r
113                                 "vnfs": [{\r
114                                                 "eventName": "Heartbeat_S",\r
115                                                 "heartbeatcountmissed": 3,\r
116                                                 "heartbeatinterval": 60,\r
117                                                 "closedLoopControlName": "ControlLoopEvent1",\r
118                                                 "policyVersion": "1.0.0.5",\r
119                                                 "policyName": "vFireWall",\r
120                                                 "policyScope": "resource=sampleResource,type=sampletype,CLName=sampleCLName",\r
121                                                 "target_type": "VM",\r
122                                                 "target": "genVnfName",\r
123                                                 "version": "2.0"\r
124                                         },\r
125                                         {\r
126                                                 "eventName": "Heartbeat_vFW",\r
127                                                 "heartbeatcountmissed": 3,\r
128                                                 "heartbeatinterval": 60,\r
129                                                 "closedLoopControlName": "ControlLoopEvent1",\r
130                                                 "policyVersion": "1.0.0.5",\r
131                                                 "policyName": "vFireWall",\r
132                                                 "policyScope": "resource=sampleResource,type=sampletype,CLName=sampleCLName",\r
133                                                 "target_type": "VNF",\r
134                                                 "target": "genVnfName",\r
135                                                 "version": "2.0"\r
136                                         }\r
137                                 ]\r
138                         },\r
139 \r
140                         "streams_publishes": {\r
141                                 "ves_heartbeat": {\r
142                                         "dmaap_info": {\r
143                                                 "topic_url": "http://10.12.5.252:3904/events/unauthenticated.DCAE_CL_OUTPUT/"\r
144                                         },\r
145                                         "type": "message_router"\r
146                                 }\r
147                         },\r
148                         "streams_subscribes": {\r
149                                 "ves_heartbeat": {\r
150                                         "dmaap_info": {\r
151                                                 "topic_url": "http://10.12.5.252:3904/events/unauthenticated.SEC_HEARTBEAT_INPUT/"\r
152                                         },\r
153                                         "type": "message_router"\r
154                                 }\r
155                         }\r
156                 }\r
157 \r
158 **Build the Docker using below command with a image name**\r
159 \r
160 ::\r
161 \r
162      sudo Docker build --no-cache --network=host -f ./Dockerfile -t\r
163      heartbeat.test1:latest .\r
164 \r
165  To check whether image is built or not, run below command\r
166 \r
167 ::\r
168 \r
169       sudo Docker images |grep heartbeat.test1\r
170 \r
171 **Run the Docker using below command which uses the environment file\r
172 mentioned in the above section.**\r
173 \r
174 ::\r
175 \r
176       sudo Docker run -d --name hb1 --env-file env.list\r
177       heartbeat.test1:latest\r
178 \r
179  To check the logs, run below command\r
180 \r
181 ::\r
182 \r
183       sudo Docker logs -f hb1\r
184 \r
185 **To stop the Docker run**\r
186 \r
187    Get the Docker container ID from below command\r
188 \r
189 ::\r
190 \r
191        sudo Docker ps -a \| grep heartbeat.test1\r
192 \r
193    Run below commands to stop the Docker run\r
194 \r
195 ::\r
196 \r
197        sudo Docker stop <Docker container ID)\r
198        sudo Docker rm -f hb1\r
199 \r
200 **Initiate the maven build**\r
201 \r
202    To run the maven build, execute any one of them.\r
203 \r
204 ::\r
205 \r
206       sudo mvn -s settings.xml deploy\r
207       OR\r
208       sudo mvn -s settings.xml -X deploy\r
209 \r
210    If there is a libxml-xpath related issue, then install the\r
211    libxml-xpath as below. If the issue is something else, follow the\r
212    link given as part of the build failure.\r
213 \r
214 ::\r
215       sudo apt install libxml-xpath-perl\r