File tree Expand file tree Collapse file tree 9 files changed +46
-2
lines changed
common/tedge_config/src/tedge_toml
tedge_config/mapper_config
extensions/c8y_mapper_ext/src Expand file tree Collapse file tree 9 files changed +46
-2
lines changed Original file line number Diff line number Diff line change @@ -699,6 +699,10 @@ define_tedge_config! {
699699 /// Enable device_profile feature
700700 #[ tedge_config( example = "true" , default ( value = true ) ) ]
701701 device_profile: bool ,
702+
703+ /// Enable device restart feature
704+ #[ tedge_config( example = "true" , default ( value = true ) ) ]
705+ device_restart: bool ,
702706 } ,
703707
704708 mapper: {
Original file line number Diff line number Diff line change @@ -128,6 +128,7 @@ impl FromCloudConfig for C8yMapperSpecificConfig {
128128 config_update : c8y. enable . config_update ,
129129 firmware_update : c8y. enable . firmware_update ,
130130 device_profile : c8y. enable . device_profile ,
131+ device_restart : c8y. enable . device_restart ,
131132 } ,
132133 mqtt_service : MqttServiceConfig {
133134 enabled : c8y. mqtt_service . enabled ,
Original file line number Diff line number Diff line change @@ -384,6 +384,9 @@ pub struct EnableConfig {
384384
385385 /// Enable device_profile feature
386386 pub device_profile : bool ,
387+
388+ /// Enable device restart feature
389+ pub device_restart : bool ,
387390}
388391
389392/// Bridge include configuration
Original file line number Diff line number Diff line change @@ -201,6 +201,7 @@ impl C8yMapperConfig {
201201 config_update : c8y_config. cloud_specific . enable . config_update ,
202202 firmware_update : c8y_config. cloud_specific . enable . firmware_update ,
203203 device_profile : c8y_config. cloud_specific . enable . device_profile ,
204+ device_restart : c8y_config. cloud_specific . enable . device_restart ,
204205 } ;
205206 let bridge_config = BridgeConfig {
206207 c8y_prefix : c8y_config. bridge . topic_prefix . clone ( ) ,
Original file line number Diff line number Diff line change @@ -657,7 +657,12 @@ impl CumulocityConverter {
657657
658658 let msgs = match C8yDeviceControlOperation :: from_json_object ( extras) ? {
659659 C8yDeviceControlOperation :: Restart ( _) => {
660- self . forward_restart_request ( device_xid, cmd_id) ?
660+ if self . config . capabilities . device_restart {
661+ self . forward_restart_request ( device_xid, cmd_id) ?
662+ } else {
663+ warn ! ( "Received a c8y_Restart operation, however, device_restart feature is disabled" ) ;
664+ vec ! [ ]
665+ }
661666 }
662667 C8yDeviceControlOperation :: SoftwareUpdate ( request) => {
663668 self . forward_software_request ( device_xid, cmd_id, request)
@@ -1540,6 +1545,11 @@ impl CumulocityConverter {
15401545 & mut self ,
15411546 target : & EntityTopicId ,
15421547 ) -> Result < Vec < MqttMessage > , ConversionError > {
1548+ if !self . config . capabilities . device_restart {
1549+ warn ! ( "Received restart metadata, however, device restart feature is disabled" ) ;
1550+ return Ok ( vec ! [ ] ) ;
1551+ }
1552+
15431553 match self . register_operation ( target, "c8y_Restart" ) . await {
15441554 Err ( _) => {
15451555 error ! ( "Fail to register `restart` operation for unknown device: {target}" ) ;
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ pub struct Capabilities {
2626 pub config_update : bool ,
2727 pub firmware_update : bool ,
2828 pub device_profile : bool ,
29+ pub device_restart : bool ,
2930}
3031
3132#[ cfg( test) ]
@@ -37,6 +38,7 @@ impl Default for Capabilities {
3738 config_update : true ,
3839 firmware_update : true ,
3940 device_profile : true ,
41+ device_restart : true ,
4042 }
4143 }
4244}
Original file line number Diff line number Diff line change @@ -251,6 +251,12 @@ impl OperationHandler {
251251 ( AnyEntity , CommandMetadata ( OperationType :: DeviceProfile ) ) ,
252252 ] ) ;
253253 }
254+ if capabilities. device_restart {
255+ topics. extend ( [
256+ ( AnyEntity , Command ( OperationType :: Restart ) ) ,
257+ ( AnyEntity , CommandMetadata ( OperationType :: Restart ) ) ,
258+ ] ) ;
259+ }
254260
255261 topics
256262 }
Original file line number Diff line number Diff line change 11paho-mqtt ~= 1.6.1
22python-dotenv ~= 1.0.0
33robotframework ~= 7.0.0
4- robotframework-c8y @ git+https://github.com/thin-edge/robotframework-c8y.git@0.49 .0
4+ robotframework-c8y @ git+https://github.com/thin-edge/robotframework-c8y.git@0.51 .0
55robotframework-aws @
git+https://github.com/thin-edge/[email protected] 66robotframework-debuglibrary ~= 2.5.0
77robotframework-jsonlibrary ~= 0.5
Original file line number Diff line number Diff line change @@ -32,6 +32,23 @@ tedge-mapper-c8y does not react to local restart operations transitions
3232 topic=te/device/main///cmd/restart/local-2222 payload={"status":"failed"} expected_status=failed c8y_fragment=c8y_Restart
3333 topic=te/device/main///cmd/restart/local-3333 payload={"status":"successful"} expected_status=successful c8y_fragment=c8y_Restart
3434
35+ Supports disabling the Cumulocity c8y_Restart Command
36+ Execute Command tedge config set c8y.enable.device_restart false
37+ Execute Command rm -f /etc/tedge/operations/c8y/c8y_Restart
38+
39+ Restart Service tedge-mapper-c8y
40+ Service Health Status Should Be Up tedge-mapper-c8y
41+ File Should Not Exist /etc/tedge/operations/c8y/c8y_Restart
42+ Should Not Contain Supported Operations c8y_Restart
43+ ${operation } = Cumulocity.Restart Device
44+ Operation Should Be PENDING ${operation } timeout=30
45+
46+ # Cleanup operation for cleaner logs (as pending operations pollute the test report output)
47+ # Note: It does not need to be run under a TearDown hook as this code will only run
48+ # if the operation is not processed, otherwise it would of been processed and thus not need cleaning up
49+ Execute Command tedge mqtt pub c8y/s/us '505,${operation.to_json()["id"] } ,Cancelled operation'
50+ Operation Should Be FAILED ${operation }
51+
3552
3653*** Keywords ***
3754Set Service User
You can’t perform that action at this time.
0 commit comments