summaryrefslogtreecommitdiffstats
path: root/docs/sections/services/heartbeat-ms/build_setup.rst
blob: f2943cc6cfb19ba458fd49a89ec427615e88d9c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
.. This work is licensed under a Creative Commons Attribution 4.0 International License.
.. http://creativecommons.org/licenses/by/4.0

.. _build_setup:


Build and Setup procedure
=========================

ONAP Repository
---------------

Use the below repository for Heartbeat Microservice.

   https://gerrit.onap.org/r/#/admin/projects/dcaegen2/services/heartbeat

POD 25 access
-------------

To run heartbeat Micro Service in development environment, POD25
access is required. Please get the access and install Openvpn.

Connect to POD25 setup using Openvpn and the credentials obtained.

Docker build procedure
----------------------

Clone the code using below command
   .. code-block:: bash
      git clone https://gerrit.onap.org/r/dcaegen2/services/heartbeat 

give executable permission to mvn-phase-script.sh if not there
already
   .. code-block:: bash

      chmod +x mvn-phase-script.sh

**Setting up the postgres DB, group/consumer IDs, CBS download and
CBS polling. The following environment variables are to be set.**

   For postgres and CBS download, the environment setting file to be
   passed while running the Docker. The file would contain following
   parameters. The sample values are shown for reference.

    ::
	   pg_ipAddress=10.0.4.1
	   pg_portNum=5432
	   pg_userName=postgres
	   pg_passwd=abc
	   #Below parameters for CBS download
	   SERVICE_NAME=mvp-dcaegen2-heartbeat-static
	   CONSUL_HOST=10.12.6.50
	   HOSTNAME=mvp-dcaegen2-heartbeat-static
	   #Below parameter for heartbeat worker process to receive message
	   groupID=group1
	   consumerID=1

   If the postgres parameters are not there in environment setting file,
   then it takes the values from    miss_htbt_service/config/hbproperties.yaml 
   file. Make sure that postgres running in the machine where pg_ipAddress 
   parameter is mentioned. 
   
   Run below netstat command to check postgres port number and IP address are fine.

   .. code-block:: bash
      netstat -ant

   If CBS parameters are not there in the environment setting file, then
   local config file (etc/config.json) is considered as a default
   configuration file.

   For CBS polling CBS_polling_allowed & CBS_polling_interval to be set
   appropriately in miss_htbt_service/config/hbproperties.yaml file

   The sample values in miss_htbt_service/config/hbproperties.yaml file
   are as follows
    .. code-block:: YAML
	
	   pg_ipAddress: 10.0.4.1
	   pg_portNum: 5432
	   pg_userName: postgres
	   pg_passwd: postgres
	   pg_dbName: hb_vnf
	   CBS_polling_allowed: True
	   CBS_polling_interval: 300

   PS: Change the groupID and consumerID in the environment accordingly
   for each HB instance so that HB worker process receive the HB event
   correctly. Usually groupID remains the same for all instance of HB
   where as consumerID would be changed for each instance of HB Micro
   service. If groupID and consumerID is not provided, then it takes
   “DefaultGroup” and “1” respectively.

**Setting CBS configuration parameters using the consule KV URL.**

   The sample consul KV is as below.
   ::
      http://10.12.6.50:8500/ui/#/dc1/kv/mvp-dcaegen2-heartbeat-static

   Go to the above link and click on KEY/VALUE tab

   Click on mvp-dcaegen2-heartbeat-static

   Copy the configuration in the box provided and click on update. 
   
   The sample configuration is as below
   
   .. code-block:: json
   
		{
			"heartbeat_config": {
				"vnfs": [{
						"eventName": "Heartbeat_S",
						"heartbeatcountmissed": 3,
						"heartbeatinterval": 60,
						"closedLoopControlName": "ControlLoopEvent1",
						"policyVersion": "1.0.0.5",
						"policyName": "vFireWall",
						"policyScope": "resource=sampleResource,type=sampletype,CLName=sampleCLName",
						"target_type": "VM",
						"target": "genVnfName",
						"version": "2.0"
					},
					{
						"eventName": "Heartbeat_vFW",
						"heartbeatcountmissed": 3,
						"heartbeatinterval": 60,
						"closedLoopControlName": "ControlLoopEvent1",
						"policyVersion": "1.0.0.5",
						"policyName": "vFireWall",
						"policyScope": "resource=sampleResource,type=sampletype,CLName=sampleCLName",
						"target_type": "VNF",
						"target": "genVnfName",
						"version": "2.0"
					}
				]
			},

			"streams_publishes": {
				"ves_heartbeat": {
					"dmaap_info": {
						"topic_url": "http://10.12.5.252:3904/events/unauthenticated.DCAE_CL_OUTPUT/"
					},
					"type": "message_router"
				}
			},
			"streams_subscribes": {
				"ves_heartbeat": {
					"dmaap_info": {
						"topic_url": "http://10.12.5.252:3904/events/unauthenticated.SEC_HEARTBEAT_INPUT/"
					},
					"type": "message_router"
				}
			}
		}

**Build the Docker using below command with a image name**

   .. code-block:: bash

     sudo Docker build --no-cache --network=host -f ./Dockerfile -t
     heartbeat.test1:latest .

 To check whether image is built or not, run below command

   .. code-block:: bash
      sudo Docker images |grep heartbeat.test1

**Run the Docker using below command which uses the environment file
mentioned in the above section.**

   .. code-block:: bash
      sudo Docker run -d --name hb1 --env-file env.list
      heartbeat.test1:latest

 To check the logs, run below command
 
   .. code-block:: bash
      sudo Docker logs -f hb1

**To stop the Docker run**

   Get the Docker container ID from below command

   .. code-block:: bash

       sudo Docker ps -a \| grep heartbeat.test1

   Run below commands to stop the Docker run
   
   .. code-block:: bash
   
       sudo Docker stop <Docker container ID)
       sudo Docker rm -f hb1

**Initiate the maven build**

   To run the maven build, execute any one of them.
   
   .. code-block:: bash
      sudo mvn -s settings.xml deploy
      OR
      sudo mvn -s settings.xml -X deploy

   If there is a libxml-xpath related issue, then install the
   libxml-xpath as below. If the issue is something else, follow the
   link given as part of the build failure.
  
   .. code-block:: bash
      sudo apt install libxml-xpath-perl