-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for smartpqi/arcconf RAID adapters on Linux
The smartpqi driver for Adaptec/Microsemi RAID controllers uses a cli tool called `arcconf`. Add support modeled after the existing MegaRAID/storcli structures and implement the RAID Controller interface introduced to abstract the specific RAID adapter for the linux system. - Did not implement the Caching mechansim, repeated invocations do not have any significant impact on system, 5 minute timeout seems quite long to wait for RAID device changes which happen immediately after issuing arcconf commands. - Refactored how linux package looks up disks to see if they belong to a RAID adapter to prevent import loops. - Added tests for arcconf for the interface commands parsing output collected from systems with smartpqi driver and card - Added smartpqi to the demo program Signed-off-by: Ryan Harper <ryaharpe@cisco.com>
- Loading branch information
Showing
11 changed files
with
1,991 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"strconv" | ||
|
||
"github.com/urfave/cli/v2" | ||
"machinerun.io/disko/smartpqi" | ||
) | ||
|
||
//nolint:gochecknoglobals | ||
var smartpqiCommands = cli.Command{ | ||
Name: "smartpqi", | ||
Usage: "smartpqi / arcconf commands", | ||
Subcommands: []*cli.Command{ | ||
{ | ||
Name: "dump", | ||
Usage: "Dump information about smartpqi", | ||
Action: smartpqiDump, | ||
}, | ||
{ | ||
Name: "disk-summary", | ||
Usage: "Show information about virtual devices on system", | ||
Action: smartpqiDiskSummary, | ||
}, | ||
{ | ||
Name: "list-controllers", | ||
Usage: "Show the discovered controller IDs", | ||
Action: smartpqiListControllers, | ||
}, | ||
}, | ||
} | ||
|
||
func smartpqiListControllers(c *cli.Context) error { | ||
arc := smartpqi.ArcConf() | ||
ctrls, err := arc.List() | ||
if err != nil { | ||
return fmt.Errorf("failed to list controllers: %s", err) | ||
} | ||
|
||
fmt.Printf("Found %d controllers.", len(ctrls)) | ||
for _, cID := range ctrls { | ||
fmt.Printf("Controller ID: %d\n", cID) | ||
} | ||
return nil | ||
} | ||
|
||
func smartpqiDiskSummary(c *cli.Context) error { | ||
var err error | ||
var ctrlNum = 1 | ||
var ctrlArg = c.Args().First() | ||
|
||
if ctrlArg != "" { | ||
ctrlNum, err = strconv.Atoi(ctrlArg) | ||
if err != nil { | ||
return fmt.Errorf("could not convert to integer: %s", err) | ||
} | ||
} | ||
|
||
arc := smartpqi.ArcConf() | ||
ctrl, err := arc.Query(ctrlNum) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
data := [][]string{{"Path", "Name", "DiskType", "RAID"}} | ||
|
||
for _, ld := range ctrl.LogicalDrives { | ||
stype := "HDD" | ||
|
||
if ld.IsSSD() { | ||
stype = "SSD" | ||
} | ||
|
||
name := ld.Name | ||
if ld.Name == "" { | ||
name = fmt.Sprintf("logicalid-%d", ld.ID) | ||
} | ||
|
||
data = append(data, []string{ld.DiskName, name, stype, ld.RAIDLevel}) | ||
} | ||
|
||
printTextTable(data) | ||
|
||
return nil | ||
} | ||
|
||
func smartpqiDump(c *cli.Context) error { | ||
var err error | ||
var ctrlNum = 1 | ||
var ctrlArg = c.Args().First() | ||
|
||
if ctrlArg != "" { | ||
ctrlNum, err = strconv.Atoi(ctrlArg) | ||
if err != nil { | ||
return fmt.Errorf("could not convert to integer: %s", err) | ||
} | ||
} | ||
|
||
arc := smartpqi.ArcConf() | ||
ctrl, err := arc.Query(ctrlNum) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
jbytes, err := json.MarshalIndent(&ctrl, "", " ") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
fmt.Printf("%s\n", string(jbytes)) | ||
|
||
return nil | ||
} |
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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
package megaraid | ||
|
||
const sysDriverMegaRaidSAS = "/sys/bus/pci/drivers/megaraid_sas" | ||
const SysfsPCIDriversPath = "/sys/bus/pci/drivers/megaraid_sas" |
Oops, something went wrong.