Class: Proxmox::Task::Status

Inherits:
Base
  • Object
show all
Defined in:
lib/pve/proxmox.rb

Instance Attribute Summary

Attributes inherited from Base

#sid

Instance Method Summary collapse

Methods inherited from Base

__new__, fetch, #method_missing, #respond_to?

Methods included from RestConnection

#bench, #rest_del, #rest_get, #rest_post, #rest_put

Constructor Details

#initializeStatus

Returns a new instance of Status.



249
250
251
252
# File 'lib/pve/proxmox.rb', line 249

def initialize
  rest_prefix
  @sid = upid
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Proxmox::Base

Instance Method Details

#failed?Boolean

Returns:

  • (Boolean)


264
# File 'lib/pve/proxmox.rb', line 264

def failed?() stopped? ? 'OK' != @exitstatus : nil end

#finished?Boolean Also known as: stopped?

Returns:

  • (Boolean)


261
# File 'lib/pve/proxmox.rb', line 261

def finished?() 'stopped' == @status end

#inspectObject



254
255
256
257
258
# File 'lib/pve/proxmox.rb', line 254

def inspect
  h = instance_variables - %i[@node @task @sid @rest_prefix @upid @t]
  h.map! {|k| "#{k[1..-1]}=#{instance_variable_get(k).inspect}" }
  "#<#{self.class.name}|#{@upid} node=#{@node.node} #{h.join ' '}>"
end

#refresh!Object



242
243
244
245
246
247
# File 'lib/pve/proxmox.rb', line 242

def refresh!
  d = rest_get @rest_prefix
  d[:starttime] &&= Time.at d[:starttime]
  d = {exitstatus: nil}.merge d
  __update__ d.merge( node: @node, t: 'status', upid: @upid, task: @task)
end

#rest_prefixObject



238
239
240
# File 'lib/pve/proxmox.rb', line 238

def rest_prefix
  @rest_prefix ||= '/nodes/%s/tasks/%s/status' % [@node.node, @upid]
end

#running?Boolean

Returns:

  • (Boolean)


260
# File 'lib/pve/proxmox.rb', line 260

def running?() 'running' == @status end

#successfull?Boolean

Returns:

  • (Boolean)


263
# File 'lib/pve/proxmox.rb', line 263

def successfull?() stopped? ? 'OK' == @exitstatus : nil end