Skip to content

Commit

Permalink
added new parameter MediaType to VirtualMediaConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Maksim Kovshov committed Dec 5, 2023
1 parent 22a60a7 commit 8061a5b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
16 changes: 9 additions & 7 deletions redfish/virtualmedia.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -185,6 +185,7 @@ func (virtualmedia *VirtualMedia) Update() error {
readWriteFields := []string{
"Image",
"Inserted",
"MediaType",
"Password",
"TransferMethod",
"TransferProtocolType",
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion redfish/virtualmedia_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ func TestVirtualMediaUpdate(t *testing.T) {

testClient := &common.TestClient{}
result.SetClient(testClient)

result.UserName = "Fred"
result.WriteProtected = false
err = result.Update()
Expand Down Expand Up @@ -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,
Expand All @@ -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)
}
Expand Down

0 comments on commit 8061a5b

Please sign in to comment.