[Backlogmanager] [FIWARE-JIRA] (HELP-21043) [fiware-stackoverflow] Initialize Orion with persistent data

Fernando Lopez (JIRA) jira-help-desk at jira.fiware.org
Wed Aug 23 09:04:00 CEST 2023


     [ https://jira.fiware.org/browse/HELP-21043?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Fernando Lopez reassigned HELP-21043:
-------------------------------------

    Assignee: Jason Fox

> [fiware-stackoverflow] Initialize Orion with persistent data
> ------------------------------------------------------------
>
>                 Key: HELP-21043
>                 URL: https://jira.fiware.org/browse/HELP-21043
>             Project: Help-Desk
>          Issue Type: Monitor
>          Components: FIWARE-TECH-HELP
>            Reporter: Backlog Manager
>            Assignee: Jason Fox
>              Labels: fiware, fiware-orion
>
> Created question in FIWARE Q/A platform on 28-03-2023 at 21:03
> {color: red}Please, ANSWER this question AT{color} 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"
>                     ]
>                 },
>                 "controlledAsset": {
>                     "type": "Relationship",
>                     "value": [
>                         "urn:ngsi-ld:Building:2"
>                     ]
>                 },
>                 "controlledProperty": {
>                     "type": "Property",
>                     "value": [
>                         "temperature",
>                         "humidity"
>                     ]
>                 },
>                 "batteryLevel": {
>                     "type": "Property",
>                     "value": {
>                         "@type": "Number",
>                         "@value": 0.75
>                     }
>                 },
>                 "value": {
>                     "type": "Property",
>                     "value": "t%3D0.22%3Bh%3D58.3"
>                 },
>                 "dateFirstUsed": {
>                     "type": "Property",
>                     "value": {
>                         "@type": "DateTime",
>                         "@value": "2023-03-23T11:00:00Z"
>                     }
>                 },
>                 "deviceState": {
>                     "type": "Property",
>                     "value": "ok"
>                 },
>                 "direction": {
>                     "type": "Property",
>                     "value": "Inlet"
>                 },
>                 "serialNumber": {
>                     "type": "Property",
>                     "value": "9845A"
>                 }
>             },
>             {
>                 "id": "urn:ngsi-ld:Device:1284P",
>                 "type": "Device",
>                 "deviceCategory": {
>                     "type": "Property",
>                     "value": [
>                         "sensor"
>                     ]
>                 },
>                 "controlledAsset": {
>                     "type": "Relationship",
>                     "value": [
>                         "urn:ngsi-ld:Building:4"
>                     ]
>                 },
>                 "controlledProperty": {
>                     "type": "Property",
>                     "value": [
>                         "occupancy"
>                     ]
>                 },
>                 "batteryLevel": {
>                     "type": "Property",
>                     "value": {
>                         "@type": "Number",
>                         "@value": 0.92
>                     }
>                 },
>                 "value": {
>                     "type": "Property",
>                     "value": "43"
>                 },
>                 "dateFirstUsed": {
>                     "type": "Property",
>                     "value": {
>                         "@type": "DateTime",
>                         "@value": "2023-03-23T11:00:00Z"
>                     }
>                 },
>                 "deviceState": {
>                     "type": "Property",
>                     "value": "ok"
>                 },
>                 "direction": {
>                     "type": "Property",
>                     "value": "Inlet"
>                 },
>                 "serialNumber": {
>                     "type": "Property",
>                     "value": "1284P"
>                 }
>             },
>             {
>                 "id": "urn:ngsi-ld:Device:5726B",
>                 "type": "Device",
>                 "deviceCategory": {
>                     "type": "Property",
>                     "value": [
>                         "sensor"
>                     ]
>                 },
>                 "controlledAsset": {
>                     "type": "Relationship",
>                     "value": [
>                         "urn:ngsi-ld:Building:5"
>                     ]
>                 },
>                 "controlledProperty": {
>                     "type": "Property",
>                     "value": [
>                         "precipitation"
>                     ]
>                 },
>                 "batteryLevel": {
>                     "type": "Property",
>                     "value": {
>                         "@type": "Number",
>                         "@value": 0.45
>                     }
>                 },
>                 "value": {
>                     "type": "Property",
>                     "value": "26.14"
>                 },
>                 "dateFirstUsed": {
>                     "type": "Property",
>                     "value": {
>                         "@type": "DateTime",
>                         "@value": "2023-03-23T11:00:00Z"
>                     }
>                 },
>                 "deviceState": {
>                     "type": "Property",
>                     "value": "ok"
>                 },
>                 "direction": {
>                     "type": "Property",
>                     "value": "Outlet"
>                 },
>                 "serialNumber": {
>                     "type": "Property",
>                     "value": "5726B"
>                 }
>             },
>             {
>                 "id": "urn:ngsi-ld:Device:4858R",
>                 "type": "Device",
>                 "deviceCategory": {
>                     "type": "Property",
>                     "value": [
>                         "sensor"
>                     ]
>                 },
>                 "controlledAsset": {
>                     "type": "Relationship",
>                     "value": [
>                         "urn:ngsi-ld:OnStreetParking:1"
>                     ]
>                 },
>                 "controlledProperty": {
>                     "type": "Property",
>                     "value": [
>                         "occupancy"
>                     ]
>                 },
>                 "batteryLevel": {
>                     "type": "Property",
>                     "value": {
>                         "@type": "Number",
>                         "@value": 0.84
>                     }
>                 },
>                 "value": {
>                     "type": "Property",
>                     "value": "12"
>                 },
>                 "dateFirstUsed": {
>                     "type": "Property",
>                     "value": {
>                         "@type": "DateTime",
>                         "@value": "2023-03-23T11:00:00Z"
>                     }
>                 },
>                 "deviceState": {
>                     "type": "Property",
>                     "value": "ok"
>                 },
>                 "direction": {
>                     "type": "Property",
>                     "value": "Entry"
>                 },
>                 "serialNumber": {
>                     "type": "Property",
>                     "value": "4858R"
>                 }
>             }
>         ]
>     }'
> 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?



--
This message was sent by Atlassian JIRA
(v6.4.1#64016)


More information about the Backlogmanager mailing list

You can get more information about our cookies and privacy policies clicking on the following links: Privacy policy   Cookies policy