Fix Image and ImageName values in schema
According to design document and schema Image shall contain URL of
image location and ImageName only name of the image.
Testing:
Manual tests with mounting resource and checking redfish item.
Change-Id: Ie1a906c66aa2a10113c307eb1e7d2d7da2810fbd
Signed-off-by: Przemyslaw Czarnowski <przemyslaw.hawrylewicz.czarnowski@intel.com>
diff --git a/redfish-core/lib/virtual_media.hpp b/redfish-core/lib/virtual_media.hpp
index a921dcb..1336190 100644
--- a/redfish-core/lib/virtual_media.hpp
+++ b/redfish-core/lib/virtual_media.hpp
@@ -97,7 +97,19 @@
std::get_if<std::string>(&imageUrlProperty->second);
if (imageUrlValue && !imageUrlValue->empty())
{
- aResp->res.jsonValue["ImageName"] = *imageUrlValue;
+ std::filesystem::path filePath = *imageUrlValue;
+ if (!filePath.has_filename())
+ {
+ // this will handle https share, which not necessarily
+ // has to have filename given.
+ aResp->res.jsonValue["ImageName"] = "";
+ }
+ else
+ {
+ aResp->res.jsonValue["ImageName"] = filePath.filename();
+ }
+
+ aResp->res.jsonValue["Image"] = *imageUrlValue;
aResp->res.jsonValue["Inserted"] = *activeValue;
if (*activeValue == true)
{
@@ -121,15 +133,9 @@
item["@odata.type"] = "#VirtualMedia.v1_3_0.VirtualMedia";
item["Name"] = "Virtual Removable Media";
item["Id"] = resName;
- item["Image"] = nullptr;
- item["Inserted"] = nullptr;
- item["ImageName"] = nullptr;
item["WriteProtected"] = true;
- item["ConnectedVia"] = "NotConnected";
item["MediaTypes"] = {"CD", "USBStick"};
item["TransferMethod"] = "Stream";
- item["TransferProtocolType"] = nullptr;
- item["Oem"]["OpenBMC"]["WebSocketEndpoint"] = nullptr;
item["Oem"]["OpenBMC"]["@odata.type"] =
"#OemVirtualMedia.v1_0_0.VirtualMedia";