-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename Disk stuff -> Drive and teach diskwipe example more tricks (#163)
### What does this PR do The main reason for this PR is to make the diskwipe example a better example of both using ironlib to detect hardware presence and capabilities and using the information to influence actions to be taken. After collecting all the hardware the new example code detects nvme vs sata and detects the features supported by the disk all to decide which is the best tool to wipe the drive. Along the way many refactors stood out as necessary. The main one was blkdiscard did not implement the DiskWiper interface. I also noticed we were using Device when Drive already existed and was more appropriate and that the args and log lines could do with some homogeneity so that they don't appear to be originating from different repositories. Further breakdown of the changes are shown below: #### Make blkdiscard look more like other DiskWipers & utilities I missed this when doing review on the original PR, so doing it now. #### Change wipe examples to all take the same cli args Best to make the examples all actually usable and there's no point to have different arguments so lets make them all similar. #### Rename Disk, device -> Drive, drive I don't want to have 2 names for the same thing and even worse reuse a name that means something completely different in a different context. bmc-toolbox/common already has Drive and Device so lets use Drive and drive for disks and device for Devices. #### Make all WipeDrive methods logs look similar Similar to the cli arg homogeneity argument a few commits ago, lets do the same thing for log messages in WipeDrive implementations. This makes it so every line has the drive name, has the wipe method under the same key and has similar start/error messages. #### Change WipeDrive to take a common.Drive instead of string We use a statically typed language so why devolve down to strings when we also have a better type lying around, so lets use it. #### Get rid of Nvme.wipe Now that Nvme.WipeDrive takes a common.Drive that has the capabilities saved, WipeDrive was just a thin wrapper around wipe. Hoist the code for wipe into WipeDrive then. #### Better tests in fill_zero_test Use stretchr/testify in fill_zero_test for easier to read tests. Actually test different sized files in fill_zero_test.Test_WipeDrive, previously there was a bug and all files were 4096 bytes long. The test were also updated to actually verify that FillZero actually fills the file with 0s, before it was just ensuring the file was not shrunk or grown. #### Make Blkdiscard.WipeDrive & FillZeroCmd.WipeDrive verify the wipe Nvme wipe has multiple sub-methods for wiping and it verifies the method worked correctly or tries the next one. FillZeroCmd nor Blkdiscard did not do this. I was on the fence if we should change Nvme or FillZero and Blkdiscard and chose to stay with the way Nvme does it because ultimately, I want callers to not have to worry about this. If a WipeDrive method returns success then the wipe is good. #### Make diskwipe a better example I thought it would be nice to have a diskwipe example that could do a better job of using ironlib's hardware collection capabilities vs just statically using a tool, it serves as a better example of using ironlib vs just being a go wrapper for various unix cli utilities. So I got rid of the separate blkdiscard example and wipe code from nvme-wipe (so it just does nvme namespace clearing/creating so I renamed it to nvme-ns-wipe) and taught diskwipe to know when to use each tool. ### The HW vendor this change applies to (if applicable) N.A. ### The HW model number, product name this change applies to (if applicable) N.A. ### The BMC firmware and/or BIOS versions that this change applies to (if applicable) N.A. ### What version of tooling - vendor specific or opensource does this change depend on (if applicable) N.A. ### How can this change be tested by a PR reviewer? These are mostly refactors of code but can mess around with the examples/diskwipe and examples/nvme-ns-wipe binaries. ### Description for changelog/release notes Reword changelog/release notes for DiskWiper/WipeDisk -> DriveWiper/WipeDrive. Reword changelog/release notes regarding the diskwipe example and how it uses the best tool for the job.
- Loading branch information
Showing
16 changed files
with
287 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
diskwipe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
nvme-ns-wipe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.