mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 03:27:03 -07:00
refactor: updated PrintDrives() implementation
This commit is contained in:
parent
5943854fc1
commit
a7ae240bd3
1 changed files with 26 additions and 9 deletions
33
pkg/list.go
33
pkg/list.go
|
|
@ -72,14 +72,31 @@ func ListDrives(cc *crawler.CrawlerConfig) ([]*redfish.Drive, error) {
|
|||
return foundDrives, nil
|
||||
}
|
||||
|
||||
func PrintDrives(drives []*redfish.Drive) {
|
||||
func PrintDrives(drives []*redfish.Drive, format string) {
|
||||
switch format {
|
||||
case "json":
|
||||
util.PrintJSON(drives)
|
||||
case "yaml":
|
||||
util.PrintYAML(drives)
|
||||
case "list":
|
||||
for i, drive := range drives {
|
||||
fmt.Printf("Drive %d\n", i)
|
||||
fmt.Printf("\tManufacturer: %s\n", drive.Manufacturer)
|
||||
fmt.Printf("\tModel: %s\n", drive.Model)
|
||||
fmt.Printf("\tSize: %d GiB\n", (drive.CapacityBytes / 1024 / 1024 / 1024))
|
||||
fmt.Printf("\tSerial number: %s\n", drive.SerialNumber)
|
||||
fmt.Printf("\tPart number: %s\n", drive.PartNumber)
|
||||
fmt.Printf("\tLocation: %s %d\n", drive.PhysicalLocation.PartLocation.LocationType, drive.PhysicalLocation.PartLocation.LocationOrdinalValue)
|
||||
fmt.Printf(`
|
||||
Drive %d
|
||||
\tManufacturuer: %s
|
||||
\tModel: %s
|
||||
\tSize: %d GiB
|
||||
\tSerial Number: %s
|
||||
\tPart Number: %s
|
||||
\tLocation: %s,%s
|
||||
`, i,
|
||||
drive.Manufacturer,
|
||||
drive.Model,
|
||||
(drive.CapacityBytes / 1024 / 1024 / 1024),
|
||||
drive.SerialNumber,
|
||||
drive.PartNumber,
|
||||
drive.PhysicalLocation.PartLocation.LocationType,
|
||||
drive.PhysicalLocation.PartLocation.LocationOrdinalValue,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue