entity_manager: convert Type to lower case for schema filename
There is an inconsistent string of object type between bmcweb and EM.
When adding StepwiseController via redfish, bmcweb assign "Stepwise" to
"Type" and passes it to EM's AddObject method. In EM's AddObject, EM
retrieves the "Type" value and use it to get schema file.
Because all schema filenames have fully switched to lower case, add
boost::to_lower_copy() to convert "Type" value to get correct filename.
Tested on bletchley:
- send PATCH to add new StepwiseController call "SWTest"
PATCH Body:
{
"Oem": {
"OpenBmc": {
"Fan": {
"StepwiseControllers": {
"SWTest": {
"Direction": "Floor",
"Inputs": [
"MB_U402_THERM_LOCAL"
],
"NegativeHysteresis": 0.0,
"PositiveHysteresis": 0.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"
}
]
}
}
}
}
}
}
Response:
{
"@Message.ExtendedInfo": [
{
"@odata.type": "#Message.v1_1_1.Message",
"Message": "The request completed successfully.",
"MessageArgs": [],
"MessageId": "Base.1.13.0.Success",
"MessageSeverity": "OK",
"Resolution": "None"
}
]
}
- BMC add new StepwiseController successfully.
root@bletchley:~# busctl introspect xyz.openbmc_project.EntityManager \
> /xyz/openbmc_project/inventory/system/chassis/Bletchley_Chassis/SWTest
NAME TYPE SIGNATURE RESULT/VALUE FLAGS
org.freedesktop.DBus.Introspectable interface - - -
.Introspect method - s -
org.freedesktop.DBus.Peer interface - - -
.GetMachineId method - s -
.Ping method - - -
org.freedesktop.DBus.Properties interface - - -
.Get method ss v -
.GetAll method s a{sv} -
.Set method ssv - -
.PropertiesChanged signal sa{sv}as - -
xyz.openbmc_project.Configuration.Stepwise interface - - -
.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 0 emits-change writable
.Output property ad 2 0 15 emits-change writable
.PositiveHysteresis property d 0 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
Signed-off-by: Potin Lai <potin.lai@quantatw.com>
Change-Id: I6498125bf108e005d5d138a0d7798d92558ed44c
diff --git a/src/entity_manager.cpp b/src/entity_manager.cpp
index a20ac67..12c57c5 100644
--- a/src/entity_manager.cpp
+++ b/src/entity_manager.cpp
@@ -507,7 +507,7 @@
}
std::ifstream schemaFile(std::string(schemaDirectory) + "/" +
- *type + ".json");
+ boost::to_lower_copy(*type) + ".json");
// todo(james) we might want to also make a list of 'can add'
// interfaces but for now I think the assumption if there is a
// schema avaliable that it is allowed to update is fine