Giter VIP home page Giter VIP logo

edgehog-device-runtime's People

Contributors

bettio avatar dependabot[bot] avatar francescovaiani avatar harlem88 avatar joshuachp avatar nanjarapalli avatar noaccos avatar rbino avatar rgallor avatar sorru94 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

edgehog-device-runtime's Issues

Define a Rust module to support Docker Engine API

Rust provides a powerful module system that can be used to hierarchically split code in logical units (modules), and manage visibility (public/private) between them.

A module is a collection of items: functions, structs, traits, impl blocks, and even other modules.

Tracking issue: interfaces for docker module

Interfaces

Here is the list of interfaces defined for the system:

Images

Create image request

{
  "interface_name": "io.edgehog.devicemanager.apps.CreateImageRequest",
  "version_major": 0,
  "version_minor": 1,
  "type": "datastream",
  "ownership": "server",
  "aggregation": "object",
  "mappings": [
    {
      "endpoint": "/image/id",
      "type": "string"
    },
    {
      "endpoint": "/image/repo",
      "type": "string"
    },
    {
      "endpoint": "/image/name",
      "type": "string"
    },
    {
      "endpoint": "/image/tag",
      "type": "string"
    }
  ]
}

Available Images

{
  "interface_name": "io.edgehog.devicemanager.apps.AvailableImages",
  "version_major": 0,
  "version_minor": 1,
  "type": "properties",
  "ownership": "device",
  "mappings": [
    {
      "allow_unset": true,
      "endpoint": "/%{image_id}/pulled",
      "type": "boolean"
    }
  ]
}

Volumes

Create Volume Request

{
  "interface_name": "io.edgehog.devicemanager.apps.CreateVolumeRequest",
  "version_major": 0,
  "version_minor": 1,
  "type": "datastream",
  "ownership": "server",
  "aggregation": "object",
  "mappings": [
    {
      "endpoint": "/volume/id",
      "type": "string"
    },
    {
      "endpoint": "/volume/driver",
      "type": "string"
    },
    {
      "endpoint": "/volume/options",
      "type": "string"
    }
  ]
}

Available Volumes

{
  "interface_name": "io.edgehog.devicemanager.apps.AvailableVolumes",
  "version_major": 0,
  "version_minor": 1,
  "type": "properties",
  "ownership": "device",
  "mappings": [
    {
      "allow_unset": true,
      "endpoint": "/%{volume_id}/created",
      "type": "boolean"
    },
    {
      "allow_unset": true,
      "endpoint": "/%{volume_id}/driver",
      "type": "boolean"
    },
    {
      "allow_unset": true,
      "endpoint": "/%{volume_id}/options",
      "type": "boolean"
    }
  ]
}

Networks

Create Network request

{
  "interface_name": "io.edgehog.devicemanager.apps.CreateNetworkRequest",
  "version_major": 0,
  "version_minor": 1,
  "type": "datastream",
  "ownership": "server",
  "aggregation": "object",
  "mappings": [
    {
      "endpoint": "/network/id",
      "type": "string"
    },
    {
      "endpoint": "/network/driver",
      "type": "string"
    },
    {
      "endpoint": "/network/checkDuplicate",
      "type": "boolean"
    },
    {
      "endpoint": "/network/internal",
      "type": "boolean"
    },
    {
      "endpoint": "/network/enableIPv6",
      "type": "boolean"
    }
  ]
}

Available Networks

{
  "interface_name": "io.edgehog.devicemanager.apps.AvailableNetworks",
  "version_major": 0,
  "version_minor": 1,
  "type": "properties",
  "ownership": "device",
  "mappings": [
    {
      "endpoint": "/%{network_id}/driver",
      "type": "string"
    },
    {
      "endpoint": "/%{network_id}/checkDuplicate",
      "type": "boolean"
    },
    {
      "endpoint": "/%{network_id}/internal",
      "type": "boolean"
    },
    {
      "endpoint": "/%{network_id}/enableIPv6",
      "type": "boolean"
    }
  ]
}

Containers

Create Container Request

{
  "interface_name": "io.edgehog.devicemanager.apps.CreateContainerRequest",
  "version_major": 0,
  "version_minor": 1,
  "type": "datastream",
  "ownership": "server",
  "aggregation": "object",
  "mappings": [
    {
      "endpoint": "/container/id",
      "type": "string"
    },
    {
      "endpoint": "/container/hostname",
      "type": "string"
    },
    {
      "endpoint": "/container/imageId",
      "type": "string"
    },
    {
      "endpoint": "/container/restartPolicy",
      "type": "string"
    },
    {
      "endpoint": "/container/env",
      "type": "stringarray",
      "doc": "Array of KEY=value environment variables"
    },
    {
      "endpoint": "/container/binds",
      "type": "stringarray",
      "doc": "Array of binds"
    },
    {
      "endpoint": "/container/networks",
      "type": "stringarray"
    },
    {
      "endpoint": "/container/portBindings",
      "type": "stringarray",
      "doc": "Array of ip:[host_port:]container_port[/protocol] | [hostPort:]containerPort[/protocol]. protocol is tcp by default"
    },
    {
      "endpoint": "/container/privileged",
      "type": "boolean"
    }
  ]
}

