Skip to content

Commit e63cada

Browse files
created example of code
1 parent 8869cc6 commit e63cada

File tree

1 file changed

+80
-33
lines changed

1 file changed

+80
-33
lines changed
Lines changed: 80 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,9 @@
11

2-
# # This code allows you to install a orion-ld broker in a linux system
3-
# # The manuals are here https://github.com/FIWARE/context.Orion-LD/tree/develop/doc/manuals-ld
4-
#
5-
# # INSTALL NGSI LD broker (OrionLD)
6-
# sudo docker pull mongo:3.6
7-
# sudo docker pull fiware/orion-ld
8-
# sudo docker network create fiware_default
9-
# sudo docker run -d --name=mongo-db --network=fiware_default --expose=27017 mongo:3.6 --bind_ip_all --smallfiles
10-
# sudo docker run -d --name fiware-orionld -h orion --network=fiware_default -p 1026:1026 fiware/orion-ld -dbhost mongo-db
11-
#
12-
# # TO RELAUNCH (only if you have already installed a broker in the same machine)
13-
# sudo docker stop fiware-orionld
14-
# sudo docker rm fiware-orionld
15-
# sudo docker stop mongo-db
16-
# sudo docker rm mongo-db
17-
# sudo docker network rm fiware_default
2+
# # The code for installing different versions of context brokers are located after the code
183
#
19-
# # CHECK INSTANCES
20-
# # Check the broker is running
21-
# curl -X GET 'http://localhost:1026/version'
22-
#
23-
# # Check what entities are in the broker
24-
# curl -X GET http://localhost:1026/ngsi-ld/v1/entities?local=true&limit=1000
25-
#
26-
# # now the python code you can use to insert some value in the context broker according to the data model
27-
# # 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
31-
#
32-
#
33-
import pysmartdatamodels as sdm
4+
from pysmartdatamodels import pysmartdatamodels as sdm
345
import subprocess
35-
serverUrl = "http://localhost:1026" # supposed that your broker is installed in localhost. Edit to match your configuration
6+
serverUrl = "http://localhost:1026" # supposed that your broker is installed in localhost with 1026 as default port. Edit to match your configuration
367
dataModel = "BuildingType"
378
subject = "dataModel.Building"
389
buildingTypeChildren = ['urn:ngsi-ld:BuildingType:e4291e84-58f8-11e8-84c3-77e4f1f8c4f1', 'urn:ngsi-ld:BuildingType:a71c7a08-58f9-11e8-a41e-4bcb7249360e', 'urn:ngsi-ld:BuildingType:afac9bbc-58f9-11e8-b587-1f0d57b81bb4']
@@ -53,8 +24,84 @@
5324
# 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
5425
print(sdm.update_broker(dataModel, subject, attribute, value, serverUrl=serverUrl, updateThenCreate=True))
5526

56-
print(" In case you have installed the orion-ld broker (see comments on the header of this program)")
27+
print(" In case you have installed the a cntext broker (see comments below )")
5728
print(" Execute this instruction to check that the entities has been inserted")
5829
command = ['curl', '-X', 'GET', 'http://localhost:1026/ngsi-ld/v1/entities?local=true&limit=1000']
5930
result = subprocess.run(command, capture_output=True, text=True)
6031
print(result.stdout)
32+
33+
# This code allows you to install different context brokers in a linux system
34+
#
35+
# # ORION-LD
36+
# # The manuals are here https://github.com/FIWARE/context.Orion-LD/tree/develop/doc/manuals-ld
37+
#
38+
# # INSTALL NGSI LD broker (OrionLD)
39+
# sudo docker pull mongo:3.6
40+
# sudo docker pull fiware/orion-ld
41+
# sudo docker network create fiware_default
42+
# sudo docker run -d --name=mongo-db --network=fiware_default --expose=27017 mongo:3.6 --bind_ip_all --smallfiles
43+
# sudo docker run -d --name fiware-orionld -h orion --network=fiware_default -p 1026:1026 fiware/orion-ld -dbhost mongo-db
44+
#
45+
# # TO RELAUNCH (only if you have already installed a broker in the same machine)
46+
# sudo docker stop fiware-orionld
47+
# sudo docker rm fiware-orionld
48+
# sudo docker stop mongo-db
49+
# sudo docker rm mongo-db
50+
# sudo docker network rm fiware_default
51+
#
52+
# # CHECK INSTANCES
53+
# # Check the broker is running
54+
# curl -X GET 'http://localhost:1026/version'
55+
#
56+
# # Check what entities are in the broker
57+
# curl -X GET http://localhost:1026/ngsi-ld/v1/entities?local=true&limit=1000
58+
#
59+
# # STELLIO
60+
#
61+
# # INSTALL NGSI LD broker (Stellio)
62+
# 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
63+
# 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
64+
# docker compose up -d
65+
# # wait for some seconds for services to be up and running
66+
#
67+
# # TO RELAUNCH (only if you have already installed a broker in the same machine)
68+
# docker compose down
69+
#
70+
# # CHECK INSTANCES
71+
# curl -X GET 'http://localhost:8080/actuator/health'
72+
# curl -X GET 'http://localhost:8080/search-service/actuator/health'
73+
#
74+
# # view the logs
75+
# docker-compose logs -f --tail=100
76+
#
77+
# # SCORPIO
78+
# sudo docker pull postgis/postgis
79+
# sudo docker pull scorpiobroker/all-in-one-runner:java-latest
80+
# sudo docker network create fiware_default
81+
# 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
82+
# sudo docker run -d --name scorpio -h scorpio --network=fiware_default -e DBHOST=postgres -p 9090:9090 scorpiobroker/all-in-one-runner:java-latest
83+
#
84+
# # TO RELAUNCH (only if you have already installed a broker in the same machine)
85+
# sudo docker stop scorpio
86+
# sudo docker rm scorpio
87+
# sudo docker stop postgres
88+
# sudo docker rm postgres
89+
# sudo docker network rm fiware_default
90+
#
91+
# # CHECK INSTANCES
92+
# # Check the broker is running
93+
# # Release Info
94+
# curl -X GET 'http://localhost:9090/q/info'
95+
# # Health status of the broker
96+
# curl -X GET 'http://localhost:9090/q/health'
97+
#
98+
# # Check what entities are in the broker
99+
# curl -X GET http://localhost:1026/ngsi-ld/v1/entities?local=true&limit=1000
100+
#
101+
#
102+
# # now the python code you can use to insert some value in the context broker according to the data model
103+
# # Version Warning!
104+
# # This code is designed to work with the version 0.8.0.1 of pysmartdatamodels or later
105+
#
106+
#
107+
#

0 commit comments

Comments
 (0)