Class: Fog::Compute::Proxmox::Tasks

Inherits:
Proxmox::Collection show all
Defined in:
lib/fog/compute/proxmox/models/tasks.rb

Overview

class Tasks Collection of node

Instance Attribute Summary

Attributes inherited from Proxmox::Collection

#response

Instance Method Summary collapse

Methods inherited from Proxmox::Collection

#clear_ignored_attributes, #create, #destroy, #find_by_id, #load_response, #not_implemented, #read, #summary

Instance Method Details

#allObject


41
42
43
# File 'lib/fog/compute/proxmox/models/tasks.rb', line 41

def all
  search
end

#get(id) ⇒ Object


55
56
57
58
59
60
61
# File 'lib/fog/compute/proxmox/models/tasks.rb', line 55

def get(id)
  requires :node
  status_details = service.status_task(node.node, id)
  task_hash = status_details.merge(log: log(id))
  task_data = task_hash.merge(node: node, upid: id)
  new(task_data)
end

#log(id) ⇒ Object


45
46
47
48
49
50
51
52
53
# File 'lib/fog/compute/proxmox/models/tasks.rb', line 45

def log(id)
  requires :node
  log = ''
  log_array = service.log_task(node.node, id, {})
  log_array.each do |line_hash|
    log += line_hash['t'].to_s + "\n"
  end
  log
end

#new(attributes = {}) ⇒ Object


31
32
33
34
# File 'lib/fog/compute/proxmox/models/tasks.rb', line 31

def new(attributes = {})
  requires :node
  super({ node: node }.merge(attributes))
end

#search(options = {}) ⇒ Object


36
37
38
39
# File 'lib/fog/compute/proxmox/models/tasks.rb', line 36

def search(options = {})
  requires :node
  load_response(service.list_tasks(node.node, options), 'tasks')
end

#wait_for(task_upid) ⇒ Object


63
64
65
66
67
# File 'lib/fog/compute/proxmox/models/tasks.rb', line 63

def wait_for(task_upid)
  task = get(task_upid)
  task.wait_for { finished? }
  task.succeeded?
end