Skip to content
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

Support deleting raid arrays (virtual disks) by ID #55

Merged
merged 1 commit into from
Aug 2, 2023
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
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
Loading