From a76179042ef37dd9fb5fb4e043c8989937af1f31 Mon Sep 17 00:00:00 2001 From: Marcel Guzik Date: Wed, 4 Dec 2024 20:27:25 +0100 Subject: [PATCH 01/10] Create a module with smartrest message ids consts Signed-off-by: Marcel Guzik --- .../core/c8y_api/src/smartrest/message_ids.rs | 107 ++++++++++++++++++ crates/core/c8y_api/src/smartrest/mod.rs | 1 + 2 files changed, 108 insertions(+) create mode 100644 crates/core/c8y_api/src/smartrest/message_ids.rs diff --git a/crates/core/c8y_api/src/smartrest/message_ids.rs b/crates/core/c8y_api/src/smartrest/message_ids.rs new file mode 100644 index 00000000000..a1d6157346f --- /dev/null +++ b/crates/core/c8y_api/src/smartrest/message_ids.rs @@ -0,0 +1,107 @@ +//! Definitions of Smartrest MQTT message ids. +//! +//! - https://cumulocity.com/docs/smartrest/smartrest-one/#built-in-messages +//! - https://cumulocity.com/docs/smartrest/mqtt-static-templates/ + +// Message IDs + +pub const ERROR: usize = 41; +pub const JWT_TOKEN: usize = 71; + +// Static templates + +// Publish templates + +// Inventory templates (1xx) + +pub const DEVICE_CREATION: usize = 100; +pub const CHILD_DEVICE_CREATION: usize = 101; +pub const SERVICE_CREATION: usize = 102; +pub const SERVICE_STATUS_UPDATE: usize = 104; +pub const GET_CHILD_DEVICES: usize = 105; +pub const CLEAR_DEVICE_FRAGMENT: usize = 107; +pub const CONFIGURE_HARDWARE: usize = 110; +pub const CONFIGURE_MOBILE: usize = 111; +pub const CONFIGURE_POSITION: usize = 112; +pub const SET_CONFIGURATION: usize = 113; +pub const SET_SUPPORTED_OPERATIONS: usize = 114; +pub const SET_FIRMWARE: usize = 115; +pub const SET_SOFTWARE_LIST: usize = 116; +pub const SET_REQUIRED_AVAILABILITY: usize = 117; +pub const SET_SUPPORTED_LOGS: usize = 118; +pub const SET_SUPPORTED_CONFIGURATIONS: usize = 119; +pub const SET_CURRENTLY_INSTALLED_CONFIGURATION: usize = 120; +pub const SET_DEVICE_PROFILE_THAT_IS_BEING_APPLIED: usize = 121; +pub const SET_DEVICE_AGENT_INFORMATION: usize = 122; +pub const GET_DEVICE_MANAGED_OBJECT_ID: usize = 123; +pub const SEND_HEARTBEAT: usize = 125; +pub const SET_ADVANCED_SOFTWARE_LIST: usize = 140; +pub const APPEND_ADVANCED_SOFTWARE_ITEMS: usize = 141; +pub const REMOVE_ADVANCED_SOFTWARE_ITEMS: usize = 142; +pub const SET_SUPPORTED_SOFTWARE_TYPES: usize = 143; +pub const SET_CLOUD_REMOTE_ACCESS: usize = 150; + +// Measurement templates (2xx) + +pub const CREATE_CUSTOM_MEASUREMENT: usize = 200; +pub const CREATE_A_CUSTOM_MEASUREMENT_WITH_MULTIPLE_FRAGMENTS_AND_SERIES: usize = 201; +pub const CREATE_SIGNAL_STRENGTH_MEASUREMENT: usize = 210; +pub const CREATE_TEMPERATURE_MEASUREMENT: usize = 211; +pub const CREATE_BATTERY_MEASUREMENT: usize = 212; + +// Alarm templates (3xx) + +pub const CREATE_CRITICAL_ALARM: usize = 301; +pub const CREATE_MAJOR_ALARM: usize = 302; +pub const CREATE_MINOR_ALARM: usize = 303; +pub const CREATE_WARNING_ALARM: usize = 304; +pub const UPDATE_SEVERITY_OF_EXISTING_ALARM: usize = 305; +pub const CLEAR_EXISTING_ALARM: usize = 306; +pub const CLEAR_ALARM_FRAGMENT: usize = 307; + +// Event templates (4xx) + +pub const CREATE_BASIC_EVENT: usize = 400; +pub const CREATE_LOCATION_UPDATE_EVENT: usize = 401; +pub const CREATE_LOCATION_UPDATE_EVENT_WITH_DEVICE_UPDATE: usize = 402; +pub const CLEAR_EVENT_FRAGMENT: usize = 407; + +// Operation templates (5xx) + +pub const GET_PENDING_OPERATIONS: usize = 500; +pub const SET_OPERATION_TO_EXECUTING: usize = 501; +pub const SET_OPERATION_TO_FAILED: usize = 502; +pub const SET_OPERATION_TO_SUCCESSFUL: usize = 503; +pub const SET_OPERATION_TO_EXECUTING_ID: usize = 504; +pub const SET_OPERATION_TO_FAILED_ID: usize = 505; +pub const SET_OPERATION_TO_SUCCESSFUL_ID: usize = 506; +pub const SET_EXECUTING_OPERATIONS_TO_FAILED: usize = 507; + +// Subscribe templates + +// Inventory templates (1xx) + +pub const GET_CHILDREN_OF_DEVICE: usize = 106; +pub const GET_DEVICE_MANAGED_OBJECT_ID_RESPONSE: usize = 124; + +// Operation templates (5xx) + +pub const RESTART: usize = 510; +pub const COMMAND: usize = 511; +pub const CONFIGURATION: usize = 513; +pub const FIRMWARE: usize = 515; +pub const SOFTWARE_LIST: usize = 516; +pub const MEASUREMENT_REQUEST_OPERATION: usize = 517; +pub const RELAY: usize = 518; +pub const RELAY_ARRAY: usize = 519; +pub const UPLOAD_CONFIGURATION_FILE: usize = 520; +pub const DOWNLOAD_CONFIGURATION_FILE: usize = 521; +pub const LOGFILE_REQUEST: usize = 522; +pub const COMMUNICATION_MODE: usize = 523; +pub const DOWNLOAD_CONFIGURATION_FILE_WITH_TYPE: usize = 524; +pub const FIRMWARE_FROM_PATCH: usize = 525; +pub const UPLOAD_CONFIGURATION_FILE_WITH_TYPE: usize = 526; +pub const SET_DEVICE_PROFILES: usize = 527; +pub const UPDATE_SOFTWARE: usize = 528; +pub const UPDATE_ADVANCED_SOFTWARE: usize = 529; +pub const CLOUD_REMOTE_ACCESS_CONNECT: usize = 530; diff --git a/crates/core/c8y_api/src/smartrest/mod.rs b/crates/core/c8y_api/src/smartrest/mod.rs index 6bf38f3e77c..03525ad3bb5 100644 --- a/crates/core/c8y_api/src/smartrest/mod.rs +++ b/crates/core/c8y_api/src/smartrest/mod.rs @@ -3,6 +3,7 @@ pub mod csv; pub mod error; pub mod inventory; pub mod message; +pub mod message_ids; pub mod payload; pub mod smartrest_deserializer; pub mod smartrest_serializer; From d26826b33e1c99893d90487bcd9c86c673e1258d Mon Sep 17 00:00:00 2001 From: reubenmiller Date: Sat, 7 Dec 2024 17:11:08 +0100 Subject: [PATCH 02/10] feat: add c8y createBulk topics to bridge --- crates/core/tedge/src/bridge/c8y.rs | 9 ++++ crates/core/tedge_mapper/src/c8y/mapper.rs | 7 +++ .../telemetry/child_device_telemetry.robot | 43 +++++++++++++++++++ .../thin-edge_device_telemetry.robot | 43 +++++++++++++++++++ ...dge_device_telemetry_built-in_bridge.robot | 43 +++++++++++++++++++ 5 files changed, 145 insertions(+) diff --git a/crates/core/tedge/src/bridge/c8y.rs b/crates/core/tedge/src/bridge/c8y.rs index 766db61e0ef..615eef0b13b 100644 --- a/crates/core/tedge/src/bridge/c8y.rs +++ b/crates/core/tedge/src/bridge/c8y.rs @@ -72,8 +72,11 @@ impl From for BridgeConfig { // c8y JSON format!(r#"inventory/managedObjects/update/# out 1 {topic_prefix}/ """#), format!(r#"measurement/measurements/create out 1 {topic_prefix}/ """#), + format!(r#"measurement/measurements/createBulk out 1 {topic_prefix}/ """#), format!(r#"event/events/create out 1 {topic_prefix}/ """#), + format!(r#"event/events/createBulk out 1 {topic_prefix}/ """#), format!(r#"alarm/alarms/create out 1 {topic_prefix}/ """#), + format!(r#"alarm/alarms/createBulk out 1 {topic_prefix}/ """#), format!(r#"devicecontrol/notifications in 1 {topic_prefix}/ """#), format!(r#"error in 1 {topic_prefix}/ """#), ]; @@ -278,8 +281,11 @@ mod tests { // c8y JSON r#"inventory/managedObjects/update/# out 1 c8y/ """#.into(), r#"measurement/measurements/create out 1 c8y/ """#.into(), + r#"measurement/measurements/createBulk out 1 c8y/ """#.into(), r#"event/events/create out 1 c8y/ """#.into(), + r#"event/events/createBulk out 1 c8y/ """#.into(), r#"alarm/alarms/create out 1 c8y/ """#.into(), + r#"alarm/alarms/createBulk out 1 c8y/ """#.into(), r#"devicecontrol/notifications in 1 c8y/ """#.into(), r#"error in 1 c8y/ """#.into(), // c8y JWT token retrieval @@ -369,8 +375,11 @@ mod tests { // c8y JSON r#"inventory/managedObjects/update/# out 1 c8y/ """#.into(), r#"measurement/measurements/create out 1 c8y/ """#.into(), + r#"measurement/measurements/createBulk out 1 c8y/ """#.into(), r#"event/events/create out 1 c8y/ """#.into(), + r#"event/events/createBulk out 1 c8y/ """#.into(), r#"alarm/alarms/create out 1 c8y/ """#.into(), + r#"alarm/alarms/createBulk out 1 c8y/ """#.into(), r#"devicecontrol/notifications in 1 c8y/ """#.into(), r#"error in 1 c8y/ """#.into(), // Important: no c8y JWT token topics! diff --git a/crates/core/tedge_mapper/src/c8y/mapper.rs b/crates/core/tedge_mapper/src/c8y/mapper.rs index c127444ca09..b0b33e6df2b 100644 --- a/crates/core/tedge_mapper/src/c8y/mapper.rs +++ b/crates/core/tedge_mapper/src/c8y/mapper.rs @@ -127,8 +127,15 @@ impl TEdgeComponent for CumulocityMapper { local_prefix.clone(), "", )?; + tc.forward_from_local( + "measurement/measurements/createBulk/#", + local_prefix.clone(), + "", + )?; tc.forward_from_local("event/events/create/#", local_prefix.clone(), "")?; + tc.forward_from_local("event/events/createBulk/#", local_prefix.clone(), "")?; tc.forward_from_local("alarm/alarms/create/#", local_prefix.clone(), "")?; + tc.forward_from_local("alarm/alarms/createBulk/#", local_prefix.clone(), "")?; // JWT token if use_certificate { diff --git a/tests/RobotFramework/tests/cumulocity/telemetry/child_device_telemetry.robot b/tests/RobotFramework/tests/cumulocity/telemetry/child_device_telemetry.robot index c10405285db..a390c181768 100644 --- a/tests/RobotFramework/tests/cumulocity/telemetry/child_device_telemetry.robot +++ b/tests/RobotFramework/tests/cumulocity/telemetry/child_device_telemetry.robot @@ -181,6 +181,49 @@ Child device supports sending custom child device measurements directly to c8y Should Be Equal ${measurements[0]["meta"]["sensorLocation"]} Brisbane, Australia Should Be Equal ${measurements[0]["type"]} 10min_average +Thin-edge device supports sending custom bulk measurements directly to c8y + Execute Command + ... tedge mqtt pub "c8y/measurement/measurements/createBulk" '{"measurements":[{"time":"2024-12-01T02:00:00Z","externalSource":{"externalId":"${CHILD_SN}","type":"c8y_Serial"},"outside":{"temperature":{"value":2.5,"unit":"°C"}},"type":"1min_average"},{"time":"2024-12-01T02:01:00Z","externalSource":{"externalId":"${CHILD_SN}","type":"c8y_Serial"},"outside":{"temperature":{"value":3.5,"unit":"°C"}},"type":"1min_average"}]}' + Cumulocity.Set Device ${CHILD_SN} + ${measurements}= Device Should Have Measurements + ... minimum=2 + ... maximum=2 + ... value=outside + ... series=temperature + ... type=1min_average + Should Be Equal As Numbers ${measurements[0]["outside"]["temperature"]["value"]} 2.5 + Should Be Equal As Numbers ${measurements[1]["outside"]["temperature"]["value"]} 3.5 + Should Be Equal ${measurements[0]["type"]} 1min_average + Should Be Equal ${measurements[1]["type"]} 1min_average + +Thin-edge device supports sending custom bulk events directly to c8y + Execute Command + ... tedge mqtt pub "c8y/event/events/createBulk" '{"events":[{"time":"2024-12-01T02:00:00Z","externalSource":{"externalId":"${CHILD_SN}","type":"c8y_Serial"},"text":"event 1","type":"bulkevent"},{"time":"2024-12-01T02:01:00Z","externalSource":{"externalId":"${CHILD_SN}","type":"c8y_Serial"},"text":"event 2","type":"bulkevent"}]}' + Cumulocity.Set Device ${CHILD_SN} + ${events}= Device Should Have Event/s + ... minimum=2 + ... maximum=2 + ... type=bulkevent + Should Be Equal As Strings ${events[0]["text"]} event 2 + Should Be Equal As Strings ${events[1]["text"]} event 1 + Should Be Equal ${events[0]["type"]} bulkevent + Should Be Equal ${events[1]["type"]} bulkevent + +Thin-edge device supports sending custom bulk alarms directly to c8y + Execute Command + ... tedge mqtt pub "c8y/alarm/alarms/createBulk" '{"alarms":[{"time":"2024-12-01T02:00:00Z","externalSource":{"externalId":"${CHILD_SN}","type":"c8y_Serial"},"text":"alarm 1","severity":"MAJOR","type":"bulkalarm1"},{"time":"2024-12-01T02:01:00Z","externalSource":{"externalId":"${CHILD_SN}","type":"c8y_Serial"},"text":"alarm 2","severity":"MINOR","type":"bulkalarm2"}]}' + Cumulocity.Set Device ${CHILD_SN} + ${alarms}= Device Should Have Alarm/s + ... minimum=2 + ... maximum=2 + ... type=bulkalarm1,bulkalarm2 + Should Be Equal As Strings ${alarms[0]["text"]} alarm 2 + Should Be Equal As Strings ${alarms[1]["text"]} alarm 1 + Should Be Equal As Strings ${alarms[0]["severity"]} MINOR + Should Be Equal As Strings ${alarms[1]["severity"]} MAJOR + Should Be Equal ${alarms[0]["type"]} bulkalarm2 + Should Be Equal ${alarms[1]["type"]} bulkalarm1 + Nested child devices support sending inventory data via tedge topic ${nested_child}= Get Random Name Execute Command diff --git a/tests/RobotFramework/tests/cumulocity/telemetry/thin-edge_device_telemetry.robot b/tests/RobotFramework/tests/cumulocity/telemetry/thin-edge_device_telemetry.robot index f3d48307a53..545915150e1 100644 --- a/tests/RobotFramework/tests/cumulocity/telemetry/thin-edge_device_telemetry.robot +++ b/tests/RobotFramework/tests/cumulocity/telemetry/thin-edge_device_telemetry.robot @@ -217,6 +217,49 @@ Thin-edge device supports sending custom Thin-edge device measurements directly Should Be Equal ${measurements[0]["meta"]["sensorLocation"]} Brisbane, Australia Should Be Equal ${measurements[0]["type"]} 10min_average +Thin-edge device supports sending custom bulk measurements directly to c8y + Execute Command + ... tedge mqtt pub "c8y/measurement/measurements/createBulk" '{"measurements":[{"time":"2024-12-01T02:00:00Z","outside":{"temperature":{"value":2.5,"unit":"°C"}},"type":"1min_average"},{"time":"2024-12-01T02:01:00Z","outside":{"temperature":{"value":3.5,"unit":"°C"}},"type":"1min_average"}]}' + Cumulocity.Set Device ${DEVICE_SN} + ${measurements}= Device Should Have Measurements + ... minimum=2 + ... maximum=2 + ... value=outside + ... series=temperature + ... type=1min_average + Should Be Equal As Numbers ${measurements[0]["outside"]["temperature"]["value"]} 2.5 + Should Be Equal As Numbers ${measurements[1]["outside"]["temperature"]["value"]} 3.5 + Should Be Equal ${measurements[0]["type"]} 1min_average + Should Be Equal ${measurements[1]["type"]} 1min_average + +Thin-edge device supports sending custom bulk events directly to c8y + Execute Command + ... tedge mqtt pub "c8y/event/events/createBulk" '{"events":[{"time":"2024-12-01T02:00:00Z","text":"event 1","type":"bulkevent"},{"time":"2024-12-01T02:01:00Z","text":"event 2","type":"bulkevent"}]}' + Cumulocity.Set Device ${DEVICE_SN} + ${events}= Device Should Have Event/s + ... minimum=2 + ... maximum=2 + ... type=bulkevent + Should Be Equal As Strings ${events[0]["text"]} event 2 + Should Be Equal As Strings ${events[1]["text"]} event 1 + Should Be Equal ${events[0]["type"]} bulkevent + Should Be Equal ${events[1]["type"]} bulkevent + +Thin-edge device supports sending custom bulk alarms directly to c8y + Execute Command + ... tedge mqtt pub "c8y/alarm/alarms/createBulk" '{"alarms":[{"time":"2024-12-01T02:00:00Z","text":"alarm 1","severity":"MAJOR","type":"bulkalarm1"},{"time":"2024-12-01T02:01:00Z","text":"alarm 2","severity":"MINOR","type":"bulkalarm2"}]}' + Cumulocity.Set Device ${DEVICE_SN} + ${alarms}= Device Should Have Alarm/s + ... minimum=2 + ... maximum=2 + ... type=bulkalarm1,bulkalarm2 + Should Be Equal As Strings ${alarms[0]["text"]} alarm 2 + Should Be Equal As Strings ${alarms[1]["text"]} alarm 1 + Should Be Equal As Strings ${alarms[0]["severity"]} MINOR + Should Be Equal As Strings ${alarms[1]["severity"]} MAJOR + Should Be Equal ${alarms[0]["type"]} bulkalarm2 + Should Be Equal ${alarms[1]["type"]} bulkalarm1 + Thin-edge device support sending inventory data via c8y topic Execute Command ... tedge mqtt pub "c8y/inventory/managedObjects/update/${DEVICE_SN}" '{"parentInfo":{"nested":{"name":"complex"}},"subType":"customType"}' diff --git a/tests/RobotFramework/tests/cumulocity/telemetry/thin-edge_device_telemetry_built-in_bridge.robot b/tests/RobotFramework/tests/cumulocity/telemetry/thin-edge_device_telemetry_built-in_bridge.robot index fa2e9f9356c..b1cc16a5d94 100644 --- a/tests/RobotFramework/tests/cumulocity/telemetry/thin-edge_device_telemetry_built-in_bridge.robot +++ b/tests/RobotFramework/tests/cumulocity/telemetry/thin-edge_device_telemetry_built-in_bridge.robot @@ -244,6 +244,49 @@ Thin-edge device supports sending custom Thin-edge device measurements directly Should Be Equal ${measurements[0]["meta"]["sensorLocation"]} Brisbane, Australia Should Be Equal ${measurements[0]["type"]} 10min_average +Thin-edge device supports sending custom bulk measurements directly to c8y + Execute Command + ... tedge mqtt pub "${C8Y_TOPIC_PREFIX}/measurement/measurements/createBulk" '{"measurements":[{"time":"2024-12-01T02:00:00Z","outside":{"temperature":{"value":2.5,"unit":"°C"}},"type":"1min_average"},{"time":"2024-12-01T02:01:00Z","outside":{"temperature":{"value":3.5,"unit":"°C"}},"type":"1min_average"}]}' + Cumulocity.Set Device ${DEVICE_SN} + ${measurements}= Device Should Have Measurements + ... minimum=2 + ... maximum=2 + ... value=outside + ... series=temperature + ... type=1min_average + Should Be Equal As Numbers ${measurements[0]["outside"]["temperature"]["value"]} 2.5 + Should Be Equal As Numbers ${measurements[1]["outside"]["temperature"]["value"]} 3.5 + Should Be Equal ${measurements[0]["type"]} 1min_average + Should Be Equal ${measurements[1]["type"]} 1min_average + +Thin-edge device supports sending custom bulk events directly to c8y + Execute Command + ... tedge mqtt pub "${C8Y_TOPIC_PREFIX}/event/events/createBulk" '{"events":[{"time":"2024-12-01T02:00:00Z","text":"event 1","type":"bulkevent"},{"time":"2024-12-01T02:01:00Z","text":"event 2","type":"bulkevent"}]}' + Cumulocity.Set Device ${DEVICE_SN} + ${events}= Device Should Have Event/s + ... minimum=2 + ... maximum=2 + ... type=bulkevent + Should Be Equal As Strings ${events[0]["text"]} event 2 + Should Be Equal As Strings ${events[1]["text"]} event 1 + Should Be Equal ${events[0]["type"]} bulkevent + Should Be Equal ${events[1]["type"]} bulkevent + +Thin-edge device supports sending custom bulk alarms directly to c8y + Execute Command + ... tedge mqtt pub "${C8Y_TOPIC_PREFIX}/alarm/alarms/createBulk" '{"alarms":[{"time":"2024-12-01T02:00:00Z","text":"alarm 1","severity":"MAJOR","type":"bulkalarm1"},{"time":"2024-12-01T02:01:00Z","text":"alarm 2","severity":"MINOR","type":"bulkalarm2"}]}' + Cumulocity.Set Device ${DEVICE_SN} + ${alarms}= Device Should Have Alarm/s + ... minimum=2 + ... maximum=2 + ... type=bulkalarm1,bulkalarm2 + Should Be Equal As Strings ${alarms[0]["text"]} alarm 2 + Should Be Equal As Strings ${alarms[1]["text"]} alarm 1 + Should Be Equal As Strings ${alarms[0]["severity"]} MINOR + Should Be Equal As Strings ${alarms[1]["severity"]} MAJOR + Should Be Equal ${alarms[0]["type"]} bulkalarm2 + Should Be Equal ${alarms[1]["type"]} bulkalarm1 + Thin-edge device support sending inventory data via c8y topic Execute Command ... tedge mqtt pub "${C8Y_TOPIC_PREFIX}/inventory/managedObjects/update/${DEVICE_SN}" '{"parentInfo":{"nested":{"name":"complex"}},"subType":"customType"}' From fd69121c7450b843bdf821fa31a14d594aae7cb1 Mon Sep 17 00:00:00 2001 From: reubenmiller Date: Sat, 7 Dec 2024 19:30:22 +0100 Subject: [PATCH 03/10] remove draft warnings as design has been finalized --- docs/src/references/agent/operation-workflow.md | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/docs/src/references/agent/operation-workflow.md b/docs/src/references/agent/operation-workflow.md index b812ad393ba..9e9ef954c42 100644 --- a/docs/src/references/agent/operation-workflow.md +++ b/docs/src/references/agent/operation-workflow.md @@ -349,11 +349,7 @@ Note that: - No `on_exit` nor `on_kill` status can be provided, as the script is not monitored. - If the script cannot be launched, the workflow will be moved to the final `"failed"` state. -### 🚧 Sub-Operation Execution {#sub-operation-execution} - -:::info -🚧 The syntax for triggering other workflows from an existing workflow is still being finalized so please avoid using it in production environments. -::: +### Sub-Operation Execution {#sub-operation-execution} An operation workflow can trigger a command defined by another workflow. @@ -580,11 +576,7 @@ on_success = "scheduled" on_error = { status = "failed", reason = "not timely" } ``` -### 🚧 Customizing builtin operations - -:::info -🚧 The syntax for customizing builtin workflows is still being finalized so please avoid using it in production environments. -::: +### Customizing builtin operations __tedge-agent__ supports out-of-the-box a set of so-called builtin operations: `software_list`, `software_update`, `restart`, `config_snapshot`, `config_update`, `log_upload`. From 2691d1df3fe944154d8b2c0aac51d8d922296505 Mon Sep 17 00:00:00 2001 From: reubenmiller Date: Sat, 7 Dec 2024 19:33:50 +0100 Subject: [PATCH 04/10] fix typo --- docs/src/references/agent/operation-workflow.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/references/agent/operation-workflow.md b/docs/src/references/agent/operation-workflow.md index 9e9ef954c42..a1771b38ae9 100644 --- a/docs/src/references/agent/operation-workflow.md +++ b/docs/src/references/agent/operation-workflow.md @@ -604,7 +604,7 @@ For each, there are *two* workflows: an internal workflow and a customized versi with a step triggering `operation = "builtin:"`. - A customized workflow can also be a complete rework of the feature, ignoring the builtin behavior. - However, the builtin behavior can only be invoked from the workflow for the same operation - (e.g. `builtin:sofware_update` can only be invoked from `sofware_update`). + (e.g. `builtin:software_update` can only be invoked from `software_update`). In order to customize a builtin operation, the first step is to materialize its definition in `/etc/tedge/operations`. For instance, here is the builtin workflow for the `software_update` operation: From bd5f565a3bc5027252f09f05e7e5c1ea1352f965 Mon Sep 17 00:00:00 2001 From: reubenmiller Date: Sat, 7 Dec 2024 19:40:17 +0100 Subject: [PATCH 05/10] normalize usage of builtin --- docs/src/references/agent/operation-workflow.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/src/references/agent/operation-workflow.md b/docs/src/references/agent/operation-workflow.md index a1771b38ae9..fef67e0aa58 100644 --- a/docs/src/references/agent/operation-workflow.md +++ b/docs/src/references/agent/operation-workflow.md @@ -206,7 +206,7 @@ when a state message is published for a command on a topic matching the global t i.e. `te/+/+/+/+/cmd/+/+`. - Each running instance of the __tedge_agent__ reacts only on commands targeting its own device. - If a user-defined workflow has been defined for this operation, then this workflow is used to determine the required action. -- If no workflow has been defined by the user for this operation, then the built-in workflow is used. +- If no workflow has been defined by the user for this operation, then the builtin workflow is used. - If there is no workflow or no defined action for the current state, then the __tedge_agent__ simply waits for another component to take over the command. @@ -610,14 +610,14 @@ In order to customize a builtin operation, the first step is to materialize its For instance, here is the builtin workflow for the `software_update` operation: ```toml title="/etc/tedge/operations/software_update.toml" -operation = "software_update" # any builtion operation can be customized +operation = "software_update" # any builtin operation can be customized ["init"] action = "proceed" # open to customization on_success = "scheduled" [scheduled] -operation = "builtin:software_update" # trigger the built-in behavior for software update +operation = "builtin:software_update" # trigger the builtin behavior for software update on_exec = "executing" [executing] @@ -648,7 +648,7 @@ on_success = "scheduled" on_error = { status = "failed", reason = "not timely" } [scheduled] -operation = "builtin:software_update" # trigger the built-in behavior for software update +operation = "builtin:software_update" # trigger the builtin behavior for software update on_success = "executing" [executing] From 9a9a065889d44870568b6dbfa64f9b5de2cd5c54 Mon Sep 17 00:00:00 2001 From: reubenmiller Date: Sun, 8 Dec 2024 11:19:17 +0100 Subject: [PATCH 06/10] dev: update code owners --- .github/CODEOWNERS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 3b0231a5193..565db07e128 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -11,12 +11,12 @@ justfile @thin-edge/contributors @thin-edge/inetum-contributors /.github/ @reubenmiller @Bravo555 @rina23q # Documentation -/docs/ @reubenmiller @didier-wenzek @gligorisaev +/docs/ @reubenmiller @didier-wenzek /design/ @reubenmiller @didier-wenzek @albinsuresh /images/ @reubenmiller @didier-wenzek # Testing -/tests/ @thin-edge/contributors @gligorisaev +/tests/ @thin-edge/contributors # Packaging / Misc. contribution (e.g. config files) /configuration/ @reubenmiller @rina23q From eb4663d3554f15cec0ead6d6a916e0fa207a45cc Mon Sep 17 00:00:00 2001 From: Marcel Guzik Date: Mon, 9 Dec 2024 17:21:47 +0100 Subject: [PATCH 07/10] chore: update url crate due to RUSTSEC-2024-0421 Signed-off-by: Marcel Guzik --- Cargo.lock | 287 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 255 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3a1e31e7a7d..a892f35c808 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -126,7 +126,7 @@ dependencies = [ "proc-macro2", "quote", "syn 1.0.109", - "synstructure", + "synstructure 0.12.6", ] [[package]] @@ -1840,6 +1840,124 @@ dependencies = [ "tokio", ] +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -1848,12 +1966,23 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.5.0" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "icu_normalizer", + "icu_properties", ] [[package]] @@ -2027,6 +2156,12 @@ version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +[[package]] +name = "litemap" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" + [[package]] name = "lock_api" version = "0.4.11" @@ -3584,6 +3719,12 @@ dependencies = [ "lock_api", ] +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + [[package]] name = "strsim" version = "0.10.0" @@ -3692,6 +3833,17 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "system-configuration" version = "0.5.1" @@ -4435,20 +4587,15 @@ dependencies = [ ] [[package]] -name = "tinyvec" -version = "1.6.0" +name = "tinystr" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" dependencies = [ - "tinyvec_macros", + "displaydoc", + "zerovec", ] -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - [[package]] name = "tokio" version = "1.37.0" @@ -4741,12 +4888,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "unicode-bidi" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" - [[package]] name = "unicode-ident" version = "1.0.12" @@ -4759,15 +4900,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" -[[package]] -name = "unicode-normalization" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" -dependencies = [ - "tinyvec", -] - [[package]] name = "unicode-segmentation" version = "1.11.0" @@ -4817,9 +4949,9 @@ dependencies = [ [[package]] name = "url" -version = "2.5.0" +version = "2.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" dependencies = [ "form_urlencoded", "idna", @@ -4832,6 +4964,18 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "utf8parse" version = "0.2.1" @@ -5220,6 +5364,18 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + [[package]] name = "ws_stream_tungstenite" version = "0.11.0" @@ -5299,6 +5455,30 @@ dependencies = [ "time", ] +[[package]] +name = "yoke" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", + "synstructure 0.13.1", +] + [[package]] name = "zerocopy" version = "0.7.32" @@ -5319,8 +5499,51 @@ dependencies = [ "syn 2.0.77", ] +[[package]] +name = "zerofrom" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", + "synstructure 0.13.1", +] + [[package]] name = "zeroize" version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] From 563a5d9f239692c95bdf352b6d647ccd82a6065b Mon Sep 17 00:00:00 2001 From: Marcel Guzik Date: Mon, 9 Dec 2024 17:43:20 +0100 Subject: [PATCH 08/10] Switch from patched versions of rumqttd and x509-parser Signed-off-by: Marcel Guzik --- Cargo.lock | 602 ++++++++++++++++++++++------------------------------- Cargo.toml | 8 +- 2 files changed, 251 insertions(+), 359 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a892f35c808..dc2ea1ae40b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,6 +17,17 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "ahash" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + [[package]] name = "ahash" version = "0.8.7" @@ -107,8 +118,24 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f6fd5ddaf0351dff5b8da21b2fb4ff8e08ddd02857f0bf69c47639106c0fff0" dependencies = [ - "asn1-rs-derive", - "asn1-rs-impl", + "asn1-rs-derive 0.4.0", + "asn1-rs-impl 0.1.0", + "displaydoc", + "nom", + "num-traits", + "rusticata-macros", + "thiserror", + "time", +] + +[[package]] +name = "asn1-rs" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5493c3bedbacf7fd7382c6346bbd66687d12bbaad3a89a2d2c303ee6cf20b048" +dependencies = [ + "asn1-rs-derive 0.5.1", + "asn1-rs-impl 0.2.0", "displaydoc", "nom", "num-traits", @@ -129,6 +156,18 @@ dependencies = [ "synstructure 0.12.6", ] +[[package]] +name = "asn1-rs-derive" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "965c2d33e53cb6b267e148a4cb0760bc01f4904c1cd4bb4002a085bb016d1490" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", + "synstructure 0.13.1", +] + [[package]] name = "asn1-rs-impl" version = "0.1.0" @@ -140,6 +179,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "asn1-rs-impl" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "assert-json-diff" version = "2.0.2" @@ -207,22 +257,8 @@ dependencies = [ "pin-project-lite", "rustls-native-certs", "tokio", - "tokio-rustls 0.24.1", - "tungstenite 0.20.1", -] - -[[package]] -name = "async-tungstenite" -version = "0.25.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cca750b12e02c389c1694d35c16539f88b8bbaa5945934fdc1b41a776688589" -dependencies = [ - "futures-io", - "futures-util", - "log", - "pin-project-lite", - "tokio", - "tungstenite 0.21.0", + "tokio-rustls", + "tungstenite", ] [[package]] @@ -287,7 +323,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" dependencies = [ "async-trait", - "axum-core 0.3.4", + "axum-core", "axum-macros", "base64 0.21.7", "bitflags 1.3.2", @@ -309,7 +345,7 @@ dependencies = [ "serde_path_to_error", "serde_urlencoded", "sha1", - "sync_wrapper 0.1.2", + "sync_wrapper", "tokio", "tokio-tungstenite", "tower", @@ -317,40 +353,6 @@ dependencies = [ "tower-service", ] -[[package]] -name = "axum" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" -dependencies = [ - "async-trait", - "axum-core 0.4.3", - "bytes", - "futures-util", - "http 1.1.0", - "http-body 1.0.0", - "http-body-util", - "hyper 1.3.1", - "hyper-util", - "itoa", - "matchit", - "memchr", - "mime", - "percent-encoding", - "pin-project-lite", - "rustversion", - "serde", - "serde_json", - "serde_path_to_error", - "serde_urlencoded", - "sync_wrapper 1.0.1", - "tokio", - "tower", - "tower-layer", - "tower-service", - "tracing", -] - [[package]] name = "axum-core" version = "0.3.4" @@ -368,27 +370,6 @@ dependencies = [ "tower-service", ] -[[package]] -name = "axum-core" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" -dependencies = [ - "async-trait", - "bytes", - "futures-util", - "http 1.1.0", - "http-body 1.0.0", - "http-body-util", - "mime", - "pin-project-lite", - "rustversion", - "sync_wrapper 0.1.2", - "tower-layer", - "tower-service", - "tracing", -] - [[package]] name = "axum-macros" version = "0.3.8" @@ -414,10 +395,10 @@ dependencies = [ "http-body 0.4.6", "hyper 0.14.28", "pin-project-lite", - "rustls 0.21.11", - "rustls-pemfile 1.0.4", + "rustls", + "rustls-pemfile", "tokio", - "tokio-rustls 0.24.1", + "tokio-rustls", "tower-service", ] @@ -427,7 +408,7 @@ version = "1.3.1" dependencies = [ "anyhow", "assert_matches", - "axum 0.6.20", + "axum", "axum-server", "camino", "futures", @@ -435,15 +416,15 @@ dependencies = [ "pin-project", "rcgen", "reqwest", - "rustls 0.21.11", - "rustls-pemfile 1.0.4", + "rustls", + "rustls-pemfile", "tedge_config", "tempfile", "tokio", - "tokio-rustls 0.24.1", + "tokio-rustls", "tower", "tracing", - "x509-parser", + "x509-parser 0.16.0", "yansi", ] @@ -519,12 +500,6 @@ version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" -[[package]] -name = "base64" -version = "0.22.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" - [[package]] name = "batcher" version = "1.3.1" @@ -561,9 +536,6 @@ name = "bitflags" version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" -dependencies = [ - "serde", -] [[package]] name = "block-buffer" @@ -636,7 +608,7 @@ name = "c8y-remote-access-plugin" version = "1.3.1" dependencies = [ "async-compat", - "async-tungstenite 0.23.0", + "async-tungstenite", "base64 0.13.1", "c8y_api", "camino", @@ -649,16 +621,16 @@ dependencies = [ "miette", "rand", "rstest", - "rustls 0.21.11", + "rustls", "serde", "tedge_config", "tedge_utils", "tempfile", "thiserror", "tokio", - "toml", + "toml 0.8.8", "url", - "ws_stream_tungstenite 0.11.0", + "ws_stream_tungstenite", ] [[package]] @@ -687,7 +659,7 @@ dependencies = [ "thiserror", "time", "tokio", - "toml", + "toml 0.8.8", "tracing", "url", ] @@ -697,7 +669,7 @@ name = "c8y_auth_proxy" version = "1.3.1" dependencies = [ "anyhow", - "axum 0.6.20", + "axum", "axum-server", "axum_tls", "c8y_api", @@ -709,7 +681,7 @@ dependencies = [ "mockito", "rcgen", "reqwest", - "rustls 0.21.11", + "rustls", "tedge_actors", "tedge_config", "tedge_config_macros", @@ -808,7 +780,7 @@ dependencies = [ "thiserror", "time", "tokio", - "toml", + "toml 0.8.8", "tracing", "url", ] @@ -847,15 +819,15 @@ dependencies = [ "camino", "rcgen", "reqwest", - "rustls 0.21.11", + "rustls", "rustls-native-certs", - "rustls-pemfile 1.0.4", + "rustls-pemfile", "sha-1", "tempfile", "thiserror", "time", "tracing", - "x509-parser", + "x509-parser 0.16.0", "zeroize", ] @@ -949,12 +921,11 @@ dependencies = [ [[package]] name = "config" -version = "0.14.0" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7328b20597b53c2454f0b1919720c25c7339051c02b72b7e05409e00b14132be" +checksum = "23738e11972c7643e4ec947840fc463b6a571afcd3e735bdfce7d03c7a784aca" dependencies = [ "async-trait", - "convert_case", "json5", "lazy_static", "nom", @@ -963,39 +934,10 @@ dependencies = [ "rust-ini", "serde", "serde_json", - "toml", + "toml 0.5.11", "yaml-rust", ] -[[package]] -name = "const-random" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359" -dependencies = [ - "const-random-macro", -] - -[[package]] -name = "const-random-macro" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" -dependencies = [ - "getrandom", - "once_cell", - "tiny-keccak", -] - -[[package]] -name = "convert_case" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" -dependencies = [ - "unicode-segmentation", -] - [[package]] name = "core-foundation" version = "0.9.4" @@ -1045,12 +987,6 @@ version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" -[[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" - [[package]] name = "crypto-common" version = "0.1.6" @@ -1164,7 +1100,21 @@ version = "8.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dbd676fbbab537128ef0278adb5576cf363cff6aa22a7b24effe97347cfab61e" dependencies = [ - "asn1-rs", + "asn1-rs 0.5.2", + "displaydoc", + "nom", + "num-bigint", + "num-traits", + "rusticata-macros", +] + +[[package]] +name = "der-parser" +version = "9.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cd0a5c643689626bec213c4d8bd4d96acc8ffdb4ad4bb6bc16abf27d5f4b553" +dependencies = [ + "asn1-rs 0.6.2", "displaydoc", "nom", "num-bigint", @@ -1217,12 +1167,9 @@ dependencies = [ [[package]] name = "dlv-list" -version = "0.5.2" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "442039f5147480ba31067cb00ada1adae6892028e40e45fc5de7b7df6dcc1b5f" -dependencies = [ - "const-random", -] +checksum = "0688c2a7f92e427f44895cd63841bff7b29f8d7a1648b9e7e07a4a365b2e1257" [[package]] name = "doc-comment" @@ -1272,7 +1219,7 @@ dependencies = [ "nix", "regex", "reqwest", - "rustls 0.21.11", + "rustls", "serde", "serde_json", "tedge_utils", @@ -1363,7 +1310,7 @@ dependencies = [ "pear", "serde", "tempfile", - "toml", + "toml 0.8.8", "uncased", "version_check", ] @@ -1600,7 +1547,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.11", - "indexmap", + "indexmap 2.2.1", "slab", "tokio", "tokio-util", @@ -1619,7 +1566,7 @@ dependencies = [ "futures-core", "futures-sink", "http 1.1.0", - "indexmap", + "indexmap 2.2.1", "slab", "tokio", "tokio-util", @@ -1628,19 +1575,28 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.13.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash 0.7.8", +] [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "33ff8ae62cd3a9102e5637afc8452c55acf3844001bd5374e0b0bd7b6616c038" dependencies = [ - "ahash", + "ahash 0.8.7", ] +[[package]] +name = "hashbrown" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" + [[package]] name = "headers" version = "0.3.9" @@ -1819,10 +1775,10 @@ dependencies = [ "futures-util", "http 0.2.11", "hyper 0.14.28", - "rustls 0.21.11", + "rustls", "rustls-native-certs", "tokio", - "tokio-rustls 0.24.1", + "tokio-rustls", ] [[package]] @@ -1985,6 +1941,16 @@ dependencies = [ "icu_properties", ] +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + [[package]] name = "indexmap" version = "2.2.1" @@ -2178,6 +2144,15 @@ version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +[[package]] +name = "mach2" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709" +dependencies = [ + "libc", +] + [[package]] name = "maplit" version = "1.0.2" @@ -2216,40 +2191,53 @@ dependencies = [ [[package]] name = "metrics" -version = "0.22.1" +version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd71d9db2e4287c3407fa04378b8c2ee570aebe0854431562cdd89ca091854f4" +checksum = "fde3af1a009ed76a778cb84fdef9e7dbbdf5775ae3e4cc1f434a6a307f6f76c5" dependencies = [ - "ahash", + "ahash 0.8.7", + "metrics-macros", "portable-atomic", ] [[package]] name = "metrics-exporter-prometheus" -version = "0.13.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bf4e7146e30ad172c42c39b3246864bd2d3c6396780711a1baf749cfe423e21" +checksum = "1d4fa7ce7c4862db464a37b0b31d89bca874562f034bd7993895572783d02950" dependencies = [ "base64 0.21.7", "hyper 0.14.28", - "indexmap", + "indexmap 1.9.3", "ipnet", "metrics", "metrics-util", "quanta", "thiserror", "tokio", + "tracing", +] + +[[package]] +name = "metrics-macros" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b4faf00617defe497754acde3024865bc143d44a86799b24e191ecff91354f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.77", ] [[package]] name = "metrics-util" -version = "0.16.3" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b07a5eb561b8cbc16be2d216faf7757f9baf3bfb94dbb0fae3df8387a5bb47f" +checksum = "4de2ed6e491ed114b40b732e4d1659a9d53992ebd87490c44a6ffe23739d973e" dependencies = [ "crossbeam-epoch", "crossbeam-utils", - "hashbrown 0.14.3", + "hashbrown 0.13.1", "metrics", "num_cpus", "quanta", @@ -2572,7 +2560,16 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bedf36ffb6ba96c2eb7144ef6270557b52e54b20c0a8e1eb2ff99a6c6959bff" dependencies = [ - "asn1-rs", + "asn1-rs 0.5.2", +] + +[[package]] +name = "oid-registry" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8d8034d9489cdaf79228eb9f6a3b8d7bb32ba00d6645ebd48eef4077ceb5bd9" +dependencies = [ + "asn1-rs 0.6.2", ] [[package]] @@ -2589,12 +2586,12 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "ordered-multimap" -version = "0.6.0" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ed8acf08e98e744e5384c8bc63ceb0364e68a6854187221c18df61c4797690e" +checksum = "ccd746e37177e1711c20dd619a1620f34f5c8b569c53590a72dedd5344d8924a" dependencies = [ "dlv-list", - "hashbrown 0.13.2", + "hashbrown 0.12.3", ] [[package]] @@ -2962,12 +2959,13 @@ dependencies = [ [[package]] name = "quanta" -version = "0.12.3" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5167a477619228a0b284fac2674e3c388cba90631d7b7de620e6f1fcd08da5" +checksum = "a17e662a7a8291a865152364c20c7abc5e60486ab2001e8ec10b24862de0b9ab" dependencies = [ "crossbeam-utils", "libc", + "mach2", "once_cell", "raw-cpuid", "wasi", @@ -3031,11 +3029,11 @@ dependencies = [ [[package]] name = "raw-cpuid" -version = "11.0.2" +version = "10.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e29830cbb1290e404f24c73af91c5d8d631ce7e128691e9477556b540cd01ecd" +checksum = "6c297679cb867470fa8c9f67dbba74a78d78e3e98d7cf2b08d6d71540f797332" dependencies = [ - "bitflags 2.4.2", + "bitflags 1.3.2", ] [[package]] @@ -3128,15 +3126,15 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls 0.21.11", + "rustls", "rustls-native-certs", - "rustls-pemfile 1.0.4", + "rustls-pemfile", "serde", "serde_json", "serde_urlencoded", "system-configuration", "tokio", - "tokio-rustls 0.24.1", + "tokio-rustls", "tokio-util", "tower-service", "url", @@ -3163,14 +3161,13 @@ dependencies = [ [[package]] name = "ron" -version = "0.8.1" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94" +checksum = "88073939a61e5b7680558e6be56b419e208420c2adb92be54921fa6b72283f1a" dependencies = [ - "base64 0.21.7", - "bitflags 2.4.2", + "base64 0.13.1", + "bitflags 1.3.2", "serde", - "serde_derive", ] [[package]] @@ -3220,20 +3217,21 @@ dependencies = [ "futures-util", "log", "rustls-native-certs", - "rustls-pemfile 1.0.4", - "rustls-webpki 0.101.7", + "rustls-pemfile", + "rustls-webpki", "thiserror", "tokio", - "tokio-rustls 0.24.1", + "tokio-rustls", ] [[package]] name = "rumqttd" version = "0.19.0" -source = "git+https://github.com/bytebeamio/rumqtt?rev=0767080715699c34d8fe90b843716ba5ec12f8b9#0767080715699c34d8fe90b843716ba5ec12f8b9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acd14965c40f3e679264cb8a8db540db511f1d7ed8b209b22d1641320bd26a58" dependencies = [ - "async-tungstenite 0.25.1", - "axum 0.7.5", + "async-tungstenite", + "axum", "bytes", "clap", "config", @@ -3243,28 +3241,26 @@ dependencies = [ "metrics-exporter-prometheus", "parking_lot", "rand", - "rustls-pemfile 2.1.2", - "rustls-webpki 0.102.4", + "rustls-pemfile", + "rustls-webpki", "serde", "serde_json", "slab", - "subtle", "thiserror", "tokio", - "tokio-rustls 0.25.0", + "tokio-rustls", "tokio-util", "tracing", "tracing-subscriber", - "uuid", - "ws_stream_tungstenite 0.13.0", - "x509-parser", + "ws_stream_tungstenite", + "x509-parser 0.15.1", ] [[package]] name = "rust-ini" -version = "0.19.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e2a3bcec1f113553ef1c88aae6c020a369d03d55b58de9869a0908930385091" +checksum = "f6d5f2436026b4f6e79dc829837d467cc7e9a55ee40e750d716713540715a2df" dependencies = [ "cfg-if", "ordered-multimap", @@ -3315,24 +3311,10 @@ checksum = "7fecbfb7b1444f477b345853b1fce097a2c6fb637b2bfb87e6bc5db0f043fae4" dependencies = [ "log", "ring", - "rustls-webpki 0.101.7", + "rustls-webpki", "sct", ] -[[package]] -name = "rustls" -version = "0.22.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" -dependencies = [ - "log", - "ring", - "rustls-pki-types", - "rustls-webpki 0.102.4", - "subtle", - "zeroize", -] - [[package]] name = "rustls-native-certs" version = "0.6.3" @@ -3340,7 +3322,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" dependencies = [ "openssl-probe", - "rustls-pemfile 1.0.4", + "rustls-pemfile", "schannel", "security-framework", ] @@ -3354,22 +3336,6 @@ dependencies = [ "base64 0.21.7", ] -[[package]] -name = "rustls-pemfile" -version = "2.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" -dependencies = [ - "base64 0.22.1", - "rustls-pki-types", -] - -[[package]] -name = "rustls-pki-types" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" - [[package]] name = "rustls-webpki" version = "0.101.7" @@ -3380,17 +3346,6 @@ dependencies = [ "untrusted", ] -[[package]] -name = "rustls-webpki" -version = "0.102.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff448f7e92e913c4b7d4c6d8e4540a1724b319b4152b8aef6d4cf8339712b33e" -dependencies = [ - "ring", - "rustls-pki-types", - "untrusted", -] - [[package]] name = "rustversion" version = "1.0.14" @@ -3753,12 +3708,6 @@ dependencies = [ "syn 1.0.109", ] -[[package]] -name = "subtle" -version = "2.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" - [[package]] name = "supports-color" version = "2.1.0" @@ -3815,12 +3764,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" -[[package]] -name = "sync_wrapper" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" - [[package]] name = "synstructure" version = "0.12.6" @@ -3910,11 +3853,11 @@ dependencies = [ "test-case", "thiserror", "tokio", - "toml", + "toml 0.8.8", "tracing", "url", "which", - "x509-parser", + "x509-parser 0.16.0", "yansi", ] @@ -3924,7 +3867,7 @@ version = "1.3.1" dependencies = [ "anyhow", "async-trait", - "axum 0.6.20", + "axum", "axum-server", "axum_tls", "bytes", @@ -3941,8 +3884,8 @@ dependencies = [ "plugin_sm", "rcgen", "reqwest", - "rustls 0.21.11", - "rustls-pemfile 1.0.4", + "rustls", + "rustls-pemfile", "serde", "serde_json", "sha256", @@ -3966,7 +3909,7 @@ dependencies = [ "time", "tokio", "tokio-util", - "toml", + "toml 0.8.8", "tower", "tracing", "which", @@ -4101,7 +4044,7 @@ dependencies = [ "thiserror", "time", "tokio", - "toml", + "toml 0.8.8", "walkdir", ] @@ -4121,7 +4064,7 @@ dependencies = [ "once_cell", "regex", "reqwest", - "rustls 0.21.11", + "rustls", "serde", "serde_ignored", "serde_json", @@ -4133,7 +4076,7 @@ dependencies = [ "tempfile", "test-case", "thiserror", - "toml", + "toml 0.8.8", "tracing", "tracing-subscriber", "url", @@ -4153,7 +4096,7 @@ dependencies = [ "serde_json", "tedge_config_macros-macro", "thiserror", - "toml", + "toml 0.8.8", "tracing", "url", ] @@ -4206,7 +4149,7 @@ dependencies = [ "tempfile", "thiserror", "tokio", - "toml", + "toml 0.8.8", "uzers", ] @@ -4268,7 +4211,7 @@ dependencies = [ "hyper 0.14.28", "hyper-rustls", "mockito", - "rustls 0.21.11", + "rustls", "serde", "serde_json", "tedge_actors", @@ -4303,7 +4246,7 @@ dependencies = [ "thiserror", "time", "tokio", - "toml", + "toml 0.8.8", ] [[package]] @@ -4376,7 +4319,7 @@ dependencies = [ "anyhow", "camino", "tempfile", - "toml", + "toml 0.8.8", ] [[package]] @@ -4577,15 +4520,6 @@ dependencies = [ "time-core", ] -[[package]] -name = "tiny-keccak" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" -dependencies = [ - "crunchy", -] - [[package]] name = "tinystr" version = "0.7.6" @@ -4632,18 +4566,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.21.11", - "tokio", -] - -[[package]] -name = "tokio-rustls" -version = "0.25.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" -dependencies = [ - "rustls 0.22.4", - "rustls-pki-types", + "rustls", "tokio", ] @@ -4655,11 +4578,11 @@ checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" dependencies = [ "futures-util", "log", - "rustls 0.21.11", + "rustls", "rustls-native-certs", "tokio", - "tokio-rustls 0.24.1", - "tungstenite 0.20.1", + "tokio-rustls", + "tungstenite", ] [[package]] @@ -4676,6 +4599,15 @@ dependencies = [ "tracing", ] +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + [[package]] name = "toml" version = "0.8.8" @@ -4703,7 +4635,7 @@ version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" dependencies = [ - "indexmap", + "indexmap 2.2.1", "serde", "serde_spanned", "toml_datetime", @@ -4826,26 +4758,7 @@ dependencies = [ "httparse", "log", "rand", - "rustls 0.21.11", - "sha1", - "thiserror", - "url", - "utf-8", -] - -[[package]] -name = "tungstenite" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1" -dependencies = [ - "byteorder", - "bytes", - "data-encoding", - "http 1.1.0", - "httparse", - "log", - "rand", + "rustls", "sha1", "thiserror", "url", @@ -4900,12 +4813,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" -[[package]] -name = "unicode-segmentation" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" - [[package]] name = "unicode-width" version = "0.1.11" @@ -4929,7 +4836,7 @@ name = "upload" version = "1.3.1" dependencies = [ "anyhow", - "axum 0.6.20", + "axum", "axum_tls", "backoff", "camino", @@ -4982,16 +4889,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" -[[package]] -name = "uuid" -version = "1.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de17fd2f7da591098415cff336e12965a28061ddace43b59cb3c430179c9439" -dependencies = [ - "getrandom", - "rand", -] - [[package]] name = "uzers" version = "0.11.3" @@ -5382,7 +5279,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e283cc794a890f5bdc01e358ad7c34535025f79ba83c1b5c7e01e5d6c60b336d" dependencies = [ - "async-tungstenite 0.23.0", + "async-tungstenite", "async_io_stream", "bitflags 2.4.2", "futures-core", @@ -5391,41 +5288,40 @@ dependencies = [ "futures-util", "pharos", "rustc_version", + "tokio", "tracing", - "tungstenite 0.20.1", + "tungstenite", ] [[package]] -name = "ws_stream_tungstenite" -version = "0.13.0" +name = "x509-parser" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a198f414f083fb19fcc1bffcb0fa0cf46d33ccfa229adf248cac12c180e91609" +checksum = "7069fba5b66b9193bd2c5d3d4ff12b839118f6bcbef5328efafafb5395cf63da" dependencies = [ - "async-tungstenite 0.25.1", - "async_io_stream", - "bitflags 2.4.2", - "futures-core", - "futures-io", - "futures-sink", - "futures-util", - "pharos", - "rustc_version", - "tokio", - "tracing", - "tungstenite 0.21.0", + "asn1-rs 0.5.2", + "data-encoding", + "der-parser 8.2.0", + "lazy_static", + "nom", + "oid-registry 0.6.1", + "rusticata-macros", + "thiserror", + "time", ] [[package]] name = "x509-parser" -version = "0.15.2" -source = "git+https://github.com/thin-edge/x509-parser.git?branch=ring-0.17#63deff43b1d7f04c985fa6eec7a8cb59014a8661" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcbc162f30700d6f3f82a24bf7cc62ffe7caea42c0b2cba8bf7f3ae50cf51f69" dependencies = [ - "asn1-rs", + "asn1-rs 0.6.2", "data-encoding", - "der-parser", + "der-parser 9.0.0", "lazy_static", "nom", - "oid-registry", + "oid-registry 0.7.1", "rusticata-macros", "thiserror", "time", diff --git a/Cargo.toml b/Cargo.toml index 9c67ab8c0d8..4be21143dd6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -154,8 +154,7 @@ reqwest = { version = "0.11", default-features = false } rpassword = "5.0" rstest = "0.16.0" rumqttc = "0.23" -# TODO: used git rev version to fix `unknown feature stdsimd` error: replace with 0.20 version after the release -rumqttd = { git = "https://github.com/bytebeamio/rumqtt", rev = "0767080715699c34d8fe90b843716ba5ec12f8b9" } +rumqttd = "0.19" rustls = "0.21.11" rustls-native-certs = "0.6.3" rustls-pemfile = "1.0.1" @@ -191,7 +190,7 @@ walkdir = "2" which = "4.2" whoami = "1.5.0" ws_stream_tungstenite = "0.11" -x509-parser = "0.15" +x509-parser = "0.16" yansi = "1.0.1" zeroize = "1.5" @@ -205,6 +204,3 @@ overflow-checks = true [workspace.lints.clippy] get_first = "allow" - -[patch.crates-io] -x509-parser = { git = 'https://github.com/thin-edge/x509-parser.git', branch = "ring-0.17" } From 2ce9ee779b6ec5e29cf05c8d8b6eb8d0753aeb6a Mon Sep 17 00:00:00 2001 From: reubenmiller Date: Fri, 6 Dec 2024 21:00:15 +0100 Subject: [PATCH 09/10] feat: support Cumulocity legacy file upload/download operations --- .../core/c8y_api/src/json_c8y_deserializer.rs | 13 ++++- .../operate/c8y/configuration-management.md | 4 ++ .../legacy_configuration_workflow.robot | 54 +++++++++++++++++++ .../tedge-configuration-plugin.toml | 5 ++ 4 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 tests/RobotFramework/tests/cumulocity/configuration/legacy_config_operation/legacy_configuration_workflow.robot create mode 100644 tests/RobotFramework/tests/cumulocity/configuration/legacy_config_operation/tedge-configuration-plugin.toml diff --git a/crates/core/c8y_api/src/json_c8y_deserializer.rs b/crates/core/c8y_api/src/json_c8y_deserializer.rs index 44163446f84..d55173775fc 100644 --- a/crates/core/c8y_api/src/json_c8y_deserializer.rs +++ b/crates/core/c8y_api/src/json_c8y_deserializer.rs @@ -405,12 +405,20 @@ pub struct C8yLogfileRequest { pub maximum_lines: usize, } +/// Default type assigned to the upload/download operations +/// in order to be compatible with the Cumulocity legacy configuration upload/download +/// operations which don't have a type property set in the operation +fn default_config_type() -> String { + "default".to_string() +} + /// Representation of c8y_UploadConfigFile JSON object /// /// ```rust /// use c8y_api::json_c8y_deserializer::C8yUploadConfigFile; /// /// // Example input from c8y +/// // Note: Legacy config upload operations will not have the type property /// let data = r#" /// { /// "type": "/etc/tedge/tedge.toml" @@ -422,7 +430,7 @@ pub struct C8yLogfileRequest { #[derive(Debug, Deserialize, Eq, PartialEq)] #[serde(rename_all = "camelCase")] pub struct C8yUploadConfigFile { - #[serde(rename = "type")] + #[serde(rename = "type", default = "default_config_type")] pub config_type: String, } @@ -432,6 +440,7 @@ pub struct C8yUploadConfigFile { /// use c8y_api::json_c8y_deserializer::C8yDownloadConfigFile; /// /// // Example input from c8y +/// // Note: Legacy config download operations will not have the type property /// let data = r#" /// { /// "type": "/etc/tedge/tedge.toml", @@ -444,7 +453,7 @@ pub struct C8yUploadConfigFile { #[derive(Debug, Deserialize, Eq, PartialEq)] #[serde(rename_all = "camelCase")] pub struct C8yDownloadConfigFile { - #[serde(rename = "type")] + #[serde(rename = "type", default = "default_config_type")] pub config_type: String, pub url: String, } diff --git a/docs/src/operate/c8y/configuration-management.md b/docs/src/operate/c8y/configuration-management.md index 856eed70d56..73e196b3415 100644 --- a/docs/src/operate/c8y/configuration-management.md +++ b/docs/src/operate/c8y/configuration-management.md @@ -32,6 +32,10 @@ files = [ * `type` is a unique alias for each file entry which will be used to represent that file in Cumulocity UI. * `user`, `group` and `mode` are UNIX file permission settings to be used to create a configuration file. If not provided, the files will be created with `root` user. If the file exists already, its ownership will be retained. +:::note +The Cumulocity legacy configuration operations (e.g. non file-type operations) will be automatically given the "default" type. This will enable you to configure the file location as you would with any other configuration file. +::: + For more details on this configuration file format, refer to the [reference guide](../../references/agent/tedge-configuration-management.md#configuration). :::note diff --git a/tests/RobotFramework/tests/cumulocity/configuration/legacy_config_operation/legacy_configuration_workflow.robot b/tests/RobotFramework/tests/cumulocity/configuration/legacy_config_operation/legacy_configuration_workflow.robot new file mode 100644 index 00000000000..69d51428878 --- /dev/null +++ b/tests/RobotFramework/tests/cumulocity/configuration/legacy_config_operation/legacy_configuration_workflow.robot @@ -0,0 +1,54 @@ +*** Settings *** +Resource ../../../../resources/common.resource +Library String +Library Cumulocity +Library ThinEdgeIO + +Test Setup Custom Setup +Test Teardown Get Logs + +Test Tags theme:c8y theme:configuration + + +*** Test Cases *** +Support Legacy Configuration Download Operation + [Documentation] Support Cumulocity Legacy File Upload/Download + ... which was the default before file-type configuration operations were introduced + ... Cumulocity Docs: https://cumulocity.com/docs/device-integration/fragment-library/#install-legacy-configuration + + # pre-condition + Cumulocity.Managed Object Should Not Have Fragments c8y_ConfigurationDump + + # Send configuration to a device + ${binary_url}= Create Inventory Binary dummy example contents=foobar + ${binary_id}= Get Binary ID From URL ${binary_url} + ${operation}= Cumulocity.Create Operation + ... description=Legacy Configuration Download + ... fragments={"c8y_DownloadConfigFile":{"url": "${binary_url}", "c8y_ConfigurationDump": {"id": "${binary_id}"}}} + Cumulocity.Operation Should Be SUCCESSFUL ${operation} + + # Server will update the inventory managed object fields + Cumulocity.Device Should Have Fragments c8y_ConfigurationDump + Cumulocity.Device Should Have Fragment Values c8y_ConfigurationDump.id\="${binary_id}" + + # Get configuration from the device + ${operation}= Cumulocity.Create Operation + ... description=Legacy Configuration Upload + ... fragments={"c8y_UploadConfigFile":{}} + Cumulocity.Operation Should Be SUCCESSFUL ${operation} + + +*** Keywords *** +Custom Setup + ${DEVICE_SN}= Setup skip_bootstrap=False + Set Suite Variable $DEVICE_SN + + Transfer To Device + ... ${CURDIR}/tedge-configuration-plugin.toml + ... /etc/tedge/plugins/tedge-configuration-plugin.toml + Cumulocity.Device Should Exist ${DEVICE_SN} + +Get Binary ID From URL + [Arguments] ${url} + ${parts}= Split String From Right ${url} separator=/ max_split=1 + RETURN ${parts[1]} diff --git a/tests/RobotFramework/tests/cumulocity/configuration/legacy_config_operation/tedge-configuration-plugin.toml b/tests/RobotFramework/tests/cumulocity/configuration/legacy_config_operation/tedge-configuration-plugin.toml new file mode 100644 index 00000000000..0bed610e040 --- /dev/null +++ b/tests/RobotFramework/tests/cumulocity/configuration/legacy_config_operation/tedge-configuration-plugin.toml @@ -0,0 +1,5 @@ +files = [ + { path = '/etc/tedge/tedge.toml', user = 'tedge', group = 'tedge', mode = 0o444 }, + { path = '/etc/tedge/system.toml', type = 'system.toml', user = 'tedge', group = 'tedge', mode = 0o444 }, + { path = '/etc/legacy.txt', type = 'default', user = 'tedge', group = 'tedge', mode = 0o644 }, +] From f0ff4f795bc978176d2f9045ce93afbe11a7fce7 Mon Sep 17 00:00:00 2001 From: Marcel Guzik Date: Wed, 4 Dec 2024 20:32:33 +0100 Subject: [PATCH 10/10] Replace smartrest message id magic numbers with consts from c8y_api Usage of the magic numbers was replaced with using the consts where it could be done trivially, i.e. when these magic numbers were not parts of string literals where replacing them would add a lot of code, which mainly happens to be in the unit tests. Signed-off-by: Marcel Guzik --- crates/core/c8y_api/src/smartrest/alarm.rs | 19 ++++--- .../core/c8y_api/src/smartrest/inventory.rs | 32 +++++++---- crates/core/c8y_api/src/smartrest/payload.rs | 5 +- .../src/smartrest/smartrest_deserializer.rs | 8 +-- .../src/smartrest/smartrest_serializer.rs | 53 +++++++++++-------- crates/core/c8y_api/src/utils.rs | 3 +- .../src/cli/connect/c8y_direct_connection.rs | 3 +- crates/core/tedge/src/cli/connect/command.rs | 8 +-- .../c8y_firmware_manager/src/actor.rs | 26 +++++---- .../c8y_firmware_manager/src/tests.rs | 3 +- .../c8y_firmware_manager/src/worker.rs | 6 ++- .../c8y_mapper_ext/src/operations/convert.rs | 6 ++- 12 files changed, 107 insertions(+), 65 deletions(-) diff --git a/crates/core/c8y_api/src/smartrest/alarm.rs b/crates/core/c8y_api/src/smartrest/alarm.rs index fff630283c6..51bfcc011bb 100644 --- a/crates/core/c8y_api/src/smartrest/alarm.rs +++ b/crates/core/c8y_api/src/smartrest/alarm.rs @@ -1,5 +1,6 @@ use crate::json_c8y::AlarmSeverity; use crate::json_c8y::C8yAlarm; +use crate::smartrest::message_ids::*; use time::format_description::well_known::Rfc3339; use super::payload::SmartrestPayload; @@ -9,21 +10,23 @@ pub fn serialize_alarm(c8y_alarm: &C8yAlarm) -> Result { let smartrest_code = match alarm.severity { - AlarmSeverity::Critical => "301", - AlarmSeverity::Major => "302", - AlarmSeverity::Minor => "303", - AlarmSeverity::Warning => "304", + AlarmSeverity::Critical => CREATE_CRITICAL_ALARM, + AlarmSeverity::Major => CREATE_MAJOR_ALARM, + AlarmSeverity::Minor => CREATE_MINOR_ALARM, + AlarmSeverity::Warning => CREATE_WARNING_ALARM, }; - SmartrestPayload::serialize([ + SmartrestPayload::serialize(( smartrest_code, &alarm.alarm_type, &alarm.text, &alarm.time.format(&Rfc3339)?, - ]) + )) .expect("TODO: should alarm text be trimmed?") } - C8yAlarm::Clear(alarm) => SmartrestPayload::serialize((306, &alarm.alarm_type)) - .expect("alarm type should be shorter than payload size limit"), + C8yAlarm::Clear(alarm) => { + SmartrestPayload::serialize((CLEAR_EXISTING_ALARM, &alarm.alarm_type)) + .expect("alarm type should be shorter than payload size limit") + } }; Ok(smartrest) } diff --git a/crates/core/c8y_api/src/smartrest/inventory.rs b/crates/core/c8y_api/src/smartrest/inventory.rs index f46198283ac..e48a2c46bd8 100644 --- a/crates/core/c8y_api/src/smartrest/inventory.rs +++ b/crates/core/c8y_api/src/smartrest/inventory.rs @@ -9,13 +9,16 @@ // smartrest messages are sent. There should be one comprehensive API for // generating them. -use crate::smartrest::csv::fields_to_csv_string; use crate::smartrest::topic::publish_topic_from_ancestors; use crate::smartrest::topic::C8yTopic; use mqtt_channel::MqttMessage; use std::time::Duration; use tedge_config::TopicPrefix; +use super::message_ids::CHILD_DEVICE_CREATION; +use super::message_ids::SERVICE_CREATION; +use super::message_ids::SET_DEVICE_PROFILE_THAT_IS_BEING_APPLIED; +use super::message_ids::SET_REQUIRED_AVAILABILITY; use super::payload::SmartrestPayload; /// Create a SmartREST message for creating a child device under the given ancestors. @@ -49,7 +52,7 @@ pub fn child_device_creation_message( } let payload = SmartrestPayload::serialize(( - 101, + CHILD_DEVICE_CREATION, child_id, device_name.unwrap_or(child_id), device_type.unwrap_or("thin-edge.io-child"), @@ -115,11 +118,16 @@ pub fn service_creation_message_payload( }); } - let payload = - SmartrestPayload::serialize((102, service_id, service_type, service_name, service_status)) - .expect( - "TODO: message can get over the limit but none of the fields can be reasonably trimmed", - ); + let payload = SmartrestPayload::serialize(( + SERVICE_CREATION, + service_id, + service_type, + service_name, + service_status, + )) + .expect( + "TODO: message can get over the limit but none of the fields can be reasonably trimmed", + ); Ok(payload) } @@ -140,8 +148,9 @@ impl From for MqttMessage { fn from(value: C8ySmartRestSetInterval117) -> Self { let topic = value.c8y_topic.to_topic(&value.prefix).unwrap(); let interval_in_minutes = value.interval.as_secs() / 60; - let payload = SmartrestPayload::serialize((117, &interval_in_minutes)) - .expect("interval should not increase size over the limit"); + let payload = + SmartrestPayload::serialize((SET_REQUIRED_AVAILABILITY, &interval_in_minutes)) + .expect("interval should not increase size over the limit"); MqttMessage::new(&topic, payload.into_inner()) } } @@ -152,8 +161,9 @@ impl From for MqttMessage { /// When all individual operations are finished (i.e. firmware update, software /// update and configuration update), the `profile_executed` field should be set /// to `true`, otherwise it should be `false`. -pub fn set_c8y_profile_target_payload(profile_executed: bool) -> String { - fields_to_csv_string(["121", &profile_executed.to_string()]) +pub fn set_c8y_profile_target_payload(profile_executed: bool) -> SmartrestPayload { + SmartrestPayload::serialize((SET_DEVICE_PROFILE_THAT_IS_BEING_APPLIED, profile_executed)) + .expect("shouldn't put payload over size limit") } #[derive(thiserror::Error, Debug)] diff --git a/crates/core/c8y_api/src/smartrest/payload.rs b/crates/core/c8y_api/src/smartrest/payload.rs index 345c0165c38..3f7f46f2aff 100644 --- a/crates/core/c8y_api/src/smartrest/payload.rs +++ b/crates/core/c8y_api/src/smartrest/payload.rs @@ -84,9 +84,12 @@ impl Display for SmartrestPayload { mod tests { use super::*; + use crate::smartrest::message_ids::SET_DEVICE_PROFILE_THAT_IS_BEING_APPLIED; + #[test] fn serializes_payload() { - let payload = SmartrestPayload::serialize((121, true)).unwrap(); + let payload = + SmartrestPayload::serialize((SET_DEVICE_PROFILE_THAT_IS_BEING_APPLIED, true)).unwrap(); assert_eq!(payload.as_str(), "121,true"); } diff --git a/crates/core/c8y_api/src/smartrest/smartrest_deserializer.rs b/crates/core/c8y_api/src/smartrest/smartrest_deserializer.rs index ee5b5f545c9..27070d758fd 100644 --- a/crates/core/c8y_api/src/smartrest/smartrest_deserializer.rs +++ b/crates/core/c8y_api/src/smartrest/smartrest_deserializer.rs @@ -1,3 +1,5 @@ +use super::message_ids::GET_CHILDREN_OF_DEVICE; +use super::message_ids::JWT_TOKEN; use crate::smartrest::error::SmartRestDeserializerError; use csv::ReaderBuilder; use serde::de::Error; @@ -136,7 +138,7 @@ pub struct SmartRestJwtResponse { impl Default for SmartRestJwtResponse { fn default() -> Self { Self { - id: 71, + id: JWT_TOKEN as u16, token: "".into(), } } @@ -153,7 +155,7 @@ impl SmartRestJwtResponse { jwt = result.unwrap(); } - if jwt.id != 71 { + if jwt.id != JWT_TOKEN as u16 { return Err(SmartRestDeserializerError::InvalidMessageId(jwt.id)); } @@ -177,7 +179,7 @@ impl SmartRestRequestGeneric for AvailableChildDevices {} impl Default for AvailableChildDevices { fn default() -> Self { Self { - message_id: "106".into(), + message_id: GET_CHILDREN_OF_DEVICE.to_string(), devices: Default::default(), } } diff --git a/crates/core/c8y_api/src/smartrest/smartrest_serializer.rs b/crates/core/c8y_api/src/smartrest/smartrest_serializer.rs index b572922eb6b..dd5a46bd7dd 100644 --- a/crates/core/c8y_api/src/smartrest/smartrest_serializer.rs +++ b/crates/core/c8y_api/src/smartrest/smartrest_serializer.rs @@ -10,35 +10,38 @@ use tedge_api::SoftwareListCommand; use tedge_api::SoftwareModule; use tracing::warn; +use super::message_ids::*; + pub type SmartRest = String; -pub fn request_pending_operations() -> &'static str { - "500" +pub fn request_pending_operations() -> SmartrestPayload { + SmartrestPayload::serialize(GET_PENDING_OPERATIONS) + .expect("shouldn't put payload over size limit") } /// Generates a SmartREST message to set the provided operation to executing pub fn set_operation_executing_with_name(operation: impl C8yOperation) -> SmartrestPayload { - SmartrestPayload::serialize(("501", operation.name())) + SmartrestPayload::serialize((SET_OPERATION_TO_EXECUTING, operation.name())) .expect("operation name shouldn't put payload over size limit") } /// Generates a SmartREST message to set the provided operation ID to executing pub fn set_operation_executing_with_id(op_id: &str) -> SmartrestPayload { - SmartrestPayload::serialize(("504", op_id)) + SmartrestPayload::serialize((SET_OPERATION_TO_EXECUTING_ID, op_id)) .expect("op_id shouldn't put payload over size limit") } /// Generates a SmartREST message to set the provided operation to failed with the provided reason pub fn fail_operation_with_name(operation: impl C8yOperation, reason: &str) -> SmartrestPayload { - fail_operation("502", operation.name(), reason) + fail_operation(SET_OPERATION_TO_FAILED, operation.name(), reason) } /// Generates a SmartREST message to set the provided operation ID to failed with the provided reason pub fn fail_operation_with_id(op_id: &str, reason: &str) -> SmartrestPayload { - fail_operation("505", op_id, reason) + fail_operation(SET_OPERATION_TO_FAILED_ID, op_id, reason) } -fn fail_operation(template_id: &str, operation: &str, reason: &str) -> SmartrestPayload { +fn fail_operation(template_id: usize, operation: &str, reason: &str) -> SmartrestPayload { // If the failure reason exceeds 500 bytes, truncate it if reason.len() <= 500 { SmartrestPayload::serialize((template_id, operation, reason)) @@ -62,7 +65,7 @@ pub fn succeed_static_operation_with_name( operation: CumulocitySupportedOperations, payload: Option>, ) -> SmartrestPayload { - succeed_static_operation("503", operation.name(), payload) + succeed_static_operation(SET_OPERATION_TO_SUCCESSFUL, operation.name(), payload) } /// Generates a SmartREST message to set the provided operation ID to successful without a payload @@ -75,11 +78,11 @@ pub fn succeed_static_operation_with_id( op_id: &str, payload: Option>, ) -> SmartrestPayload { - succeed_static_operation("506", op_id, payload) + succeed_static_operation(SET_OPERATION_TO_SUCCESSFUL_ID, op_id, payload) } fn succeed_static_operation( - template_id: &str, + template_id: usize, operation: &str, payload: Option>, ) -> SmartrestPayload { @@ -106,7 +109,7 @@ fn succeed_static_operation( /// # Errors /// This will return an error if the payload is a CSV with multiple records, or an empty CSV. pub fn succeed_operation( - template_id: &str, + template_id: usize, operation: &str, reason: impl Into, ) -> Result { @@ -123,7 +126,9 @@ pub fn succeed_operation( } // payload too big, need to trim - let prefix = super::csv::fields_to_csv_string([template_id, operation]); + let prefix = SmartrestPayload::serialize((template_id, operation)) + .unwrap() + .into_inner(); let trim_indicator = "..."; @@ -165,14 +170,14 @@ pub fn succeed_operation_with_name( operation: &str, reason: impl Into, ) -> Result { - succeed_operation("503", operation, reason) + succeed_operation(SET_OPERATION_TO_SUCCESSFUL, operation, reason) } pub fn succeed_operation_with_id( operation: &str, reason: impl Into, ) -> Result { - succeed_operation("506", operation, reason) + succeed_operation(SET_OPERATION_TO_SUCCESSFUL_ID, operation, reason) } #[derive(Debug, Clone)] @@ -203,7 +208,8 @@ impl CumulocitySupportedOperations { } pub fn declare_supported_operations(ops: &[&str]) -> SmartrestPayload { - SmartrestPayload::serialize((114, ops)).expect("TODO: ops list can increase payload over limit") + SmartrestPayload::serialize((SET_SUPPORTED_OPERATIONS, ops)) + .expect("TODO: ops list can increase payload over limit") } #[derive(Debug, Clone, PartialEq)] @@ -238,17 +244,21 @@ pub enum AdvancedSoftwareList { impl AdvancedSoftwareList { fn smartrest_payload(self) -> String { let vec = match self { - AdvancedSoftwareList::Set(items) => Self::create_software_list("140", items), - AdvancedSoftwareList::Append(items) => Self::create_software_list("141", items), + AdvancedSoftwareList::Set(items) => { + Self::create_software_list(SET_ADVANCED_SOFTWARE_LIST, items) + } + AdvancedSoftwareList::Append(items) => { + Self::create_software_list(APPEND_ADVANCED_SOFTWARE_ITEMS, items) + } }; let list: Vec<&str> = vec.iter().map(std::ops::Deref::deref).collect(); fields_to_csv_string(list.as_slice()) } - fn create_software_list(id: &str, items: Vec) -> Vec { + fn create_software_list(id: usize, items: Vec) -> Vec { if items.is_empty() { - vec![id.into(), "".into(), "".into(), "".into(), "".into()] + vec![id.to_string(), "".into(), "".into(), "".into(), "".into()] } else { let mut vec = vec![id.to_string()]; for item in items { @@ -408,7 +418,7 @@ mod tests { #[test] fn serialize_smartrest_get_pending_operations() { let smartrest = request_pending_operations(); - assert_eq!(smartrest, "500"); + assert_eq!(smartrest.as_str(), "500"); } #[test] @@ -639,7 +649,8 @@ mod tests { let mut reason: String = "a".repeat(message_len - prefix_len - 2); reason.push('"'); - let smartrest = succeed_operation("503", "c8y_Command", reason).unwrap(); + let smartrest = + succeed_operation(SET_OPERATION_TO_SUCCESSFUL, "c8y_Command", reason).unwrap(); // assert message is under size limit and has expected structure assert!( diff --git a/crates/core/c8y_api/src/utils.rs b/crates/core/c8y_api/src/utils.rs index 9a8108480c7..ff1ae5f9c57 100644 --- a/crates/core/c8y_api/src/utils.rs +++ b/crates/core/c8y_api/src/utils.rs @@ -1,4 +1,5 @@ pub mod child_device { + use crate::smartrest::message_ids::CHILD_DEVICE_CREATION; use crate::smartrest::topic::C8yTopic; use mqtt_channel::MqttMessage; use tedge_config::TopicPrefix; @@ -6,7 +7,7 @@ pub mod child_device { pub fn new_child_device_message(child_id: &str, prefix: &TopicPrefix) -> MqttMessage { MqttMessage::new( &C8yTopic::upstream_topic(prefix), - format!("101,{child_id},{child_id},thin-edge.io-child"), + format!("{CHILD_DEVICE_CREATION},{child_id},{child_id},thin-edge.io-child"), ) } } diff --git a/crates/core/tedge/src/cli/connect/c8y_direct_connection.rs b/crates/core/tedge/src/cli/connect/c8y_direct_connection.rs index 8ae941de2db..6a1bff353d6 100644 --- a/crates/core/tedge/src/cli/connect/c8y_direct_connection.rs +++ b/crates/core/tedge/src/cli/connect/c8y_direct_connection.rs @@ -146,12 +146,13 @@ fn publish_device_create_message( device_id: &str, device_type: &str, ) -> Result<(), ConnectError> { + use c8y_api::smartrest::message_ids::DEVICE_CREATION; const DEVICE_CREATE_PUBLISH_TOPIC: &str = "s/us"; client.publish( DEVICE_CREATE_PUBLISH_TOPIC, QoS::ExactlyOnce, false, - format!("100,{},{}", device_id, device_type).as_bytes(), + format!("{DEVICE_CREATION},{},{}", device_id, device_type).as_bytes(), )?; Ok(()) } diff --git a/crates/core/tedge/src/cli/connect/command.rs b/crates/core/tedge/src/cli/connect/command.rs index dacbc8d2a61..fbc3922d1e7 100644 --- a/crates/core/tedge/src/cli/connect/command.rs +++ b/crates/core/tedge/src/cli/connect/command.rs @@ -18,6 +18,8 @@ use crate::ConfigError; use anyhow::anyhow; use anyhow::bail; use c8y_api::http_proxy::read_c8y_credentials; +use c8y_api::smartrest::message::get_smartrest_template_id; +use c8y_api::smartrest::message_ids::JWT_TOKEN; use camino::Utf8PathBuf; use mqtt_channel::Topic; use rumqttc::Event; @@ -507,9 +509,9 @@ fn check_device_status_c8y( Ok(Event::Incoming(Packet::Publish(response))) => { if response.topic == c8y_topic_builtin_jwt_token_downstream { // We got a response - let token = String::from_utf8(response.payload.to_vec()).unwrap(); - // FIXME: what does this magic number mean? - if token.contains("71") { + let response = std::str::from_utf8(&response.payload).unwrap(); + let message_id = get_smartrest_template_id(response); + if message_id.parse() == Ok(JWT_TOKEN) { break; } } else if is_bridge_health_up_message(&response, &built_in_bridge_health) { diff --git a/crates/extensions/c8y_firmware_manager/src/actor.rs b/crates/extensions/c8y_firmware_manager/src/actor.rs index 80a16cd6430..00869fd3441 100644 --- a/crates/extensions/c8y_firmware_manager/src/actor.rs +++ b/crates/extensions/c8y_firmware_manager/src/actor.rs @@ -10,6 +10,7 @@ use crate::worker::OperationOutcome; use async_trait::async_trait; use c8y_api::smartrest::message::collect_smartrest_messages; use c8y_api::smartrest::message::get_smartrest_template_id; +use c8y_api::smartrest::message_ids::FIRMWARE; use c8y_api::smartrest::smartrest_deserializer::SmartRestFirmwareRequest; use c8y_api::smartrest::smartrest_deserializer::SmartRestRequestGeneric; use log::error; @@ -131,18 +132,21 @@ impl FirmwareManagerActor { message: MqttMessage, ) -> Result<(), FirmwareManagementError> { for smartrest_message in collect_smartrest_messages(message.payload_str()?) { - let result = match get_smartrest_template_id(&smartrest_message).as_str() { - "515" => match SmartRestFirmwareRequest::from_smartrest(&smartrest_message) { - Ok(firmware_request) => { - // Addressing a new firmware operation to further step. - self.handle_firmware_download_request(firmware_request) - .await - } - Err(_) => { - error!("Incorrect c8y_Firmware SmartREST payload: {smartrest_message}"); - Ok(()) + let smartrest_template_id = get_smartrest_template_id(&smartrest_message); + let result = match smartrest_template_id.as_str().parse::() { + Ok(id) if id == FIRMWARE => { + match SmartRestFirmwareRequest::from_smartrest(&smartrest_message) { + Ok(firmware_request) => { + // Addressing a new firmware operation to further step. + self.handle_firmware_download_request(firmware_request) + .await + } + Err(_) => { + error!("Incorrect c8y_Firmware SmartREST payload: {smartrest_message}"); + Ok(()) + } } - }, + } _ => { // Ignore operation messages not meant for this plugin Ok(()) diff --git a/crates/extensions/c8y_firmware_manager/src/tests.rs b/crates/extensions/c8y_firmware_manager/src/tests.rs index 16369135eb9..8c91abad758 100644 --- a/crates/extensions/c8y_firmware_manager/src/tests.rs +++ b/crates/extensions/c8y_firmware_manager/src/tests.rs @@ -3,6 +3,7 @@ use assert_json_diff::assert_json_include; use c8y_api::http_proxy::C8yEndPoint; use c8y_api::proxy_url::Protocol; use c8y_api::proxy_url::ProxyUrlGenerator; +use c8y_api::smartrest::message_ids::FIRMWARE; use c8y_api::smartrest::topic::C8yTopic; use serde_json::json; use sha256::digest; @@ -575,7 +576,7 @@ async fn publish_smartrest_firmware_operation( ) -> Result<(), DynError> { let c8y_firmware_update_msg = MqttMessage::new( &Topic::new_unchecked("c8y/s/ds"), - format!("515,{CHILD_DEVICE_ID},{FIRMWARE_NAME},{FIRMWARE_VERSION},{DOWNLOAD_URL}"), + format!("{FIRMWARE},{CHILD_DEVICE_ID},{FIRMWARE_NAME},{FIRMWARE_VERSION},{DOWNLOAD_URL}"), ); mqtt_message_box.send(c8y_firmware_update_msg).await?; Ok(()) diff --git a/crates/extensions/c8y_firmware_manager/src/worker.rs b/crates/extensions/c8y_firmware_manager/src/worker.rs index 09c9cdb11f3..786e806b333 100644 --- a/crates/extensions/c8y_firmware_manager/src/worker.rs +++ b/crates/extensions/c8y_firmware_manager/src/worker.rs @@ -5,6 +5,7 @@ use crate::mpsc; use crate::operation::FirmwareOperationEntry; use crate::operation::OperationKey; use crate::FirmwareManagerConfig; +use c8y_api::smartrest::message_ids::GET_PENDING_OPERATIONS; use c8y_api::smartrest::smartrest_deserializer::SmartRestFirmwareRequest; use c8y_api::smartrest::smartrest_serializer::fail_operation_with_name; use c8y_api::smartrest::smartrest_serializer::set_operation_executing_with_name; @@ -398,10 +399,11 @@ impl FirmwareManagerWorker { &mut self, operation_entry: &FirmwareOperationEntry, ) -> Result<(), FirmwareManagementError> { + use c8y_api::smartrest::message_ids::SET_FIRMWARE; let c8y_child_topic = C8yTopic::ChildSmartRestResponse(operation_entry.child_id.clone()) .to_topic(&self.config.c8y_prefix)?; let installed_firmware_payload = format!( - "115,{},{},{}", + "{SET_FIRMWARE},{},{},{}", operation_entry.name, operation_entry.version, operation_entry.server_url ); let installed_firmware_message = @@ -437,7 +439,7 @@ impl FirmwareManagerWorker { ) -> Result<(), FirmwareManagementError> { let message = MqttMessage::new( &C8yTopic::SmartRestResponse.to_topic(&self.config.c8y_prefix)?, - "500", + GET_PENDING_OPERATIONS.to_string(), ); self.mqtt_publisher.send(message).await?; Ok(()) diff --git a/crates/extensions/c8y_mapper_ext/src/operations/convert.rs b/crates/extensions/c8y_mapper_ext/src/operations/convert.rs index de1a56ebd56..fab5f996e76 100644 --- a/crates/extensions/c8y_mapper_ext/src/operations/convert.rs +++ b/crates/extensions/c8y_mapper_ext/src/operations/convert.rs @@ -5,6 +5,8 @@ use c8y_api::json_c8y_deserializer::C8yDownloadConfigFile; use c8y_api::json_c8y_deserializer::C8yFirmware; use c8y_api::json_c8y_deserializer::C8yLogfileRequest; use c8y_api::json_c8y_deserializer::C8yUploadConfigFile; +use c8y_api::smartrest::message_ids::SET_SUPPORTED_CONFIGURATIONS; +use c8y_api::smartrest::message_ids::SET_SUPPORTED_LOGS; use serde_json::Value; use std::sync::Arc; use tedge_api::commands::CommandStatus; @@ -173,7 +175,7 @@ impl CumulocityConverter { let mut types = metadata.types; types.sort(); let supported_log_types = types.join(","); - let payload = format!("118,{supported_log_types}"); + let payload = format!("{SET_SUPPORTED_LOGS},{supported_log_types}"); let c8y_topic = self.smartrest_publish_topic_for_entity(topic_id)?; messages.push(MqttMessage::new(&c8y_topic, payload)); @@ -306,7 +308,7 @@ impl CumulocityConverter { let mut types = metadata.types; types.sort(); let supported_config_types = types.join(","); - let payload = format!("119,{supported_config_types}"); + let payload = format!("{SET_SUPPORTED_CONFIGURATIONS},{supported_config_types}"); let sm_topic = self.smartrest_publish_topic_for_entity(topic_id)?; messages.push(MqttMessage::new(&sm_topic, payload));