From 8be2b5b64adb5800c02e62bd484e40d38978e152 Mon Sep 17 00:00:00 2001 From: Potin Lai Date: Tue, 22 Nov 2022 13:27:16 +0800 Subject: managers: fix interface patch and delete of pid object Only set createNewObject to true when corresponding interface not found in the object. Tested on Bletchley: - Add new StepwiseController called SWTest Body in JSON format ``` { "Oem": { "OpenBmc": { "Fan": { "StepwiseControllers": { "SWTest": { "Direction": "Floor", "Inputs": [ "MB_U402_THERM_LOCAL" ], "NegativeHysteresis": 1.0, "PositiveHysteresis": 2.0, "Steps": [ { "Output": 0.0, "Target": 48.0 }, { "Output": 15.0, "Target": 49.0 } ], "Zones": [ { "@odata.id": "/redfish/v1/Managers/bmc#/Oem/OpenBmc/Fan/FanZones/Zone0" } ] } } } } } } ``` Checking object from dbus ``` root@bletchley:~# busctl introspect xyz.openbmc_project.EntityManager \ > /xyz/openbmc_project/inventory/system/chassis/Bletchley_Chassis/SWTest \ > xyz.openbmc_project.Configuration.Stepwise NAME TYPE SIGNATURE RESULT/VALUE FLAGS .Delete method - - - .Class property s "Floor" emits-change writable .Inputs property as 1 "MB U402 THERM LOCAL" emits-change writable .Name property s "SWTest" emits-change writable .NegativeHysteresis property d 1 emits-change writable .Output property ad 2 0 15 emits-change writable .PositiveHysteresis property d 2 emits-change writable .Reading property ad 2 48 49 emits-change writable .Type property s "Stepwise" emits-change writable .Zones property as 1 "Zone0" emits-change writable ``` - Patch SWTest properties Body in JSON format ``` { "Oem": { "OpenBmc": { "Fan": { "StepwiseControllers": { "SWTest": { "NegativeHysteresis": 3.0, "PositiveHysteresis": 4.0 } } } } } } ``` Checking object from dbus ``` root@bletchley:~# busctl introspect xyz.openbmc_project.EntityManager \ > /xyz/openbmc_project/inventory/system/chassis/Bletchley_Chassis/SWTest \ > xyz.openbmc_project.Configuration.Stepwise NAME TYPE SIGNATURE RESULT/VALUE FLAGS .Delete method - - - .Class property s "Floor" emits-change writable .Inputs property as 1 "MB U402 THERM LOCAL" emits-change writable .Name property s "SWTest" emits-change writable .NegativeHysteresis property d 3 emits-change writable .Output property ad 2 0 15 emits-change writable .PositiveHysteresis property d 4 emits-change writable .Reading property ad 2 48 49 emits-change writable .Type property s "Stepwise" emits-change writable .Zones property as 1 "Zone0" emits-change writable ``` - Delete SWTest object Body in JSON format ``` { "Oem": { "OpenBmc": { "Fan": { "StepwiseControllers": { "SWTest": null } } } } } ``` Object deleted from dbus ``` root@bletchley:~# busctl introspect xyz.openbmc_project.EntityManager \ > /xyz/openbmc_project/inventory/system/chassis/Bletchley_Chassis/SWTest \ > xyz.openbmc_project.Configuration.Stepwise Failed to introspect object /xyz/openbmc_project/inventory/system/chassis/Bletchley_Chassis/SWTest of service xyz.openbmc_project.EntityManager: Unknown object '/xyz/openbmc_project/inventory/system/chassis/Bletchley_Chassis/SWTest'. ``` Signed-off-by: Potin Lai Change-Id: I482e942ee3c76dca17af522765d8b3aa9dc8678b --- redfish-core/lib/managers.hpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'redfish-core/lib/managers.hpp') diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp index 19c43f1948..55c3949cae 100644 --- a/redfish-core/lib/managers.hpp +++ b/redfish-core/lib/managers.hpp @@ -1552,6 +1552,7 @@ struct SetPIDValues : std::enable_shared_from_this std::string iface; if (!createNewObject) { + bool findInterface = false; for (const auto& interface : pathItr->second) { if (interface.first == pidConfigurationIface) @@ -1560,7 +1561,8 @@ struct SetPIDValues : std::enable_shared_from_this type == "FanControllers") { iface = pidConfigurationIface; - createNewObject = true; + findInterface = true; + break; } } else if (interface.first == pidZoneConfigurationIface) @@ -1568,7 +1570,8 @@ struct SetPIDValues : std::enable_shared_from_this if (type == "FanZones") { iface = pidConfigurationIface; - createNewObject = true; + findInterface = true; + break; } } else if (interface.first == stepwiseConfigurationIface) @@ -1576,10 +1579,17 @@ struct SetPIDValues : std::enable_shared_from_this if (type == "StepwiseControllers") { iface = stepwiseConfigurationIface; - createNewObject = true; + findInterface = true; + break; } } } + + // create new object if interface not found + if (!findInterface) + { + createNewObject = true; + } } if (createNewObject && it.value() == nullptr) -- cgit v1.2.3