Skip to content

Commit

Permalink
Update virtual media ejecting: (#410)
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Jan 11, 2025
2 parents d5ea37c + 6dbf141 commit fffd096
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 fffd096

Please sign in to comment.