1 #include "verifyDriveGeometry.hpp"
2 
3 #include <phosphor-logging/lg2.hpp>
4 #include <xyz/openbmc_project/Common/error.hpp>
5 
6 #include <string>
7 
8 namespace estoraged
9 {
10 using sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
11 
geometryOkay(uint64_t eraseMaxGeometry,uint64_t eraseMinGeometry,uint64_t bytes)12 void VerifyDriveGeometry::geometryOkay(
13     uint64_t eraseMaxGeometry, uint64_t eraseMinGeometry, uint64_t bytes)
14 {
15     if (bytes > eraseMaxGeometry)
16     {
17         lg2::error("Erase verify Geometry too large", "REDFISH_MESSAGE_ID",
18                    std::string("OpenBMC.0.1.DriveEraseFailure"),
19                    "REDFISH_MESSAGE_ARGS",
20                    std::to_string(bytes) + ">" +
21                        std::to_string(eraseMaxGeometry));
22         throw InternalFailure();
23     }
24     if (bytes < eraseMinGeometry)
25     {
26         lg2::error(
27             "eStorageD erase verify Geometry too small", "REDFISH_MESSAGE_ID",
28             std::string("OpenBMC.0.1.DriveEraseFailure"),
29             "REDFISH_MESSAGE_ARGS",
30             std::to_string(bytes) + "<" + std::to_string(eraseMinGeometry));
31         throw InternalFailure();
32     }
33 
34     lg2::info("eStorageD erase verify Geometry in range", "REDFISH_MESSAGE_ID",
35               std::string("OpenBMC.0.1.DriveEraseSuccess"));
36 }
37 
38 } // namespace estoraged
39