blob: 446bee97e971ce2556ffa563db67842253a5ee2a [file] [log] [blame]
John Edward Broadbente6ffe702021-10-14 14:03:11 -07001#include "verifyDriveGeometry.hpp"
2
3#include "estoraged_conf.hpp"
4
5#include <phosphor-logging/lg2.hpp>
John Wedig972c3fa2021-12-29 17:30:41 -08006#include <xyz/openbmc_project/Common/error.hpp>
John Edward Broadbente6ffe702021-10-14 14:03:11 -07007
8#include <string>
9
John Edward Broadbentd3bfa7b2022-01-13 17:41:32 -080010namespace estoraged
11{
John Wedig972c3fa2021-12-29 17:30:41 -080012using sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
John Edward Broadbente6ffe702021-10-14 14:03:11 -070013
14void VerifyDriveGeometry::geometryOkay(uint64_t bytes)
15{
16 if (bytes > ERASE_MAX_GEOMETRY)
17 {
18 lg2::error("Erase verify Geometry too large", "REDFISH_MESSAGE_ID",
19 std::string("OpenBMC.0.1.DriveEraseFailure"),
20 "REDFISH_MESSAGE_ARGS",
21 std::to_string(bytes) + ">" +
22 std::to_string(ERASE_MAX_GEOMETRY));
John Wedig972c3fa2021-12-29 17:30:41 -080023 throw InternalFailure();
John Edward Broadbente6ffe702021-10-14 14:03:11 -070024 }
Ed Tanous82897c32022-02-21 14:11:59 -080025 if (bytes < ERASE_MIN_GEOMETRY)
John Edward Broadbente6ffe702021-10-14 14:03:11 -070026 {
27 lg2::error(
28 "eStorageD erase verify Geometry too small", "REDFISH_MESSAGE_ID",
29 std::string("OpenBMC.0.1.DriveEraseFailure"),
30 "REDFISH_MESSAGE_ARGS",
31 std::to_string(bytes) + "<" + std::to_string(ERASE_MIN_GEOMETRY));
John Wedig972c3fa2021-12-29 17:30:41 -080032 throw InternalFailure();
John Edward Broadbente6ffe702021-10-14 14:03:11 -070033 }
Ed Tanous82897c32022-02-21 14:11:59 -080034
35 lg2::info("eStorageD erase verify Geometry in range", "REDFISH_MESSAGE_ID",
36 std::string("OpenBMC.0.1.DriveEraseSuccess"));
John Edward Broadbente6ffe702021-10-14 14:03:11 -070037}
John Edward Broadbentd3bfa7b2022-01-13 17:41:32 -080038
39} // namespace estoraged