-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathe2_healthcheck_solution.py
54 lines (43 loc) · 1.91 KB
/
e2_healthcheck_solution.py
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
"""
# # Exercise 2: Service Health Check
# Create one or multiple FiLiP clients and check if the corresponding services
# are up and running by accessing their version information.
# The input sections are marked with 'ToDo'
# #### Steps to complete:
# 1. Set up the missing parameters in the parameter section
# 2. Create FiLiP ngsi_v2 clients for the individual services and check for
# their version
# 3. Create a config object for the ngsi_v2 multi client (HttpClient),
# create the multi client and again check for services' versions
"""
# ## Import packages
from filip.clients.ngsi_v2 import \
HttpClient, \
HttpClientConfig, \
ContextBrokerClient, \
IoTAClient, \
QuantumLeapClient
# ## Parameters
# ToDo: Enter your context broker url and port, e.g. http://localhost:1026.
CB_URL = "http://localhost:1026"
# ToDo: Enter your IoT-Agent url and port, e.g. http://localhost:4041.
IOTA_URL = "http://localhost:4041"
# ToDo: Enter your QuantumLeap url and port, e.g. http://localhost:8668.
QL_URL = "http://localhost:8668"
# ## Main script
if __name__ == "__main__":
# ToDo: Create a single client for each service and check the service for
# its version.
cbc = ContextBrokerClient(url=CB_URL)
print(f"Context Broker Client: {cbc.get_version()}")
iotac = IoTAClient(url=IOTA_URL)
print(f"IoTA Client: {iotac.get_version()}")
qlc = QuantumLeapClient(url=QL_URL)
print(f"Quantum Leap Client: {qlc.get_version()}")
# ToDo: Create a configuration object for a multi client.
config = HttpClientConfig(cb_url=CB_URL, iota_url=IOTA_URL, ql_url=QL_URL)
# ToDo: Create a multi client check again all services for their version.
multic = HttpClient(config=config)
print(f"Multi Client (Context Broker): {multic.cb.get_version()}\n"
f"Multi Client (IoTA): {multic.iota.get_version()}\n"
f"Multi Client (Quantum Leap): {multic.timeseries.get_version()}")