Skip to content

Commit

Permalink
Support deleting raid arrays (virtual disks) by ID
Browse files Browse the repository at this point in the history
  • Loading branch information
splaspood committed Aug 2, 2023
1 parent 4ff30ee commit 7f8cf7e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions cmd/raid_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"context"
"strconv"

"github.com/spf13/cobra"

Expand Down Expand Up @@ -32,6 +33,11 @@ func deleteArray(ctx context.Context, raidType, arrayName string) {
Name: arrayName,
}

// If arrayName is actually an integer, populate that as the ControllerVirtualDiskID
if id, err := strconv.Atoi(arrayName); err == nil {
raidArray.ControllerVirtualDiskID = id
}

if out, err := raidArray.Delete(ctx, raidType); err != nil {
logger.Fatalw("failed to create raid array", "err", err, "array", raidArray, "output", out)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/model/raid_array.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (a *RaidArray) DeleteHardware(ctx context.Context) error {
}

for _, vd := range vds {
if vd.Name == a.Name {
if vd.Name == a.Name || vd.ID == strconv.Itoa(a.ControllerVirtualDiskID) {
options := &model.DestroyVirtualDiskOptions{
VirtualDiskID: a.ControllerVirtualDiskID,
}
Expand Down

0 comments on commit 7f8cf7e

Please sign in to comment.