Class: Fog::Proxmox::Compute::Task

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/compute/proxmox/models/task.rb

Overview

class Task model of a node

Instance Method Summary collapse

Constructor Details

#initialize(new_attributes = {}) ⇒ Task

Returns a new instance of Task.



48
49
50
51
52
53
54
# File 'lib/fog/compute/proxmox/models/task.rb', line 48

def initialize(new_attributes = {})
  prepare_service_value(new_attributes)
  Fog::Proxmox::Attributes.set_attr_and_sym('node_id', attributes, new_attributes)
  Fog::Proxmox::Attributes.set_attr_and_sym('upid', attributes, new_attributes)
  requires :node_id, :upid
  super(new_attributes)
end

Instance Method Details

#finished?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/fog/compute/proxmox/models/task.rb', line 60

def finished?
  status == 'stopped'
end

#reloadObject



72
73
74
75
# File 'lib/fog/compute/proxmox/models/task.rb', line 72

def reload
  object = collection.get(upid)
  merge_attributes(object.attributes)
end

#running?Boolean

Returns:

  • (Boolean)


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

def running?
  status == 'running'
end

#stopObject



68
69
70
# File 'lib/fog/compute/proxmox/models/task.rb', line 68

def stop
  service.stop_task(node_id, upid)
end

#succeeded?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/fog/compute/proxmox/models/task.rb', line 56

def succeeded?
  finished? && exitstatus == 'OK'
end