summaryrefslogtreecommitdiffstats
path: root/crates/core/c8y_smartrest
diff options
context:
space:
mode:
authorinitard <alex.solomes@softwareag.com>2021-11-26 15:30:42 +0000
committerGitHub <noreply@github.com>2021-11-26 15:30:42 +0000
commit07052edcb05d176f565db421b04d5f2453abf590 (patch)
tree3e7f0bbc28435aad40ed5c9b51d26afc12589589 /crates/core/c8y_smartrest
parent47c52a679d8e0ca6c63c693cf1e21eeccd02230c (diff)
[CIT-659] restart device local operation (#591)
* [CIT-659] operation status rename Signed-off-by: Alex <solo@softwareag.com> * [CIT-659] OperationStatus rename Signed-off-by: Alex <solo@softwareag.com> * [CIT-659] adding new structs to lib import Signed-off-by: Alex <solo@softwareag.com> * [CIT-659] restart operation implementation Signed-off-by: Alex <solo@softwareag.com> * [CIT-659] restart operation check (WIP) Signed-off-by: Alex <solo@softwareag.com> * [CIT-659] wip Signed-off-by: Alex <solo@softwareag.com> * [CIT-659] restart operation check when /run/tedge_agent_restart persists after operation Signed-off-by: Alex <solo@softwareag.com> * [CIT-659] stash merge Signed-off-by: initard <solo@softwareag.com> * [CIT-659] restart operation refactoring, - chrono dependency Signed-off-by: initard <solo@softwareag.com> * [CIT-659] removed package feature, made file creation more explicit Signed-off-by: initard <solo@softwareag.com> * [CIT-659] dealing with some unwraps and error handling Signed-off-by: initard <solo@softwareag.com> * [CIT-659] reverting changes to operation_logs + error handling Signed-off-by: initard <solo@softwareag.com> * [CIT-659] changed operation from echo 6 to init 6 Signed-off-by: initard <solo@softwareag.com> * [CIT-659] fixing restart check logic Signed-off-by: initard <solo@softwareag.com> * [CIT-659] refactored error handling and added unit test for /run/tedge_agent_restart Signed-off-by: initard <solo@softwareag.com> * [CIT-659] refactoring of tests Signed-off-by: initard <solo@softwareag.com> * [CIT-659] ignored failed test Signed-off-by: initard <solo@softwareag.com> Co-authored-by: Alex <solo@softwareag.com>
Diffstat (limited to 'crates/core/c8y_smartrest')
-rw-r--r--crates/core/c8y_smartrest/src/smartrest_deserializer.rs1
-rw-r--r--crates/core/c8y_smartrest/src/smartrest_serializer.rs8
2 files changed, 5 insertions, 4 deletions
diff --git a/crates/core/c8y_smartrest/src/smartrest_deserializer.rs b/crates/core/c8y_smartrest/src/smartrest_deserializer.rs
index 841915b7..d9868e81 100644
--- a/crates/core/c8y_smartrest/src/smartrest_deserializer.rs
+++ b/crates/core/c8y_smartrest/src/smartrest_deserializer.rs
@@ -177,6 +177,7 @@ where
// 2021-10-23T19:03:26+01:00
// so we add a ':'
let mut date_string: String = Deserialize::deserialize(deserializer)?;
+
let str_size = date_string.len();
// check if `date_string` does not have a colon.
let date_string_end = &date_string.split('+').last();
diff --git a/crates/core/c8y_smartrest/src/smartrest_serializer.rs b/crates/core/c8y_smartrest/src/smartrest_serializer.rs
index 81e7ed4f..6504567d 100644
--- a/crates/core/c8y_smartrest/src/smartrest_serializer.rs
+++ b/crates/core/c8y_smartrest/src/smartrest_serializer.rs
@@ -1,6 +1,6 @@
use crate::error::SmartRestSerializerError;
use csv::{QuoteStyle, WriterBuilder};
-use json_sm::{SoftwareOperationStatus, SoftwareUpdateResponse};
+use json_sm::{OperationStatus, SoftwareUpdateResponse};
use serde::{Deserialize, Serialize, Serializer};
type SmartRest = String;
@@ -104,7 +104,7 @@ impl SmartRestSetOperationToExecuting {
response: SoftwareUpdateResponse,
) -> Result<Self, SmartRestSerializerError> {
match response.status() {
- SoftwareOperationStatus::Executing => {
+ OperationStatus::Executing => {
Ok(Self::new(CumulocitySupportedOperations::C8ySoftwareUpdate))
}
_ => Err(SmartRestSerializerError::UnsupportedOperationStatus { response }),
@@ -141,7 +141,7 @@ impl SmartRestSetOperationToSuccessful {
response: SoftwareUpdateResponse,
) -> Result<Self, SmartRestSerializerError> {
match response.status() {
- SoftwareOperationStatus::Successful => {
+ OperationStatus::Successful => {
Ok(Self::new(CumulocitySupportedOperations::C8ySoftwareUpdate))
}
_ => Err(SmartRestSerializerError::UnsupportedOperationStatus { response }),
@@ -172,7 +172,7 @@ impl SmartRestSetOperationToFailed {
response: SoftwareUpdateResponse,
) -> Result<Self, SmartRestSerializerError> {
match &response.status() {
- SoftwareOperationStatus::Failed => Ok(Self::new(
+ OperationStatus::Failed => Ok(Self::new(
CumulocitySupportedOperations::C8ySoftwareUpdate,
response.error().unwrap_or_else(|| "".to_string()),
)),