diff --git a/QueueStatus/code/code_for_using_dataModel.ACRIS_QueueStatus.py b/QueueStatus/code/code_for_using_dataModel.ACRIS_QueueStatus.py index 8288cf7..7234c52 100644 --- a/QueueStatus/code/code_for_using_dataModel.ACRIS_QueueStatus.py +++ b/QueueStatus/code/code_for_using_dataModel.ACRIS_QueueStatus.py @@ -1,5 +1,26 @@ -# # This code allows you to install a orion-ld broker in a linux system +# # The code for installing different versions of context brokers are located after the code +# +from pysmartdatamodels import pysmartdatamodels as sdm +import subprocess +serverUrl = "http://localhost:1026" # supposed that your broker is installed in localhost with 1026 as default port. Edit to match your configuration +dataModel = "QueueStatus" +subject = "dataModel.ACRIS" +Name = "" +attribute = "Name" +value = Name +# 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 +print(sdm.update_broker(dataModel, subject, attribute, value, serverUrl=serverUrl, updateThenCreate=True)) + +print(" In case you have installed the a cntext broker (see comments below )") +print(" Execute this instruction to check that the entities has been inserted") +command = ['curl', '-X', 'GET', 'http://localhost:1026/ngsi-ld/v1/entities?local=true&limit=1000'] +result = subprocess.run(command, capture_output=True, text=True) +print(result.stdout) + +# This code allows you to install different context brokers in a linux system +# +# # ORION-LD # # The manuals are here https://github.com/FIWARE/context.Orion-LD/tree/develop/doc/manuals-ld # # # INSTALL NGSI LD broker (OrionLD) @@ -23,26 +44,52 @@ # # Check what entities are in the broker # curl -X GET http://localhost:1026/ngsi-ld/v1/entities?local=true&limit=1000 # +# # STELLIO +# +# # INSTALL NGSI LD broker (Stellio) +# 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 +# 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 +# docker compose up -d +# # wait for some seconds for services to be up and running +# +# # TO RELAUNCH (only if you have already installed a broker in the same machine) +# docker compose down +# +# # CHECK INSTANCES +# curl -X GET 'http://localhost:8080/actuator/health' +# curl -X GET 'http://localhost:8080/search-service/actuator/health' +# +# # view the logs +# docker-compose logs -f --tail=100 +# +# # SCORPIO +# sudo docker pull postgis/postgis +# sudo docker pull scorpiobroker/all-in-one-runner:java-latest +# sudo docker network create fiware_default +# 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 +# sudo docker run -d --name scorpio -h scorpio --network=fiware_default -e DBHOST=postgres -p 9090:9090 scorpiobroker/all-in-one-runner:java-latest +# +# # TO RELAUNCH (only if you have already installed a broker in the same machine) +# sudo docker stop scorpio +# sudo docker rm scorpio +# sudo docker stop postgres +# sudo docker rm postgres +# sudo docker network rm fiware_default +# +# # CHECK INSTANCES +# # Check the broker is running +# # Release Info +# curl -X GET 'http://localhost:9090/q/info' +# # Health status of the broker +# curl -X GET 'http://localhost:9090/q/health' +# +# # Check what entities are in the broker +# curl -X GET http://localhost:1026/ngsi-ld/v1/entities?local=true&limit=1000 +# +# # # now the python code you can use to insert some value in the context broker according to the data model # # Version Warning! -# # This code is designed to work with the version 0.8 of pysmartdatamodels or later -# # to work with earlier version you need to replace the import instruction for -# # from pysmartdatamodels import pysmartdatamodels as sdm +# # This code is designed to work with the version 0.8.0.1 of pysmartdatamodels or later +# # -# -import pysmartdatamodels as sdm -import subprocess -serverUrl = "http://localhost:1026" # supposed that your broker is installed in localhost. Edit to match your configuration -dataModel = "QueueStatus" -subject = "dataModel.ACRIS" -Name = "" -attribute = "Name" -value = Name -# 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 -print(sdm.update_broker(dataModel, subject, attribute, value, serverUrl=serverUrl, updateThenCreate=True)) - -print(" In case you have installed the orion-ld broker (see comments on the header of this program)") -print(" Execute this instruction to check that the entities has been inserted") -command = ['curl', '-X', 'GET', 'http://localhost:1026/ngsi-ld/v1/entities?local=true&limit=1000'] -result = subprocess.run(command, capture_output=True, text=True) -print(result.stdout) +# \ No newline at end of file