module IDRAC::VirtualMedia
def eject_virtual_media(device: "CD")
def eject_virtual_media(device: "CD") media_list = virtual_media # Find the device to eject media_to_eject = media_list.find { |m| m[:device] == device && m[:inserted] } if media_to_eject.nil? puts "No media #{device} to eject".yellow return false end puts "Ejecting #{media_to_eject[:device]} #{media_to_eject[:image]}".yellow # Use the action path from the media object if available path = if media_to_eject[:action_path] media_to_eject[:action_path].sub(/^\/redfish\/v1\//, "").sub(/InsertMedia$/, "EjectMedia") else "Managers/iDRAC.Embedded.1/VirtualMedia/#{device}/Actions/VirtualMedia.EjectMedia" end response = authenticated_request( :post, "/redfish/v1/#{path}", body: {}.to_json, headers: { 'Content-Type': 'application/json' } ) handle_response(response) response.status.between?(200, 299) end