1
1
2
- # # This code allows you to install a orion-ld broker in a linux system
2
+ # # The code for installing different versions of context brokers are located after the code
3
+ #
4
+ from pysmartdatamodels import pysmartdatamodels as sdm
5
+ import subprocess
6
+ serverUrl = "http://localhost:1026" # supposed that your broker is installed in localhost with 1026 as default port. Edit to match your configuration
7
+ dataModel = "VibrationsObserved"
8
+ subject = "dataModel.Building"
9
+ accelerationMeasured = 1.3
10
+ attribute = "accelerationMeasured"
11
+ value = accelerationMeasured
12
+ # The next line creates the query for inserting this attribute in a NGSI-LD context broker if the attribute does not exist it creates it
13
+ print (sdm .update_broker (dataModel , subject , attribute , value , serverUrl = serverUrl , updateThenCreate = True ))
14
+
15
+ dateObserved = "2021-03-08T09:45:00Z"
16
+ attribute = "dateObserved"
17
+ value = dateObserved
18
+ # The next line creates the query for inserting this attribute in a NGSI-LD context broker if the attribute does not exist it creates it
19
+ print (sdm .update_broker (dataModel , subject , attribute , value , serverUrl = serverUrl , updateThenCreate = True ))
20
+
21
+ print (" In case you have installed the a cntext broker (see comments below )" )
22
+ print (" Execute this instruction to check that the entities has been inserted" )
23
+ command = ['curl' , '-X' , 'GET' , 'http://localhost:1026/ngsi-ld/v1/entities?local=true&limit=1000' ]
24
+ result = subprocess .run (command , capture_output = True , text = True )
25
+ print (result .stdout )
26
+
27
+ # This code allows you to install different context brokers in a linux system
28
+ #
29
+ # # ORION-LD
3
30
# # The manuals are here https://github.com/FIWARE/context.Orion-LD/tree/develop/doc/manuals-ld
4
31
#
5
32
# # INSTALL NGSI LD broker (OrionLD)
23
50
# # Check what entities are in the broker
24
51
# curl -X GET http://localhost:1026/ngsi-ld/v1/entities?local=true&limit=1000
25
52
#
53
+ # # STELLIO
54
+ #
55
+ # # INSTALL NGSI LD broker (Stellio)
56
+ # curl -O https://raw.githubusercontent.com/stellio-hub/stellio-context-broker/develop/docker-compose.yml -O https://raw.githubusercontent.com/stellio-hub/stellio-context-broker/develop/.env
57
+ # curl -o config/kafka/update_run.sh --create-dirs https://raw.githubusercontent.com/stellio-hub/stellio-context-broker/develop/config/kafka/update_run.sh && chmod u+x config/kafka/update_run.sh
58
+ # docker compose up -d
59
+ # # wait for some seconds for services to be up and running
60
+ #
61
+ # # TO RELAUNCH (only if you have already installed a broker in the same machine)
62
+ # docker compose down
63
+ #
64
+ # # CHECK INSTANCES
65
+ # curl -X GET 'http://localhost:8080/actuator/health'
66
+ # curl -X GET 'http://localhost:8080/search-service/actuator/health'
67
+ #
68
+ # # view the logs
69
+ # docker-compose logs -f --tail=100
70
+ #
71
+ # # SCORPIO
72
+ # sudo docker pull postgis/postgis
73
+ # sudo docker pull scorpiobroker/all-in-one-runner:java-latest
74
+ # sudo docker network create fiware_default
75
+ # sudo docker run -d --name postgres --network=fiware_default -h postgres -p 5432 -e POSTGRES_USER=ngb -e POSTGRES_PASSWORD=ngb -e POSTGRES_DB=ngb postgis/postgis
76
+ # sudo docker run -d --name scorpio -h scorpio --network=fiware_default -e DBHOST=postgres -p 9090:9090 scorpiobroker/all-in-one-runner:java-latest
77
+ #
78
+ # # TO RELAUNCH (only if you have already installed a broker in the same machine)
79
+ # sudo docker stop scorpio
80
+ # sudo docker rm scorpio
81
+ # sudo docker stop postgres
82
+ # sudo docker rm postgres
83
+ # sudo docker network rm fiware_default
84
+ #
85
+ # # CHECK INSTANCES
86
+ # # Check the broker is running
87
+ # # Release Info
88
+ # curl -X GET 'http://localhost:9090/q/info'
89
+ # # Health status of the broker
90
+ # curl -X GET 'http://localhost:9090/q/health'
91
+ #
92
+ # # Check what entities are in the broker
93
+ # curl -X GET http://localhost:1026/ngsi-ld/v1/entities?local=true&limit=1000
94
+ #
95
+ #
26
96
# # now the python code you can use to insert some value in the context broker according to the data model
27
97
# # Version Warning!
28
- # # This code is designed to work with the version 0.8 of pysmartdatamodels or later
29
- # # to work with earlier version you need to replace the import instruction for
30
- # # from pysmartdatamodels import pysmartdatamodels as sdm
98
+ # # This code is designed to work with the version 0.8.0.1 of pysmartdatamodels or later
99
+ #
31
100
#
32
- #
33
- import pysmartdatamodels as sdm
34
- import subprocess
35
- serverUrl = "http://localhost:1026" # supposed that your broker is installed in localhost. Edit to match your configuration
36
- dataModel = "VibrationsObserved"
37
- subject = "dataModel.Building"
38
- accelerationMeasured = 1.3
39
- attribute = "accelerationMeasured"
40
- value = accelerationMeasured
41
- # The next line creates the query for inserting this attribute in a NGSI-LD context broker if the attribute does not exist it creates it
42
- print (sdm .update_broker (dataModel , subject , attribute , value , serverUrl = serverUrl , updateThenCreate = True ))
43
-
44
- dateObserved = "2021-03-08T09:45:00Z"
45
- attribute = "dateObserved"
46
- value = dateObserved
47
- # The next line creates the query for inserting this attribute in a NGSI-LD context broker if the attribute does not exist it creates it
48
- print (sdm .update_broker (dataModel , subject , attribute , value , serverUrl = serverUrl , updateThenCreate = True ))
49
-
50
- print (" In case you have installed the orion-ld broker (see comments on the header of this program)" )
51
- print (" Execute this instruction to check that the entities has been inserted" )
52
- command = ['curl' , '-X' , 'GET' , 'http://localhost:1026/ngsi-ld/v1/entities?local=true&limit=1000' ]
53
- result = subprocess .run (command , capture_output = True , text = True )
54
- print (result .stdout )
101
+ #
0 commit comments