entity-manager: extract postConfigurationRecord
Extract function postConfigurationRecord from function
postExposesRecordsToDBus.
The newly created function handles the creation of nested dbus
interfaces from object and array properties in exposes records.
What's been changed:
- Extract function with return type bool
- Bool gets mapped as false, true -> break, continue to keep the
original control flow.
- All parameters are passed as references
Tested: on Tyan S8030
```
root@s8030-bmc-30303035c0c1:~# busctl tree xyz.openbmc_project.EntityManager
`- /xyz
`- /xyz/openbmc_project
|- /xyz/openbmc_project/EntityManager
`- /xyz/openbmc_project/inventory
`- /xyz/openbmc_project/inventory/system
|- /xyz/openbmc_project/inventory/system/board
| `- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard
| |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/CPU0_Power_Consumption
| |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/CPU0_Temp
| |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/GARBO_SENSOR
| |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/HostSPIFlash
| |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/P0_VDD_18_RUN
| |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/P0_VDD_CORE_RUN
| |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/P0_VDD_MEM_ABCD
| |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/P0_VDD_MEM_EFGH
| |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/P0_VDD_SOC_RUN
| |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/VBAT_33
| |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/VDD_12_RUN
| |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/VDD_33_DUAL
| |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/VDD_33_RUN
| |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/VDD_5_DUAL
| |- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/VDD_5_RUN
| `- /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/X550
|- /xyz/openbmc_project/inventory/system/chassis
| `- /xyz/openbmc_project/inventory/system/chassis/MBX_1_57_Chassis
| |- /xyz/openbmc_project/inventory/system/chassis/MBX_1_57_Chassis/Fan_Control
| |- /xyz/openbmc_project/inventory/system/chassis/MBX_1_57_Chassis/NIC_1_Ignore
| |- /xyz/openbmc_project/inventory/system/chassis/MBX_1_57_Chassis/NIC_2_Ignore
| |- /xyz/openbmc_project/inventory/system/chassis/MBX_1_57_Chassis/NIC_FRU_1
| |- /xyz/openbmc_project/inventory/system/chassis/MBX_1_57_Chassis/NIC_FRU_2
| |- /xyz/openbmc_project/inventory/system/chassis/MBX_1_57_Chassis/SYS_FAN_1
| |- /xyz/openbmc_project/inventory/system/chassis/MBX_1_57_Chassis/SYS_FAN_2
| |- /xyz/openbmc_project/inventory/system/chassis/MBX_1_57_Chassis/SYS_FAN_3
| |- /xyz/openbmc_project/inventory/system/chassis/MBX_1_57_Chassis/Temperature_Control
| `- /xyz/openbmc_project/inventory/system/chassis/MBX_1_57_Chassis/Zone0
`- /xyz/openbmc_project/inventory/system/powersupply
|- /xyz/openbmc_project/inventory/system/powersupply/Supermicro_PWS_920P_SQ_0
| |- /xyz/openbmc_project/inventory/system/powersupply/Supermicro_PWS_920P_SQ_0/PSU0
| |- /xyz/openbmc_project/inventory/system/powersupply/Supermicro_PWS_920P_SQ_0/PSU0_ADDR
| `- /xyz/openbmc_project/inventory/system/powersupply/Supermicro_PWS_920P_SQ_0/PSU0_FRU
`- /xyz/openbmc_project/inventory/system/powersupply/Supermicro_PWS_920P_SQ_1
|- /xyz/openbmc_project/inventory/system/powersupply/Supermicro_PWS_920P_SQ_1/PSU1
|- /xyz/openbmc_project/inventory/system/powersupply/Supermicro_PWS_920P_SQ_1/PSU1_ADDR
`- /xyz/openbmc_project/inventory/system/powersupply/Supermicro_PWS_920P_SQ_1/PSU1_FRU
```
Checking individual record
```
root@s8030-bmc-30303035c0c1:~# busctl introspect xyz.openbmc_project.EntityManager /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/VBAT_33
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
...
xyz.openbmc_project.Configuration.ADC interface - - -
.Index property t 10 emits-change
.Name property s "VBAT_33" emits-change
.PowerState property s "Always" emits-change
.ScaleFactor property d 0.3333 emits-change
.Type property s "ADC" emits-change
xyz.openbmc_project.Configuration.ADC.Thresholds0 interface - - -
.Delete method - - -
.Direction property s "greater than" emits-change
.Name property s "upper critical" emits-change
.Severity property d 1 emits-change
.Value property d 3.507 emits-change
xyz.openbmc_project.Configuration.ADC.Thresholds1 interface - - -
.Delete method - - -
.Direction property s "less than" emits-change
.Name property s "lower critical" emits-change
.Severity property d 1 emits-change
.Value property d 2.688 emits-change
```
Another record with nested object
```
root@s8030-bmc-30303035c0c1:~# busctl introspect xyz.openbmc_project.EntityManager /xyz/openbmc_project/inventory/system/board/Tyan_S8030_Baseboard/HostSPIFlash
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
...
xyz.openbmc_project.Configuration.SPIFlash interface - - -
.Name property s "HostSPIFlash" emits-change
.SPIControllerIndex property t 1 emits-change
.SPIDeviceIndex property t 0 emits-change
.Type property s "SPIFlash" emits-change
xyz.openbmc_project.Configuration.SPIFlash.FirmwareInfo interface - - -
.CompatibleHardware property s "com.tyan.Hardware.S8030.SPI.Host" emits-change
.VendorIANA property t 6653 emits-change
xyz.openbmc_project.Configuration.SPIFlash.MuxOutputs0 interface - - -
.Name property s "BMC_SPI_SEL" emits-change
.Polarity property s "High" emits-change
```
Change-Id: I1d9ace86b62ed5131c3405d13c5034f4d7770ec7
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/src/entity_manager/entity_manager.hpp b/src/entity_manager/entity_manager.hpp
index 9a5a451..33efb31 100644
--- a/src/entity_manager/entity_manager.hpp
+++ b/src/entity_manager/entity_manager.hpp
@@ -60,6 +60,12 @@
const std::string& jsonPointerPathBoard, const std::string& boardPath,
const std::string& boardType);
+ // @returns false on error
+ bool postConfigurationRecord(
+ const std::string& name, nlohmann::json& config,
+ const std::string& boardNameOrig, const std::string& itemType,
+ const std::string& jsonPointerPath, const std::string& ifacePath);
+
void pruneConfiguration(bool powerOff, const std::string& name,
const nlohmann::json& device);