Available Containers

{
  "interface_name": "io.edgehog.devicemanager.apps.AvailableContainers",
  "version_major": 0,
  "version_minor": 1,
  "type": "properties",
  "ownership": "device",
  "mappings": [
    {
      "endpoint": "/%{container_id}/hostname",
      "type": "string"
    },
    {
      "endpoint": "/%{container_id}/imageId",
      "type": "string"
    },
    {
      "endpoint": "/%{container_id}/restartPolicy",
      "type": "string"
    },
    {
      "endpoint": "/%{container_id}/env",
      "type": "stringarray",
      "doc": "Array of KEY=value environment variables"
    },
    {
      "endpoint": "/%{container_id}/binds",
      "type": "stringarray",
      "doc": "Array of binds"
    },
    {
      "endpoint": "/%{container_id}/networks",
      "type": "stringarray"
    },
    {
      "endpoint": "/%{container_id}/portBindings",
      "type": "stringarray",
      "doc": "Array of ip:[host_port:]container_port[/protocol] | [hostPort:]containerPort[/protocol]. protocol is tcp by default"
    },
    {
      "endpoint": "/%{container_id}/privileged",
      "type": "boolean"
    },
    {
      "endpoint": "/%{container_id}/status",
      "type": "string"
    }
  ]
}

Other interfaces to be defined

Those need to be worked on more.

Releases

{
  "interface_name": "io.edgehog.devicemanager.apps.CreateReleaseRequest",
  "version_major": 0,
  "version_minor": 1,
  "type": "datastream",
  "ownership": "server",
  "aggregation": "object",
  "mappings": [
    {
      "endpoint": "/release/id",
      "type": "string"
    },
    {
      "endpoint": "/release/applicationId",
      "type": "string"
    },
    {
      "endpoint": "/release/version",
      "type": "string"
    },
    {
      "endpoint": "/release/containers",
      "type": "stringarray"
    }
  ]
}
{
  "interface_name": "io.edgehog.devicemanager.apps.AvailableRelease",
  "version_major": 0,
  "version_minor": 1,
  "type": "properties",
  "ownership": "device",
  "mappings": [
    {
      "endpoint": "/%{release_id}/application_id",
      "type": "string"
    }
  ]
}

Application

{
  "interface_name": "io.edgehog.devicemanager.apps.ApplicationCommand",
  "version_major": 0,
  "version_minor": 1,
  "type": "datastream",
  "ownership": "server",
  "mappings": [
    {
      "endpoint": "/%{application_id}/%{version}/command",
      "type": "string",
      "doc": "TODO: command enum [start, stop]"
    }
  ]
}

Scenarios

{
  "interface_name": "io.edgehog.devicemanager.apps.CreateScenarioRequest",
  "version_major": 0,
  "version_minor": 1,
  "type": "datastream",
  "ownership": "server",
  "aggregation": "object",
  "mappings": [
    {
      "endpoint": "/scenario/id",
      "type": "string"
    },
    {
      "endpoint": "/scenario/name",
      "type": "string"
    },
    {
      "endpoint": "/scenario/applications",
      "type": "stringarray"
    }
  ]
}
{
  "interface_name": "io.edgehog.devicemanager.apps.AvailableScenarios",
  "version_major": 0,
  "version_minor": 1,
  "type": "properties",
  "ownership": "device",
  "mappings": [
    {
      "endpoint": "/%{scenario_id}/name",
      "type": "string"
    },
    {
      "endpoint": "/%{scenario_id}/applications",
      "type": "stringarray"
    }
  ]
}
{
  "interface_name": "io.edgehog.devicemanager.apps.ActivateScenarioRequest",
  "version_major": 0,
  "version_minor": 1,
  "type": "datastream",
  "ownership": "server",
  "aggregation": "object",
  "mappings": [
    {
      "endpoint": "/scenario/id",
      "type": "string"
    }
  ]
}
{
  "interface_name": "io.edgehog.devicemanager.apps.AvailableScenarios",
  "version_major": 0,
  "version_minor": 1,
  "type": "properties",
  "ownership": "device",
  "mappings": [
    {
      "endpoint": "/%{scenario_id}/name",
      "type": "string"
    },
    {
      "endpoint": "/%{scenario_id}/applications",
      "type": "string"
    }
  ]
}

