Class: OneviewSDK::FirmwareBundle
- Inherits:
-
Object
- Object
- OneviewSDK::FirmwareBundle
- 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
-
.add(client, file_path) ⇒ OneviewSDK::FirmwareDriver
Uploads a firmware bundle file.
Class Method Details
.add(client, file_path) ⇒ OneviewSDK::FirmwareDriver
Uploads a firmware bundle file
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) = {} ['Content-Type'] = "multipart/form-data; boundary=#{BOUNDARY}" ['uploadfilename'] = File.basename(file_path) ['body'] = "--#{BOUNDARY}\r\n" ['body'] << "Content-Disposition: form-data; name=\"file\"; filename=\"#{File.basename(file_path)}\"\r\n" ['body'] << "Content-Type: application/octet-stream; Content-Transfer-Encoding: binary\r\n\r\n" ['body'] << "#{IO.binread(file_path)}\r\n--#{BOUNDARY}--" response = client.rest_post(BASE_URI, ) data = client.response_handler(response) OneviewSDK::FirmwareDriver.new(client, data) end |