-
Notifications
You must be signed in to change notification settings - Fork 9
feat: Add support for LSI/Broadcom MegaRAID 9600 Controllers using storcli2 #135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
raharper
merged 4 commits into
project-machine:main
from
raharper:feat/add-storcli2-support
Feb 5, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
02fd4f3
megaraid/storcli: update comment to match command that is actually run
raharper 18e8fe1
Bump go-version, golang-lint, drop config, fix deprecated ioutils
raharper 134e4a1
Add 'J' Device ID prefix in newer udevadm info query output
raharper b624a5c
Add support for LSI/Broadcom MegaRAID 9600 Controllers using storcli2
raharper File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,130 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "encoding/json" | ||
| "fmt" | ||
| "strconv" | ||
|
|
||
| "github.com/pkg/errors" | ||
| "github.com/urfave/cli/v2" | ||
| "machinerun.io/disko/linux" | ||
| "machinerun.io/disko/mpi3mr" | ||
| ) | ||
|
|
||
| //nolint:gochecknoglobals | ||
| var mpi3mrCommands = cli.Command{ | ||
| Name: "mpi3mr", | ||
| Usage: "mpi3mr / storcli2 commands", | ||
| Subcommands: []*cli.Command{ | ||
| { | ||
| Name: "dump", | ||
| Usage: "Dump information about mpi3mr", | ||
| Action: mpi3mrDump, | ||
| }, | ||
| { | ||
| Name: "disk-summary", | ||
| Usage: "Show information about virtual disk devices on system", | ||
| Action: mpi3mrDiskSummary, | ||
| }, | ||
| { | ||
| Name: "list-controllers", | ||
| Usage: "Show the discovered controllers' ID", | ||
| Action: mpi3mrListControllers, | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| func mpi3mrListControllers(c *cli.Context) error { | ||
| stor := mpi3mr.StorCli2() | ||
| ctrls, err := stor.List() | ||
| if err != nil { | ||
| return errors.Errorf("failed to list controllers: %v", err) | ||
| } | ||
|
|
||
| fmt.Printf("Found %d controllers:\n", len(ctrls)) | ||
| for _, cID := range ctrls { | ||
| fmt.Printf("Controller ID: %d\n", cID) | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| func mpi3mrDiskSummary(c *cli.Context) error { | ||
| var err error | ||
| var ctrlNum = 0 | ||
| var ctrlArg = c.Args().First() | ||
|
|
||
| if ctrlArg != "" { | ||
| ctrlNum, err = strconv.Atoi(ctrlArg) | ||
| if err != nil { | ||
| return errors.Errorf("invalid controller number: %v", err) | ||
| } | ||
| } | ||
|
|
||
| stor := mpi3mr.StorCli2() | ||
| ctrl, err := stor.Query(ctrlNum) | ||
| if err != nil { | ||
| return errors.Errorf("failed to query controller %d: %v", ctrlNum, err) | ||
| } | ||
|
|
||
| data := [][]string{{"Path", "Name", "Type", "State"}} | ||
|
|
||
| for _, vd := range ctrl.VirtualDrives { | ||
| stype := "HDD" | ||
|
|
||
| if vd.IsSSD() { | ||
| stype = "SSD" | ||
| } | ||
|
|
||
| name := vd.Name | ||
| if vd.Name == "" { | ||
| name = fmt.Sprintf("virtid-%s", vd.ID()) | ||
| } | ||
|
|
||
| data = append(data, []string{vd.Path(), name, stype, vd.State}) | ||
| } | ||
|
|
||
| for _, d := range ctrl.PhysicalDrives { | ||
| if d.DG >= 0 { | ||
| continue | ||
| } | ||
|
|
||
| path := "" | ||
| if bname, err := linux.NameByDiskID(stor.DriverSysfsPath(), d.PID); err == nil { | ||
| path = "/dev/" + bname | ||
| } | ||
|
|
||
| data = append(data, []string{path, fmt.Sprintf("diskid-%d", d.PID), | ||
| d.Medium, d.State}) | ||
| } | ||
|
|
||
| printTextTable(data) | ||
| return nil | ||
| } | ||
|
|
||
| func mpi3mrDump(c *cli.Context) error { | ||
| var err error | ||
| var ctrlNum = 0 | ||
| var ctrlArg = c.Args().First() | ||
|
|
||
| if ctrlArg != "" { | ||
| ctrlNum, err = strconv.Atoi(ctrlArg) | ||
| if err != nil { | ||
| return errors.Errorf("invalid controller number: %v", err) | ||
| } | ||
| } | ||
|
|
||
| stor := mpi3mr.StorCli2() | ||
| ctrl, err := stor.Query(ctrlNum) | ||
| if err != nil { | ||
| return errors.Errorf("failed to query controller %d: %v", ctrlNum, err) | ||
| } | ||
|
|
||
| jbytes, err := json.MarshalIndent(&ctrl, "", " ") | ||
| if err != nil { | ||
| return errors.Errorf("failed to marshal controller: %v", err) | ||
| } | ||
|
|
||
| fmt.Printf("%s\n", string(jbytes)) | ||
| return nil | ||
| } | ||
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.