Class: Fog::Proxmox::Storage::IsoUpload
- Inherits:
-
Model
- Object
- Model
- Fog::Proxmox::Storage::IsoUpload
- Defined in:
- lib/fog/proxmox/storage/models/iso_upload.rb
Overview
Uploads a local ISO and waits for the Proxmox task to finish.
Instance Method Summary collapse
Instance Method Details
#upload ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/fog/proxmox/storage/models/iso_upload.rb', line 12 def upload requires :node_id, :storage_id, :path filename = File.basename(path) size = File.size(path) Fog::Logger.debug("Starting Proxmox ISO upload filename=#{filename} size=#{size} bytes node=#{node_id} storage=#{storage_id}") response = File.open(path, 'rb') do |file| Fog::Proxmox::Storage.new(service.config).upload_iso( { node: node_id, storage: storage_id }, { filename: filename, file: file } ) end Fog::Logger.debug("Upload response: #{response.inspect}") raise Fog::Errors::Error, "Unexpected upload response: #{response.inspect}" unless response.to_s.start_with?('UPID:') service.nodes.get(node_id).tasks.wait_for(response) response end |