Class: OneviewSDK::API200::FirmwareBundle
- Inherits:
-
Object
- Object
- OneviewSDK::API200::FirmwareBundle
- Defined in:
- lib/oneview-sdk/resource/api200/firmware_bundle.rb
Overview
Firmware bundle resource implementation
Direct Known Subclasses
OneviewSDK::API300::C7000::FirmwareBundle, OneviewSDK::API300::Synergy::FirmwareBundle
Constant Summary collapse
- BASE_URI =
'/rest/firmware-bundles'.freeze
- READ_TIMEOUT =
in seconds, 5 minutes
300
Class Method Summary collapse
-
.add(client, file_path, timeout = READ_TIMEOUT) ⇒ OneviewSDK::FirmwareDriver
Uploads a firmware bundle file.
Class Method Details
.add(client, file_path, timeout = READ_TIMEOUT) ⇒ OneviewSDK::FirmwareDriver
Uploads a firmware bundle file
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/oneview-sdk/resource/api200/firmware_bundle.rb', line 26 def self.add(client, file_path, timeout = READ_TIMEOUT) raise 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.read_timeout = timeout http_request.start do |http| begin response = http.request(req) data = client.response_handler(response) return OneviewSDK::FirmwareDriver.new(client, data) rescue Net::ReadTimeout raise "The connection was closed because the timeout of #{timeout} seconds has expired."\ 'You can specify the timeout in seconds by passing the timeout on the method call.'\ 'Interrupted firmware uploads may result in corrupted firmware remaining in the appliance.'\ 'HPE recommends checking the appliance for corrupted firmware and removing it.' end end end end |