Skip to content

Commit

Permalink
Update virtual media ejecting:
Browse files Browse the repository at this point in the history
We weren't checking vm.Inserted and on
some HP ILOs this caused failures to eject
even when there was nothing to eject. This
makes it so that this call won't fail when
there is nothing to eject.

Signed-off-by: Jacob Weinstock <[email protected]>
  • Loading branch information
jacobweinstock committed Jan 10, 2025
1 parent d5ea37c commit 6dbf141
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions internal/redfishwrapper/virtual_media.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,21 @@ func (c *Client) SetVirtualMedia(ctx context.Context, kind string, mediaURL stri
}

for _, vm := range virtualMedia {
var ejected bool
if vm.Inserted && vm.SupportsMediaEject {
if err := vm.EjectMedia(); err != nil {
return false, err
}
ejected = true
}
if mediaURL == "" {
// Only ejecting the media was requested.
// For BMC's that don't support the "inserted" property, we need to eject the media if it's not already ejected.
if !ejected && vm.SupportsMediaEject {
if vm.Inserted && vm.SupportsMediaEject {
if err := vm.EjectMedia(); err != nil {
return false, err
}
}
return true, nil
}
if vm.Inserted && vm.SupportsMediaEject {
if err := vm.EjectMedia(); err != nil {
return false, err
}
}
if !slices.Contains(vm.MediaTypes, mediaKind) {
return false, fmt.Errorf("media kind %s not supported by BMC, supported media kinds %q", kind, vm.MediaTypes)
}
Expand Down

0 comments on commit 6dbf141

Please sign in to comment.