dcae r4 doc updates
[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 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       http://10.12.6.50:8500/ui/#/dc1/kv/mvp-dcaegen2-heartbeat-static\r
99 \r
100    Go to the above link and click on KEY/VALUE tab\r
101 \r
102    Click on mvp-dcaegen2-heartbeat-static\r
103 \r
104    Copy the configuration in the box provided and click on update. \r
105    \r
106    The sample configuration is as below\r
107    \r
108    .. code-block:: json\r
109    \r
110                 {\r
111                         "heartbeat_config": {\r
112                                 "vnfs": [{\r
113                                                 "eventName": "Heartbeat_S",\r
114                                                 "heartbeatcountmissed": 3,\r
115                                                 "heartbeatinterval": 60,\r
116                                                 "closedLoopControlName": "ControlLoopEvent1",\r
117                                                 "policyVersion": "1.0.0.5",\r
118                                                 "policyName": "vFireWall",\r
119                                                 "policyScope": "resource=sampleResource,type=sampletype,CLName=sampleCLName",\r
120                                                 "target_type": "VM",\r
121                                                 "target": "genVnfName",\r
122                                                 "version": "2.0"\r
123                                         },\r
124                                         {\r
125                                                 "eventName": "Heartbeat_vFW",\r
126                                                 "heartbeatcountmissed": 3,\r
127                                                 "heartbeatinterval": 60,\r
128                                                 "closedLoopControlName": "ControlLoopEvent1",\r
129                                                 "policyVersion": "1.0.0.5",\r
130                                                 "policyName": "vFireWall",\r
131                                                 "policyScope": "resource=sampleResource,type=sampletype,CLName=sampleCLName",\r
132                                                 "target_type": "VNF",\r
133                                                 "target": "genVnfName",\r
134                                                 "version": "2.0"\r
135                                         }\r
136                                 ]\r
137                         },\r
138 \r
139                         "streams_publishes": {\r
140                                 "ves_heartbeat": {\r
141                                         "dmaap_info": {\r
142                                                 "topic_url": "http://10.12.5.252:3904/events/unauthenticated.DCAE_CL_OUTPUT/"\r
143                                         },\r
144                                         "type": "message_router"\r
145                                 }\r
146                         },\r
147                         "streams_subscribes": {\r
148                                 "ves_heartbeat": {\r
149                                         "dmaap_info": {\r
150                                                 "topic_url": "http://10.12.5.252:3904/events/unauthenticated.SEC_HEARTBEAT_INPUT/"\r
151                                         },\r
152                                         "type": "message_router"\r
153                                 }\r
154                         }\r
155                 }\r
156 \r
157 **Build the Docker using below command with a image name**\r
158 \r
159 ::\r
160 \r
161      sudo Docker build --no-cache --network=host -f ./Dockerfile -t\r
162      heartbeat.test1:latest .\r
163 \r
164  To check whether image is built or not, run below command\r
165 \r
166 ::\r
167       sudo Docker images |grep heartbeat.test1\r
168 \r
169 **Run the Docker using below command which uses the environment file\r
170 mentioned in the above section.**\r
171 \r
172 ::\r
173       sudo Docker run -d --name hb1 --env-file env.list\r
174       heartbeat.test1:latest\r
175 \r
176  To check the logs, run below command\r
177  \r
178 ::\r
179       sudo Docker logs -f hb1\r
180 \r
181 **To stop the Docker run**\r
182 \r
183    Get the Docker container ID from below command\r
184 \r
185 ::\r
186 \r
187        sudo Docker ps -a \| grep heartbeat.test1\r
188 \r
189    Run below commands to stop the Docker run\r
190    \r
191 ::\r
192    \r
193        sudo Docker stop <Docker container ID)\r
194        sudo Docker rm -f hb1\r
195 \r
196 **Initiate the maven build**\r
197 \r
198    To run the maven build, execute any one of them.\r
199    \r
200 :: \r
201       sudo mvn -s settings.xml deploy\r
202       OR\r
203       sudo mvn -s settings.xml -X deploy\r
204 \r
205    If there is a libxml-xpath related issue, then install the\r
206    libxml-xpath as below. If the issue is something else, follow the\r
207    link given as part of the build failure.\r
208 \r
209 :: \r
210       sudo apt install libxml-xpath-perl\r