thin-edge / thin-edge.io

The open edge framework for lightweight IoT devices
https://thin-edge.io
Apache License 2.0
221 stars 54 forks source link

Use Softwaretype according to new Advanced Software Management in 10.14 #1352

Closed mbay-ODW closed 9 months ago

mbay-ODW commented 2 years ago

Is your feature improvement request related to a problem? Please describe. The current Software plugin concept uses ::{type}} in the version. Since 10.14 the software type does exist which could/should be used.

image

andrej-schreiner commented 2 years ago

great suggestion, we will review this improvement and decide when to work on this

reubenmiller commented 1 year ago

Proposed changes

In Cumulocity 10.14, the software management concept was extended to included types (e.g. the .type property). At the time of the thin-edge.io software management support, this feature did not exist (or was very new at least), so the type information was previously encoded into the .version property in the format of <version>::<type>, e.g. 1.0.0::debian.

The software management mode should be configurable to control which sets of Cumulocity IoT SmartREST templates are used to either parse the software update operation, or to send the list of installed software to Cumulocity (via MQTT). The following lists the modes.

Note: If the software list is larger, then tedge falls back to sending the software list via the Cumulocity REST API instead of MQTT. The json body example is also shown for each mode.

Ideally the mode should be automatically detected during the mapper's initialisation where tedge-mapper-c8y queries the Cumulocity API endpoint to check the platform's version, and uses the returned value to set the software management mode accordingly.

GET /tenant/system/options/system/version

Response (version information is stored in .value)

{
  "category": "system",
  "key": "version",
  "value": "1017.187.0"
}

Mode 1: Software Management (Current implementation)

Action SmartREST 2.0 template
Set software list (REST API) {"c8y_SoftwareList":[{"name":"a","version":"1.0.0::debian","url":""}]}
Parse Operation 528

Mode 2: Advanced Software Management (New)

Action SmartREST 2.0 template
Set software list (REST API) {"c8y_SoftwareList":[{"name":"a","version":"1.0.0","type":"debian","url":""}]}
Parse Operation 529

In addition to sending the software list, thin-edge.io needs to report the supported software types (currently there is not a SmartREST template to set this, so it will need to be sent via the REST API (using the same api as the software list update is sending).

Example: API to update the supported software types

Endpoint/method

POST /inventory/managedObjects/{id}

Body

{"c8y_SupportedSoftwareTypes": ["apt", "docker"]}
reubenmiller commented 9 months ago

thin-edge.io now supports official software types meaning you no longer need to encode the type into the version!

The system tests have been updated to use the official software type field:

But basically manual testing steps are:

  1. Create software item in Cumulocity IoT => Software Repository with a given type
  2. Add a version (don't use the ::{type} as it is not necessary anymore)
  3. Install the software via the device's software page
gligorisaev commented 9 months ago

QA has thoroughly checked the feature and here are the results: