Details
-
Type:
Monitor
-
Status: Answered
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: FIWARE-TECH-HELP
-
Labels:
-
HD-Chapter:Unknown
-
HD-Enabler:Unknown
-
HD-Node:Unknown
Description
Created question in FIWARE Q/A platform on 28-03-2023 at 21:03
Please, ANSWER this question AT https://stackoverflow.com/questions/75871400/initialize-orion-with-persistent-data
Question:
Initialize Orion with persistent data
Description:
I am developing a simple project in orion to subscribe to the context change of some entities. I would like to initialize the orion service with data when I instantiate the container in docker with a list of data.
This is the docker-compose file:
version: "3.9"
services:
- Orion-LD Context Broker
orion:
container_name: fiware-orion
image: fiware/orion:latest
hostname: orion
depends_on:
- mongo-db
expose: - "1026"
ports: - "1026:1026"
volumes: - ./data/orion:/usr/local/bin
command: -dbhost mongo-db -logLevel DEBUG
networks: - default
- Database
mongo-db:
container_name: fiware-mongo
image: mongo:4.4
hostname: mongo-db
expose:
- "27017"
ports: - "27017:27017"
command: --nojournal
volumes: - ./data/mongo-db:/data
networks: - default
networks:
default:
This is the data I would like to insert (I wrote it in bash):
- Add devices
curl -s -o /dev/null -X POST 'http://orion:1026/v2/op/update'\
-H 'Content-Type: application/json'\
-g -d '{
"actionType": "append",
"entities": [
{
"id": "urn:ngsi-ld:Device:9845A",
"type": "Device",
"deviceCategory": { "type": "Property", "value": [ "sensor" ] },
{ "type": "Relationship", "value": [ "urn:ngsi-ld:Building:2" ] }
"controlledAsset":,
{ "type": "Property", "value": [ "temperature", "humidity" ] }
"controlledProperty":,
"batteryLevel":Unknown macro: { "type"},
{ "type": "Property", "value": "t%3D0.22%3Bh%3D58.3" }
"value":,
"dateFirstUsed":Unknown macro: { "type"},
{ "type": "Property", "value": "ok" }
"deviceState":,
{ "type": "Property", "value": "Inlet" }
"direction":,
{ "type": "Property", "value": "9845A" }
"serialNumber":},
{ "type": "Property", "value": [ "sensor" ] }
{
"id": "urn:ngsi-ld:Device:1284P",
"type": "Device",
"deviceCategory":,
{ "type": "Relationship", "value": [ "urn:ngsi-ld:Building:4" ] }
"controlledAsset":,
{ "type": "Property", "value": [ "occupancy" ] }
"controlledProperty":,
"batteryLevel":Unknown macro: { "type"},
{ "type": "Property", "value": "43" }
"value":,
"dateFirstUsed":Unknown macro: { "type"},
{ "type": "Property", "value": "ok" }
"deviceState":,
{ "type": "Property", "value": "Inlet" }
"direction":,
{ "type": "Property", "value": "1284P" }
"serialNumber":},
{ "type": "Property", "value": [ "sensor" ] }
{
"id": "urn:ngsi-ld:Device:5726B",
"type": "Device",
"deviceCategory":,
{ "type": "Relationship", "value": [ "urn:ngsi-ld:Building:5" ] }
"controlledAsset":,
{ "type": "Property", "value": [ "precipitation" ] }
"controlledProperty":,
"batteryLevel":Unknown macro: { "type"},
{ "type": "Property", "value": "26.14" }
"value":,
"dateFirstUsed":Unknown macro: { "type"},
{ "type": "Property", "value": "ok" }
"deviceState":,
{ "type": "Property", "value": "Outlet" }
"direction":,
{ "type": "Property", "value": "5726B" }
"serialNumber":},
{ "type": "Property", "value": [ "sensor" ] }
{
"id": "urn:ngsi-ld:Device:4858R",
"type": "Device",
"deviceCategory":,
{ "type": "Relationship", "value": [ "urn:ngsi-ld:OnStreetParking:1" ] }
"controlledAsset":,
{ "type": "Property", "value": [ "occupancy" ] }
"controlledProperty":,
"batteryLevel":Unknown macro: { "type"},
{ "type": "Property", "value": "12" }
"value":,
"dateFirstUsed":Unknown macro: { "type"},
{ "type": "Property", "value": "ok" }
"deviceState":,
{ "type": "Property", "value": "Entry" }
"direction":,
{ "type": "Property", "value": "4858R" }
"serialNumber":}
]
}'
I tried with command: sh -c “ -dbhost mongo-db -logLevel && import-data.sh” but it say me that command sh is not valid.
How can I do this?
Activity
- All
- Comments
- History
- Activity
- Transitions