Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added new parameter MediaType to VirtualMediaConfig #290

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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