Seal "NotConnected" usage
When media is disconnected, "NotConnected" field did not exist. This
change adds default value of this field for all code paths.
Tested:
curl -X GET https://some_addr/redfish/v1/Managers/bmc/VirtualMedia/Legacy
{
"@odata.id": "/redfish/v1/Managers/bmc/VirtualMedia/Legacy",
"@odata.type": "#VirtualMedia.v1_3_0.VirtualMedia",
"Actions": {
"#VirtualMedia.EjectMedia": {
"target": "/redfish/v1/Managers/bmc/VirtualMedia/Legacy/Actions/VirtualMedia.EjectMedia"
},
"#VirtualMedia.InsertMedia": {
"target": "/redfish/v1/Managers/bmc/VirtualMedia/Legacy/Actions/VirtualMedia.InsertMedia"
}
},
"ConnectedVia": "NotConnected",
"Id": "Legacy",
"Inserted": false,
"MediaTypes": [
"CD",
"USBStick"
],
"Name": "Virtual Removable Media",
"Oem": {
"OpenBMC": {
"@odata.type": "#OemVirtualMedia.v1_0_0.VirtualMedia"
}
},
"TransferMethod": "Stream",
"WriteProtected": true
}
Change-Id: I5e0789947e092907abe1bc353aebc07a4fb87274
Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
Signed-off-by: Ed Tanous <edtanous@google.com>
diff --git a/redfish-core/lib/virtual_media.hpp b/redfish-core/lib/virtual_media.hpp
index 2e632f8..405de77 100644
--- a/redfish-core/lib/virtual_media.hpp
+++ b/redfish-core/lib/virtual_media.hpp
@@ -18,6 +18,7 @@
#include "account_service.hpp"
#include "app.hpp"
#include "dbus_utility.hpp"
+#include "generated/enums/virtual_media.hpp"
#include "query.hpp"
#include "registries/privilege_registry.hpp"
#include "utils/json_utils.hpp"
@@ -158,7 +159,8 @@
aResp->res.jsonValue["TransferProtocolType"] =
getTransferProtocolTypeFromUri(*imageUrlValue);
- aResp->res.jsonValue["ConnectedVia"] = "URI";
+ aResp->res.jsonValue["ConnectedVia"] =
+ virtual_media::ConnectedVia::URI;
}
}
if (property == "WriteProtected")
@@ -188,7 +190,8 @@
if (*activeValue)
{
- aResp->res.jsonValue["ConnectedVia"] = "Applet";
+ aResp->res.jsonValue["ConnectedVia"] =
+ virtual_media::ConnectedVia::Applet;
}
}
}
@@ -210,6 +213,7 @@
item["Name"] = "Virtual Removable Media";
item["Id"] = resName;
item["WriteProtected"] = true;
+ item["ConnectedVia"] = virtual_media::ConnectedVia::NotConnected;
item["MediaTypes"] = nlohmann::json::array_t({"CD", "USBStick"});
item["TransferMethod"] = "Stream";
item["Oem"]["OpenBMC"]["@odata.type"] =