Module: ILO_SDK::VirtualMediaHelper

Included in:
Client
Defined in:
lib/ilo-sdk/helpers/virtual_media_helper.rb

Overview

Contains helper methods for Virtual Media actions

Instance Method Summary collapse

Instance Method Details

#eject_virtual_media(id) ⇒ Object

Eject Virtual Media

Parameters:

  • id (String, Symbol)

Returns:

  • true


58
59
60
61
62
63
64
65
66
# File 'lib/ilo-sdk/helpers/virtual_media_helper.rb', line 58

def eject_virtual_media(id)
  new_action = {
    'Action' => 'EjectVirtualMedia',
    'Target' => '/Oem/Hp'
  }
  response = rest_post("/redfish/v1/Managers/1/VirtualMedia/#{id}/", body: new_action)
  response_handler(response)
  true
end

#get_virtual_mediaString

Get the Virtual Media Information

Returns:

  • (String)

    virtual_media

Raises:

  • (RuntimeError)

    if the request failed


18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ilo-sdk/helpers/virtual_media_helper.rb', line 18

def get_virtual_media
  response = rest_get('/redfish/v1/Managers/1/VirtualMedia/')
  media = {}
  response_handler(response)['links']['Member'].each do |vm|
    response = rest_get(vm['href'])
    virtual_media = response_handler(response)
    media[virtual_media['Id']] = {
      'Image' => virtual_media['Image'],
      'MediaTypes' => virtual_media['MediaTypes']
    }
  end
  media
end

#insert_virtual_media(id, image) ⇒ Object

Insert Virtual Media

Parameters:

  • id (String, Symbol)
  • image (String, Symbol)

Returns:

  • true


44
45
46
47
48
49
50
51
52
53
# File 'lib/ilo-sdk/helpers/virtual_media_helper.rb', line 44

def insert_virtual_media(id, image)
  new_action = {
    'Action' => 'InsertVirtualMedia',
    'Target' => '/Oem/Hp',
    'Image' => image
  }
  response = rest_post("/redfish/v1/Managers/1/VirtualMedia/#{id}/", body: new_action)
  response_handler(response)
  true
end

#virtual_media_inserted?(id) ⇒ TrueClass, FalseClass

Return whether Virtual Media is inserted

Returns:

  • (TrueClass, FalseClass)

    virtual_media_inserted

Raises:

  • (RuntimeError)

    if the request failed


35
36
37
38
# File 'lib/ilo-sdk/helpers/virtual_media_helper.rb', line 35

def virtual_media_inserted?(id)
  response = rest_get("/redfish/v1/Managers/1/VirtualMedia/#{id}/")
  response_handler(response)['Inserted']
end