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