Update Astarte device SDK to 0.7

  • Remove direct integration of Astarte Message Hub transport.
  • Use Astarte device SDK for supporting the Astarte Message Hub transport.

Add support to Astarte Message Hub

  • Make it configurable, the device runtime should be support both connection ways ( Astarte SDK, Astarte Message Hub )
  • The codebase should be the same, I think should be added a new impl of Publisher

[Docker] Create network request

Create the structure to receive the CreateNetowrkRequest and publish the AvailableNetworks property.

Interfaces

Create Network request

{
  "interface_name": "io.edgehog.devicemanager.apps.CreateNetworkRequest",
  "version_major": 0,
  "version_minor": 1,
  "type": "datastream",
  "ownership": "server",
  "aggregation": "object",
  "mappings": [
    {
      "endpoint": "/network/id",
      "type": "string"
    },
    {
      "endpoint": "/network/driver",
      "type": "string"
    },
    {
      "endpoint": "/network/checkDuplicate",
      "type": "boolean"
    },
    {
      "endpoint": "/network/internal",
      "type": "boolean"
    },
    {
      "endpoint": "/network/enableIpv6",
      "type": "boolean"
    }
  ]
}

Available Networks

{
  "interface_name": "io.edgehog.devicemanager.apps.AvailableNetworks",
  "version_major": 0,
  "version_minor": 1,
  "type": "properties",
  "ownership": "device",
  "mappings": [
    {
      "endpoint": "/%{network_id}/id",
      "type": "string"
    },
    {
      "endpoint": "/%{network_id}/driver",
      "type": "string"
    },
    {
      "endpoint": "/%{network_id}/checkDuplicate",
      "type": "boolean"
    },
    {
      "endpoint": "/%{network_id}/internal",
      "type": "boolean"
    },
    {
      "endpoint": "/%{network_id}/enableIpv6",
      "type": "boolean"
    }
  ]
}

Unset ForwarderSessionState property after runtime restart

If the device runtime suddenly crashes and one or more device forwarder sessions were active, after it has been restarted, it will neither attempt to unset the sessions' state nor to re-establish them.
To prevent this, it is necessary that, when initialized, the device forwarder retrieves the previously stored ForwarderSessionState property values from Astarte. However, this can only be done if the SqliteStore is being used, which can be trivial if the AstarteMessageHub is used instead of the AstarteDeviceSdk. It is necessary to modify the astarte-message-hub-proto and the AstarteMessageHub to enable the correct transmission of the ForwarderSessionState property values to the device.

[Docker] Create container request

Create the structure to receive the CreateContainerRequest and publish the AvailableContainers property.

Interfaces

Create Container Request

{
  "interface_name": "io.edgehog.devicemanager.apps.CreateContainerRequest",
  "version_major": 0,
  "version_minor": 1,
  "type": "datastream",
  "ownership": "server",
  "aggregation": "object",
  "mappings": [
    {
      "endpoint": "/container/id",
      "type": "string"
    },
    {
      "endpoint": "/container/hostname",
      "type": "string"
    },
    {
      "endpoint": "/container/imageId",
      "type": "string"
    },
    {
      "endpoint": "/container/restartPolicy",
      "type": "string"
    },
    {
      "endpoint": "/container/env",
      "type": "stringarray",
      "doc": "Array of KEY=value environment variables"
    },
    {
      "endpoint": "/container/binds",
      "type": "stringarray",
      "doc": "Array of binds"
    },
    {
      "endpoint": "/container/networks",
      "type": "stringarray"
    },
    {
      "endpoint": "/container/portBindings",
      "type": "stringarray",
      "doc": "Array of ip:[host_port:]container_port[/protocol] | [hostPort:]containerPort[/protocol]. protocol is tcp by default"
    },
    {
      "endpoint": "/container/privileged",
      "type": "boolean"
    }
  ]
}

Available Containers

