From c7086622f160e5f1e71acc21cbf3bbb6d22b0f82 Mon Sep 17 00:00:00 2001 From: Joel Rebello Date: Mon, 11 Sep 2023 10:21:34 +0200 Subject: [PATCH] redfishwrapper: add method to return list of virtual media currently inserted --- internal/redfishwrapper/virtual_media.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/internal/redfishwrapper/virtual_media.go b/internal/redfishwrapper/virtual_media.go index 4954eb3f..562cd8fa 100644 --- a/internal/redfishwrapper/virtual_media.go +++ b/internal/redfishwrapper/virtual_media.go @@ -74,3 +74,27 @@ func (c *Client) SetVirtualMedia(ctx context.Context, kind string, mediaURL stri return true, nil } + +func (c *Client) InsertedVirtualMedia(ctx context.Context) ([]string, error) { + managers, err := c.Managers(ctx) + if err != nil { + return nil, err + } + + var inserted []string + + for _, manager := range managers { + virtualMedia, err := manager.VirtualMedia() + if err != nil { + return nil, err + } + + for _, media := range virtualMedia { + if media.Inserted { + inserted = append(inserted, media.ID) + } + } + } + + return inserted, nil +}