Class: Fog::Proxmox::Compute::Tasks
- Inherits:
-
Collection
- Object
- Collection
- Fog::Proxmox::Compute::Tasks
- Defined in:
- lib/fog/proxmox/compute/models/tasks.rb
Overview
class Tasks Collection of node
Instance Method Summary collapse
- #all(filters = {}) ⇒ Object
- #get(id) ⇒ Object
- #log(id) ⇒ Object
- #new(new_attributes = {}) ⇒ Object
- #wait_for(task_upid) ⇒ Object
Instance Method Details
#all(filters = {}) ⇒ Object
34 35 36 |
# File 'lib/fog/proxmox/compute/models/tasks.rb', line 34 def all(filters = {}) load service.list_tasks(node_id, filters) end |
#get(id) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/fog/proxmox/compute/models/tasks.rb', line 47 def get(id) status_details = service.status_task(node_id, id) task_hash = status_details.merge(log: log(id)) task_data = task_hash.merge(node_id: node_id, upid: id) new(task_data) end |
#log(id) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/fog/proxmox/compute/models/tasks.rb', line 38 def log(id) log = '' log_array = service.log_task(node_id, id, {}) log_array.each do |line_hash| log += line_hash['t'].to_s + "\n" end log end |
#new(new_attributes = {}) ⇒ Object
30 31 32 |
# File 'lib/fog/proxmox/compute/models/tasks.rb', line 30 def new(new_attributes = {}) super({ node_id: node_id }.merge(new_attributes)) end |
#wait_for(task_upid) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/fog/proxmox/compute/models/tasks.rb', line 54 def wait_for(task_upid) task = get(task_upid) task.wait_for { finished? } = "Task #{task_upid} failed because #{task.exitstatus}" raise Fog::Errors::Error, unless task.succeeded? task.succeeded? end |