Class: OneviewSDK::FirmwareBundle

Inherits:
Object
  • Object
show all
Defined in:
lib/oneview-sdk/resource/firmware_bundle.rb

Overview

Firmware bundle resource implementation

Constant Summary collapse

BASE_URI =
'/rest/firmware-bundles'.freeze
BOUNDARY =
'----011000010111000001101001'.freeze

Class Method Summary collapse

Class Method Details

.add(client, file_path) ⇒ OneviewSDK::FirmwareDriver

Uploads a firmware bundle file

Parameters:

  • client (OneviewSDK::Client)

    The client object for the OneView appliance

  • file_path (String)

Returns:



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/oneview-sdk/resource/firmware_bundle.rb', line 22

def self.add(client, file_path)
  fail NotFound, "ERROR: File '#{file_path}' not found!" unless File.file?(file_path)
  options = {}
  options['Content-Type'] = "multipart/form-data; boundary=#{BOUNDARY}"
  options['uploadfilename'] = File.basename(file_path)
  options['body'] = "--#{BOUNDARY}\r\n"
  options['body'] << "Content-Disposition: form-data; name=\"file\"; filename=\"#{File.basename(file_path)}\"\r\n"
  options['body'] << "Content-Type: application/octet-stream; Content-Transfer-Encoding: binary\r\n\r\n"
  options['body'] << "#{IO.binread(file_path)}\r\n--#{BOUNDARY}--"
  response = client.rest_post(BASE_URI, options)
  data = client.response_handler(response)
  OneviewSDK::FirmwareDriver.new(client, data)
end