class Fog::Proxmox::Compute::Tasks

class Tasks Collection of node

Public Instance Methods

all(filters = {}) click to toggle source
# File lib/fog/proxmox/compute/models/tasks.rb, line 33
def all(filters = {})
  load service.list_tasks(node_id, filters)
end
get(id) click to toggle source
# File lib/fog/proxmox/compute/models/tasks.rb, line 46
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) click to toggle source
# File lib/fog/proxmox/compute/models/tasks.rb, line 37
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 = {}) click to toggle source
Calls superclass method
# File lib/fog/proxmox/compute/models/tasks.rb, line 29
def new(new_attributes = {})
  super({ node_id: node_id }.merge(new_attributes))
end
wait_for(task_upid) click to toggle source
# File lib/fog/proxmox/compute/models/tasks.rb, line 53
def wait_for(task_upid)
  task = get(task_upid)
  task.wait_for { finished? }
  message = "Task #{task_upid} failed because #{task.exitstatus}"
  raise Fog::Errors::Error, message unless task.succeeded?
  task.succeeded?
end