{
  "interface_name": "io.edgehog.devicemanager.apps.AvailableContainers",
  "version_major": 0,
  "version_minor": 1,
  "type": "properties",
  "ownership": "device",
  "mappings": [
    {
      "endpoint": "/%{container_id}/hostname",
      "type": "string"
    },
    {
      "endpoint": "/%{container_id}/imageId",
      "type": "string"
    },
    {
      "endpoint": "/%{container_id}/restartPolicy",
      "type": "string"
    },
    {
      "endpoint": "/%{container_id}/env",
      "type": "stringarray",
      "doc": "Array of KEY=value environment variables"
    },
    {
      "endpoint": "/%{container_id}/binds",
      "type": "stringarray",
      "doc": "Array of binds"
    },
    {
      "endpoint": "/%{container_id}/networks",
      "type": "stringarray"
    },
    {
      "endpoint": "/%{container_id}/portBindings",
      "type": "stringarray",
      "doc": "Array of ip:[host_port:]container_port[/protocol] | [hostPort:]containerPort[/protocol]. protocol is tcp by default"
    },
    {
      "endpoint": "/%{container_id}/privileged",
      "type": "boolean"
    },
    {
      "endpoint": "/%{container_id}/status",
      "type": "string"
    }
  ]
}

Container structure

Implements the following commands and functionalities for the container:

Update dependencies for MSRV

The message hub still doesn't support the MSRV 1.66.1, so we have conflicting dependencies for zbus and flate2, we would need to update those dependencies when the message hub has a release for the newer rust version.

[Docker] Create volume request

Create the structure to receive the CreateVolumeRequest and publish the AvailableVolumes property.

Interfaces

Create Volume Request

{
  "interface_name": "io.edgehog.devicemanager.apps.CreateVolumeRequest",
  "version_major": 0,
  "version_minor": 1,
  "type": "datastream",
  "ownership": "server",
  "aggregation": "object",
  "mappings": [
    {
      "endpoint": "/volume/id",
      "type": "string"
    },
    {
      "endpoint": "/volume/driver",
      "type": "string"
    },
    {
      "endpoint": "/volume/options",
      "type": "stringarray",
      "doc": "An array of key=value options to set for the drive"
    }
  ]
}

Available Volumes

{
  "interface_name": "io.edgehog.devicemanager.apps.AvailableVolumes",
  "version_major": 0,
  "version_minor": 1,
  "type": "properties",
  "ownership": "device",
  "mappings": [
    {
      "allow_unset": true,
      "endpoint": "/%{volume_id}/created",
      "type": "boolean"
    },
    {
      "allow_unset": true,
      "endpoint": "/%{volume_id}/driver",
      "type": "string"
    },
    {
      "allow_unset": true,
      "endpoint": "/%{volume_id}/options",
      "type": "stringarray",
      "doc": "An array of key=value options to set for the drive"
    }
  ]
}

Telemetry storage usage

The storage usage information returns the device name, on the interface the parameter is called label. We should define what this parameter should be if the device label is missing

Add uboot-sysdata support to the OTAUpdate

The OTA update of Edgehog OS not only uses Rauc for the update mechanism, but also needs to call a sysdata binary to switch on the right partition after reboot.

Since we don't want to bind to this mechanism, the ideal would be to wrap the sys-data binary in a Dbus-service and call it from the Runtime side.

fw_sysdata command info:

fw_sysdata -t switchslot -p -d /dev/mmcblk1

Switchslot - current state:
Boot from slot @: 00002
Boot from slot A: 00000
Current boot slot: A
Previous boot slot:
Consecutive fail boot: 0
Boot fail counter state: disabled

fw_sysdata command switch partition:

fw_sysdata -t switchslot -s -d /dev/mmcblk1

Switchslot: switch slot... OK (slot B)

Load Astarte Interfaces From a Canonical Path

Edgehog Device Manager should load interfaces from a "canonical installation path". Such as when installed to /usr/bin/ it should look for interfaces on /usr/share/edgehog-device-runtime/astarte-interfaces/ (or even /usr/share/edgehog/astarte-interfaces/).
When installation prefix is changed, it shoud behave accordingly (e.g. /usr/local/share/edgehog-device-runtime/astarte-interfaces/` etc...)

[Docker] Create image request

Create the structure to receive the CreateImageRequest and publish the AvailableImages property.

Create image request

{
  "interface_name": "io.edgehog.devicemanager.apps.CreateImageRequest",
  "version_major": 0,
  "version_minor": 1,
  "type": "datastream",
  "ownership": "server",
  "aggregation": "object",
  "mappings": [
    {
      "endpoint": "/image/id",
      "type": "string"
    },
    {
      "endpoint": "/image/repo",
      "type": "string"
    },
    {
      "endpoint": "/image/name",
      "type": "string"
    },
    {
      "endpoint": "/image/tag",
      "type": "string"
    }
  ]
}

Available Images

{
  "interface_name": "io.edgehog.devicemanager.apps.AvailableImages",
  "version_major": 0,
  "version_minor": 1,
  "type": "properties",
  "ownership": "device",
  "mappings": [
    {
      "allow_unset": true,
      "endpoint": "/%{image_id}/pulled",
      "type": "boolean"
    }
  ]
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.