Skip to content

Commit

Permalink
Merge pull request #2341 from rina23q/fix/inconsistent-log-management…
Browse files Browse the repository at this point in the history
…-key

Rename c8y.enable.log_management to c8y.enable.log_upload
  • Loading branch information
rina23q authored Oct 17, 2023
2 parents d98d5e2 + 8a807fd commit d39c1c2
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,9 @@ define_tedge_config! {
topics: TemplatesSet,

enable: {
/// Enable log management
#[tedge_config(example = "true", default(value = true))]
log_management: bool,
/// Enable log_upload feature
#[tedge_config(example = "true", default(value = true), deprecated_name = "log_management")]
log_upload: bool,

/// Enable config_snapshot feature
#[tedge_config(example = "true", default(value = false))]
Expand Down
4 changes: 2 additions & 2 deletions crates/extensions/c8y_mapper_ext/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl C8yMapperConfig {
let tedge_http_host = format!("{}:{}", tedge_http_address, tedge_http_port);

let capabilities = Capabilities {
log_management: tedge_config.c8y.enable.log_management,
log_upload: tedge_config.c8y.enable.log_upload,
config_snapshot: tedge_config.c8y.enable.config_snapshot,
config_update: tedge_config.c8y.enable.config_update,
};
Expand All @@ -103,7 +103,7 @@ impl C8yMapperConfig {
// Add feature topic filters
topics.add_all(mqtt_schema.topics(AnyEntity, Command(OperationType::Restart)));
topics.add_all(mqtt_schema.topics(AnyEntity, CommandMetadata(OperationType::Restart)));
if capabilities.log_management {
if capabilities.log_upload {
topics.add_all(crate::log_upload::log_upload_topic_filter(&mqtt_schema));
}
if capabilities.config_snapshot {
Expand Down
4 changes: 2 additions & 2 deletions crates/extensions/c8y_mapper_ext/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ mod tests;

#[derive(Debug, serde::Deserialize)]
pub struct Capabilities {
log_management: bool,
log_upload: bool,
config_snapshot: bool,
config_update: bool,
}

impl Default for Capabilities {
fn default() -> Self {
Capabilities {
log_management: true,
log_upload: true,
config_snapshot: true,
config_update: true,
}
Expand Down
15 changes: 9 additions & 6 deletions crates/extensions/c8y_mapper_ext/src/log_upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use tedge_mqtt_ext::QoS;
use tedge_mqtt_ext::TopicFilter;
use tedge_utils::file::create_directory_with_defaults;
use tedge_utils::file::create_file_with_defaults;
use tracing::log::warn;

pub fn log_upload_topic_filter(mqtt_schema: &MqttSchema) -> TopicFilter {
[
Expand All @@ -43,8 +44,10 @@ impl CumulocityConverter {
&self,
smartrest: &str,
) -> Result<Vec<Message>, CumulocityMapperError> {
if !self.config.capabilities.log_management {
// Log_management is disabled
if !self.config.capabilities.log_upload {
warn!(
"Received a c8y_LogfileRequest operation, however, log_upload feature is disabled"
);
return Ok(vec![]);
}

Expand Down Expand Up @@ -93,8 +96,8 @@ impl CumulocityConverter {
cmd_id: &str,
message: &Message,
) -> Result<Vec<Message>, ConversionError> {
if !self.config.capabilities.log_management {
// Log_management is disabled
if !self.config.capabilities.log_upload {
warn!("Received a log_upload command, however, log_upload feature is disabled");
return Ok(vec![]);
}

Expand Down Expand Up @@ -175,8 +178,8 @@ impl CumulocityConverter {
topic_id: &EntityTopicId,
message: &Message,
) -> Result<Vec<Message>, ConversionError> {
if !self.config.capabilities.log_management {
// Log_management is disabled
if !self.config.capabilities.log_upload {
warn!("Received log_upload metadata, however, log_upload feature is disabled");
return Ok(vec![]);
}

Expand Down
17 changes: 9 additions & 8 deletions docs/src/references/mqtt-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -553,14 +553,15 @@ Where the command segments are describe as follows:

The following table details some example command types which are supported by thin-edge.

|Command Type|Example Topic|
|------|---|
|software_list|`te/<identifier>/cmd/software_list/<cmd_id>`|
|software_update|`te/<identifier>/cmd/software_update/<cmd_id>`|
|config_snapshot|`te/<identifier>/cmd/config_snapshot/<cmd_id>`|
|config_update|`te/<identifier>/cmd/config_update/<cmd_id>`|
|firmware_update|`te/<identifier>/cmd/firmware_update/<cmd_id>`|
|restart|`te/<identifier>/cmd/restart/<cmd_id>`|
| Command Type | Example Topic |
|-----------------|------------------------------------------------|
| software_list | `te/<identifier>/cmd/software_list/<cmd_id>` |
| software_update | `te/<identifier>/cmd/software_update/<cmd_id>` |
| config_snapshot | `te/<identifier>/cmd/config_snapshot/<cmd_id>` |
| config_update | `te/<identifier>/cmd/config_update/<cmd_id>` |
| firmware_update | `te/<identifier>/cmd/firmware_update/<cmd_id>` |
| restart | `te/<identifier>/cmd/restart/<cmd_id>` |
| log_upload | `te/<identifier>/cmd/log_upload/<cmd_id>` |

The command would be interpreted differently based on the target entity.
For example, the `restart` could mean either a device restart or a service restart based on the target entity.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Custom Setup

${parent_ip}= Get IP Address
Set Suite Variable $PARENT_IP ${parent_ip}
Execute Command sudo tedge config set c8y.enable.log_management true
Execute Command sudo tedge config set c8y.enable.log_upload true
Execute Command sudo tedge config set mqtt.external.bind.address ${PARENT_IP}
Execute Command sudo tedge config set mqtt.external.bind.port 1883

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Custom Setup

${parent_ip}= Get IP Address
Set Suite Variable $PARENT_IP ${parent_ip}
Execute Command sudo tedge config set c8y.enable.log_management true
Execute Command sudo tedge config set c8y.enable.log_upload true
Execute Command sudo tedge config set mqtt.external.bind.address ${PARENT_IP}
Execute Command sudo tedge config set mqtt.external.bind.port 1883

Expand Down

1 comment on commit d39c1c2

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
319 0 3 319 100 51m30.433999999s

Please sign in to comment.