Skip to content

Commit

Permalink
vogelkop 0.2.2 - Hardware RAID Controller Support
Browse files Browse the repository at this point in the history
* integrate ironlib
* support creation of hardware raid arrays in configure-raid cmd
* upgrade to go 1.19
* bring various dependencies in line with go 1.19
* disable golangci checks that are not compatible with go 1.19
  • Loading branch information
splaspood committed Nov 15, 2022
1 parent d23ff73 commit 5c03b98
Show file tree
Hide file tree
Showing 9 changed files with 346 additions and 70 deletions.
14 changes: 7 additions & 7 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ linters:
- asciicheck
- bodyclose
- cyclop
- deadcode
#- deadcode
- dogsled
- dupl
- durationcheck
Expand All @@ -128,7 +128,7 @@ linters:
- goprintffuncname
- gosimple
- govet
- ifshort
#- ifshort
- importas
- ineffassign
- makezero
Expand All @@ -142,19 +142,19 @@ linters:
# disabling for the initial iteration of the linting tool
# - promlinter
- revive
- rowserrcheck
- sqlclosecheck
#- rowserrcheck
#- sqlclosecheck
- staticcheck
- structcheck
#- structcheck
- stylecheck
- thelper
- tparallel
- typecheck
- unconvert
- unparam
- unused
- varcheck
- wastedassign
#- varcheck
#- wastedassign
- whitespace

# Disabled linters, due to being misaligned with Go practices
Expand Down
54 changes: 38 additions & 16 deletions cmd/configure_raid.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package cmd

import (
"context"
"strconv"

"github.com/spf13/cobra"

"github.com/metal-toolbox/vogelkop/internal/command"
"github.com/metal-toolbox/vogelkop/pkg/model"
)

Expand All @@ -13,31 +14,52 @@ var configureRaidCmd = &cobra.Command{
Short: "Configures various types of RAID",
Long: "Configures various types of RAID",
Run: func(cmd *cobra.Command, args []string) {
ctx := context.Background()
ctx := command.NewContextWithLogger(logger)

blockDeviceFiles := GetStringSlice(cmd, "devices")
if GetBool(cmd, "delete") {
raidArray := model.RaidArray{
Name: GetString(cmd, "name"),
}

blockDevices, err := model.NewBlockDevices(blockDeviceFiles...)
if err != nil {
logger.Fatalw("Failed to GetBlockDevices", "err", err, "devices", blockDeviceFiles)
}
if out, err := raidArray.Delete(ctx, GetString(cmd, "raid-type")); err != nil {
logger.Fatalw("failed to create raid array", "err", err, "array", raidArray, "output", out)
}
} else {
var blockDeviceIDs []int

raidArray := model.RaidArray{
Name: GetString(cmd, "name"),
Devices: blockDevices,
Level: GetString(cmd, "raid-level"),
}
for _, d := range GetStringSlice(cmd, "devices") {
intBlockDevice, err := strconv.Atoi(d)
if err != nil {
logger.Fatalw("failed to convert device id string to int", "err", err, "blockDeviceID", d)
}

blockDeviceIDs = append(blockDeviceIDs, intBlockDevice)
}

// TODO(splaspood) Handle looking up devices using ironlib/mvcli to generate this list?
blockDevices, err := model.NewBlockDevicesFromPhysicalDeviceIDs(blockDeviceIDs...)
if err != nil {
logger.Fatalw("failed to gather block devices from physical ids", "err", err, "devices", blockDeviceIDs)
}

raidArray := model.RaidArray{
Name: GetString(cmd, "name"),
Devices: blockDevices,
Level: GetString(cmd, "raid-level"),
}

if err = raidArray.Create(ctx, GetString(cmd, "raid-type")); err != nil {
logger.Fatalw("failed to create raid array", "err", err, "array", raidArray)
if err = raidArray.Create(ctx, GetString(cmd, "raid-type")); err != nil {
logger.Fatalw("failed to create raid array", "err", err, "array", raidArray)
}
}
},
}

func init() {
configureRaidCmd.PersistentFlags().String("raid-type", "linuxsw", "RAID Type (linuxsw,dellperc,etc)")
configureRaidCmd.PersistentFlags().String("raid-type", "linuxsw", "RAID Type (linuxsw,hardware)")
configureRaidCmd.PersistentFlags().Bool("delete", false, "Delete virtual disk")

configureRaidCmd.PersistentFlags().StringSlice("devices", []string{}, "List of underlying physical volumes.")
configureRaidCmd.PersistentFlags().StringSlice("devices", []string{}, "List of underlying physical block devices.")
markFlagAsRequired(configureRaidCmd, "devices")

configureRaidCmd.PersistentFlags().String("raid-level", "1", "RAID Level")
Expand Down
34 changes: 26 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,44 @@ module github.com/metal-toolbox/vogelkop
go 1.19

require (
github.com/Sytten/logrus-zap-hook v0.1.0
github.com/bmc-toolbox/common v0.0.0-20221027142600-dd231ee11e95
github.com/freddierice/go-losetup/v2 v2.0.1
github.com/spf13/cobra v1.6.0
github.com/metal-toolbox/ironlib v0.1.1-staging.0.20221101172719-9d149abd382c
github.com/sirupsen/logrus v1.9.0
github.com/spf13/cobra v1.6.1
go.uber.org/zap v1.23.0
)

require (
github.com/beevik/etree v1.1.0 // indirect
github.com/dselans/dmidecode v0.0.0-20180814053009-65c3f9d81910 // indirect
github.com/frankban/quicktest v1.14.3 // indirect
github.com/google/uuid v1.1.1 // indirect
github.com/pierrec/lz4 v2.3.0+incompatible // indirect
github.com/pkg/xattr v0.4.1 // indirect
github.com/sirupsen/logrus v1.7.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/xattr v0.4.9 // indirect
github.com/r3labs/diff/v2 v2.15.1 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/tidwall/gjson v1.14.3 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/ulikunitz/xz v0.5.10 // indirect
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect
gopkg.in/djherbis/times.v1 v1.2.0 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
golang.org/x/exp v0.0.0-20221011175825-a46a59553dc7 // indirect
golang.org/x/net v0.1.0 // indirect
golang.org/x/sys v0.1.0 // indirect
golang.org/x/text v0.4.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/djherbis/times.v1 v1.3.0 // indirect
)

require (
github.com/diskfs/go-diskfs v1.2.0
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
)
Loading

0 comments on commit 5c03b98

Please sign in to comment.