Uploaded image for project: 'Help-Desk'
  1. Help-Desk
  2. HELP-21043

[fiware-stackoverflow] Initialize Orion with persistent data

    Details

    • Type: Monitor
    • Status: Answered
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: FIWARE-TECH-HELP

      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:

      1. 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
      1. 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):

      1. 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":

        Unknown macro: { "type"}

        ,
        "value":

        { "type": "Property", "value": "t%3D0.22%3Bh%3D58.3" }

        ,
        "dateFirstUsed":

        Unknown macro: { "type"}

        ,
        "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":

        Unknown macro: { "type"}

        ,
        "value":

        { "type": "Property", "value": "43" }

        ,
        "dateFirstUsed":

        Unknown macro: { "type"}

        ,
        "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":

        Unknown macro: { "type"}

        ,
        "value":

        { "type": "Property", "value": "26.14" }

        ,
        "dateFirstUsed":

        Unknown macro: { "type"}

        ,
        "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":

        Unknown macro: { "type"}

        ,
        "value":

        { "type": "Property", "value": "12" }

        ,
        "dateFirstUsed":

        Unknown macro: { "type"}

        ,
        "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?

        Activity

        Hide
        backlogmanager Backlog Manager added a comment -

        2023-03-29 05:31|CREATED monitor | # answers= 0, accepted answer= False

        Show
        backlogmanager Backlog Manager added a comment - 2023-03-29 05:31|CREATED monitor | # answers= 0, accepted answer= False
        Hide
        backlogmanager Backlog Manager added a comment -

        2023-04-01 05:32|UPDATED status: transition Answer| # answers= 1, accepted answer= False

        Show
        backlogmanager Backlog Manager added a comment - 2023-04-01 05:32|UPDATED status: transition Answer| # answers= 1, accepted answer= False
        Hide
        backlogmanager Backlog Manager added a comment -

        2023-04-02 05:31|UPDATED status: transition Answered| # answers= 1, accepted answer= False

        Show
        backlogmanager Backlog Manager added a comment - 2023-04-02 05:31|UPDATED status: transition Answered| # answers= 1, accepted answer= False

          People

          • Assignee:
            jason.fox Jason Fox
            Reporter:
            backlogmanager Backlog Manager
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: