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
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
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/oneview-sdk/resource/firmware_bundle.rb', line 23 def self.add(client, file_path) fail NotFound, "ERROR: File '#{file_path}' not found!" unless File.file?(file_path) = {} ['Content-Type'] = 'multipart/form-data' ['X-Api-Version'] = client.api_version.to_s ['auth'] = client.token ['uploadfilename'] = File.basename(file_path) url = URI.parse(URI.escape("#{client.url}#{BASE_URI}")) File.open(file_path) do |file| req = Net::HTTP::Post::Multipart.new( url.path, { 'file' => UploadIO.new(file, 'application/octet-stream', File.basename(file_path)) }, ) http_request = Net::HTTP.new(url.host, url.port) http_request.use_ssl = true http_request.verify_mode = OpenSSL::SSL::VERIFY_NONE http_request.start do |http| response = http.request(req) data = client.response_handler(response) return OneviewSDK::FirmwareDriver.new(client, data) end end end |