Closed albinsuresh closed 2 years ago
I see things we should add to the scope:
c8y-configuration-plugin
loads the provided config file list for a child-device from a child-devices individual TOML filec8y-configuration-plugin
loads the TOML file, the c8y-configuration-plugin
creates the folder /etc/tedge/operations/c8y/<child-id>
and creates the supported operations files c8y_UploadConfigFile
and c8y_DownloadConfigFile
in that folderchild-id
c8y-configuration-plugin
loads the TOML file, the c8y-configuration-plugin
sends the provided configuration types defined in the child-devices TOML file to the clouds child-device twin.Also things to add to "out of scope":
I see things we should add to the scope:
- The
c8y-configuration-plugin
loads the provided config file list for a child-device from a child-devices individual TOML file- Whenever the
c8y-configuration-plugin
loads the TOML file, thec8y-configuration-plugin
creates the folder/etc/tedge/operations/c8y/<child-id>
and creates the supported operations filesc8y_UploadConfigFile
andc8y_DownloadConfigFile
in that folder- The supported operations API accepts supported operations in a subfolder and delcares corresponding supported operation to the clouds child-device twin, using the subfolder name as
child-id
- Whenever the
c8y-configuration-plugin
loads the TOML file, thec8y-configuration-plugin
sends the provided configuration types defined in the child-devices TOML file to the clouds child-device twin.Also things to add to "out of scope":
- Announcing list of supported configuration files by the child-device itself (to the plugin via MQTT)
The first item has been pulled into the scope of this story. The rest of the items are more about child device provisioning and hence, would be addressed in #1336.
This test requires a child device.
The child device should have a configuration file like this:
files = [
{ path = '/home/user/Desktop/file_a', type = 'file_a' },
]
The child device also requires a script that communicates with the parent device via MQTT and HTTP. An example script can be found in thin-edge.io_spikes.
Tests should cover:
On the child device:
Topic: tedge/<CHILD-ID>/commands/res/config_snapshot
Payload (json string): { "status": None, "path": "", "type":c8y-configuration-plugin, "reason": None}
Topic: [c8y/s/us/<child-id>]
Payload: 114,c8y_UploadConfigFile,c8y_DownloadConfigFile
On the cloud you should see a new device created, with configuration management enabled.
this assumes the child device has already been bootstrapped.
- From the cloud trigger a configuration snapshot for "file_a"
- On receiving the following mqtt message from the parent device:
Topic: [tedge/<child-id>/commands/req/config_snapshot]
Payload: {"url":"http://127.0.0.1:80/tedge/file-transfer/<child-id>/config_snapshot/<file-type>","path":"/path/to/file","type":"<file-type>"}
The child device should send an executing back:
Topic: [tedge/<child-id>/commands/res/config_snapshot]
Payload: {"status": "executing", "path": "/path/to/file", "type": "<file-type>", "reason": null}
Topic: [tedge/<child-id>/commands/res/config_snapshot]
Payload: {"status": "successful", "path": "/path/to/file", "type": "<file-type>", "reason": null}
this assumes the child device has already been bootstrapped.
Topic: [tedge/<child-id>/commands/req/config_update]
Payload: {"url":"http://ADDRESS:80/tedge/file-transfer/<child-id>/config_snapshot/<file-type>","path":"/path/to/file","type":"<file-type>"}
The child device should send an executing back:
Topic: [tedge/<child-id>/commands/res/config_update]
Payload: {"status": "executing", "path": "/path/to/file", "type": "<file-type>", "reason": null}
Topic: [tedge/<child-id>/commands/res/config_snapshot]
Payload: {"status": "successful", "path": "/path/to/file", "type": "<file-type>", "reason": null}
Parent device:
sudo tedge config set mqtt.external.bind_address <PARENT IP>
sudo tedge config set mqtt.external.port 1883
sudo tedge disconnect c8y
sudo tedge connect c8y
sudo systemctl start c8y-configuration-plugin.service
Child device
sudo apt-get install mosquitto -y
sudo apt-get install mosquitto mosquitto-clients -y
On child device
printf 'files = [\n '\%3s' { path = '/home/pi/file_a', type = 'file_a' },\n ]\n' > c8y-configuration-plugin
printf "files = [\n\t { path = '/home/pi/file_a', type = 'file_a' },\n ]\n" > c8y-configuration-plugin
curl -X PUT http://<PARENT IP>:80/tedge/file-transfer/<CHILD ID>/c8y-configuration-plugin \
--data-binary @- << EOF
files = [
{ path = '/home/pi/tedge/file_a', type = 'file_a' },
]
EOF`mosquitto_pub -h <PARENT IP> -t "tedge/<CHILD ID>/commands/res/config_snapshot" -m '{ "status": null, "path": "", "type":"c8y-configuration-plugin", "reason": null}'
mosquitto_pub -h <PARENT IP> -t "c8y/s/us/<CHILD ID>" -m "114,c8y_UploadConfigFile,c8y_DownloadConfigFile"
On Parent Device
sudo systemctl restart tedge-mapper-c8y.service
tedge/<CHILD_ID>/commands/req/config_snapshot
On Cumulocity IoT
Go to: Device Management > Devices > All Devices > Choose your parent device > Child devices
Confirm that child device MQTT Device <CHILD ID>
is listed
MQTT Device <CHILD ID>
Configuration
file_a
that is located in the Configurations
tabClick on Get snapshot from device
Result: Observe on parent device listener that following message is arrived:
[c8y/s/ds] 526,<CHILD ID>,file_a
and following message is sent to the child device
[tedge/<CHILD ID>/commands/req/config_snapshot] {"url":"http://<PARENT IP>:80/tedge/file-transfer/<CHILD ID>/config_snapshot/file_a","path":"/home/pi/tedge/file_a","type":"file_a"}
On child device
mosquitto_pub -h <PARENT IP> -t "tedge/${CHILD_ID}/commands/res/config_snapshot" -m '{"status": "executing", "path": "/home/pi", "type": "file_a", "reason": null}'
curl -X PUT -d "test of put" http://<PARENT IP>:80/tedge/file-transfer/<CHILD ID>/config_snapshot/file_a
mosquitto_pub -h <PARENT IP> -t "tedge/<CHILD ID>/commands/res/config_snapshot" -m '{"status": "successful", "path": "/home/pi", "type": "file_a", "reason": null}'
file_a
that is located in the Configurations
tabClick on Send configuration to device
Result: Result: Observe on parent device listener that following message is arrived:
[c8y/s/ds] 524,<CHILD ID>,file_a
and following message is sent to the child device
[tedge/<CHILD ID>/commands/req/config_update] {"url":"http://<PARENT IP>:80/tedge/file-transfer/<CHILD ID>/config_snapshot/file_a","path":"/home/pi/tedge/file_a","type":"file_a"}
On child device
mosquitto_pub -h <PARENT IP> -t "tedge/${CHILD_ID}/commands/res/config_update" -m '{"status": "executing", "path": "/home/pi", "type": "file_a", "reason": null}'
curl http://<PARENT IP>:80/tedge/file-transfer/<CHILD ID>/config_update/file_a
mosquitto_pub -h <PARENT IP> -t "tedge/<CHILD ID>/commands/res/config_update" -m '{"status": "successful", "path": "/home/pi", "type": "file_a", "reason": null}'
QA check passed, therefore close this issue.
Is your feature request related to a problem? Please describe.
Support the following config management operations on child devices:
Describe the solution you'd like
Implement the config management solution for child devices described in: https://github.com/thin-edge/thin-edge.io/pull/1236
c8y-configuration-plugin
to mapc8y_ConfigUpload
requests (SmartREST 526) totedge/<child-id>/commands/req/config_snapshot
requests and deliver it to the appropriate child devicec8y_ConfigDownload
requests (SmartREST 524) totedge/<child-id>/commands/req/config_update
requests and deliver it to the appropriate child deviceconfig_update
operation) as well as the file uploaded by the child devices forconfig_snapshot
operation.Out of scope