From 8061a5b6c6a6f8cb289fd81b0792b1005093c17c Mon Sep 17 00:00:00 2001 From: Maksim Kovshov Date: Tue, 5 Dec 2023 10:56:53 +0300 Subject: [PATCH] added new parameter MediaType to VirtualMediaConfig --- redfish/virtualmedia.go | 16 +++++++++------- redfish/virtualmedia_test.go | 5 ++++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/redfish/virtualmedia.go b/redfish/virtualmedia.go index 6b6359fa..df8f290f 100644 --- a/redfish/virtualmedia.go +++ b/redfish/virtualmedia.go @@ -106,7 +106,7 @@ type VirtualMedia struct { // types for this connection. MediaTypes []VirtualMediaType // Indicates which MediaTypes is used - MediaType string + MediaType VirtualMediaType // Password shall represent the password to access the // Image parameter-specified URI. The value shall be null in responses. Password string @@ -185,6 +185,7 @@ func (virtualmedia *VirtualMedia) Update() error { readWriteFields := []string{ "Image", "Inserted", + "MediaType", "Password", "TransferMethod", "TransferProtocolType", @@ -229,12 +230,13 @@ func (virtualmedia *VirtualMedia) InsertMedia(image string, inserted, writeProte // VirtualMediaConfig is an struct used to pass config data to build the HTTP body when inserting media type VirtualMediaConfig struct { Image string - Inserted bool `json:",omitempty"` - Password string `json:",omitempty"` - TransferMethod string `json:",omitempty"` - TransferProtocolType string `json:",omitempty"` - UserName string `json:",omitempty"` - WriteProtected bool `json:",omitempty"` + Inserted bool `json:",omitempty"` + MediaType VirtualMediaType `json:",omitempty"` + Password string `json:",omitempty"` + TransferMethod TransferMethod `json:",omitempty"` + TransferProtocolType TransferProtocolType `json:",omitempty"` + UserName string `json:",omitempty"` + WriteProtected bool `json:",omitempty"` } // InsertMediaConfig sends a request to insert virtual media using the VirtualMediaConfig struct diff --git a/redfish/virtualmedia_test.go b/redfish/virtualmedia_test.go index a45c0216..d235b474 100644 --- a/redfish/virtualmedia_test.go +++ b/redfish/virtualmedia_test.go @@ -114,7 +114,6 @@ func TestVirtualMediaUpdate(t *testing.T) { testClient := &common.TestClient{} result.SetClient(testClient) - result.UserName = "Fred" result.WriteProtected = false err = result.Update() @@ -206,6 +205,7 @@ func TestVirtualMediaInsertConfig(t *testing.T) { virtualMediaConfig := VirtualMediaConfig{ Image: "https://example.com/image", Inserted: true, + MediaType: "CD", Password: "test1234", UserName: "root", WriteProtected: true, @@ -224,6 +224,9 @@ func TestVirtualMediaInsertConfig(t *testing.T) { if !strings.Contains(calls[0].Payload, "Inserted:true") { t.Errorf("Unexpected InsertMedia Inserted payload: %s", calls[0].Payload) } + if !strings.Contains(calls[0].Payload, "MediaType:CD") { + t.Errorf("Unexpected InsertMedia Inserted payload: %s", calls[0].Payload) + } if !strings.Contains(calls[0].Payload, "Password:test1234") { t.Errorf("Unexpected InsertMedia Image payload: %s", calls[0].Payload) }