Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20.x'
go-version: '1.22.x'
id: go

- name: Check out code into the Go module directory
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ jobs:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: '1.20.x'
go-version: '1.22.x'
cache: false
- name: Checkout code
uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.52.2
version: v1.63.4
- name: gofmt
run: |
make gofmt
40 changes: 0 additions & 40 deletions .golangci.yml

This file was deleted.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LDFLAGS := "${ldflags:+$ldflags }-X main.version=${ver}${suff}"
BUILD_FLAGS := -ldflags "-X main.version=$(VERSION_FULL)"
ENV_ROOT := $(shell [ "$$(id -u)" = "0" ] && echo env || echo sudo )

GOLANGCI_VER = v1.56.1
GOLANGCI_VER = v1.63.4
GOLANGCI = ./tools/golangci-lint-$(GOLANGCI_VER)

CMDS := demo/demo ptimg/ptimg
Expand Down Expand Up @@ -46,7 +46,7 @@ $(GOLANGCI):

lint: .lint

.lint: $(ALL_GO_FILES) $(GOLANGCI) .golangci.yml
.lint: $(ALL_GO_FILES) $(GOLANGCI)
Comment thread
mikemccracken marked this conversation as resolved.
$(GOLANGCI) run ./...
@touch $@

Expand Down
1 change: 1 addition & 0 deletions demo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func main() {
&diskCommands,
&megaraidCommands,
&smartpqiCommands,
&mpi3mrCommands,
&lvmCommands,
&miscCommands,
},
Expand Down
9 changes: 7 additions & 2 deletions demo/megaraid.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ var megaraidCommands = cli.Command{
},
}

const (
HDD = "HDD"
SSD = "SSD"
)

func megaraidDiskSummary(c *cli.Context) error {
var err error
var ctrlNum = 0
Expand All @@ -50,10 +55,10 @@ func megaraidDiskSummary(c *cli.Context) error {
data := [][]string{{"Path", "Name", "Type", "State"}}

for _, vd := range ctrl.VirtDrives {
stype := "HDD"
stype := HDD

if ctrl.DriveGroups[vd.DriveGroup].IsSSD() {
stype = "SSD"
stype = SSD
}

name := vd.RaidName
Expand Down
130 changes: 130 additions & 0 deletions demo/mpi3mr.go
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
}
15 changes: 14 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
module machinerun.io/disko

go 1.13
go 1.22

require (
github.com/google/go-cmp v0.6.0
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/pkg/errors v0.9.1
github.com/rekby/gpt v0.0.0-20200614112001-7da10aec5566
Expand All @@ -13,3 +14,15 @@ require (
github.com/urfave/cli/v2 v2.25.3
golang.org/x/sys v0.8.0
)

require (
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/gopherjs/gopherjs v1.17.2 // indirect
github.com/jtolds/gls v4.20.0+incompatible // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/smartystreets/assertions v1.13.1 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading