Class: Pvectl::Models::TaskEntry

Inherits:
Base
  • Object
show all
Defined in:
lib/pvectl/models/task_entry.rb

Overview

Represents an entry in a node’s task list.

Each entry corresponds to an asynchronous operation (start, stop, migrate, backup, etc.) performed on a resource. Returned by GET /nodes/#node/tasks endpoint.

Examples:

entry = TaskEntry.new(type: "qmstart", status: "stopped", exitstatus: "OK")
entry.successful? #=> true

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ TaskEntry

Returns a new instance of TaskEntry.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/pvectl/models/task_entry.rb', line 19

def initialize(attrs = {})
  super(attrs)
  @upid = @attributes[:upid]
  @node = @attributes[:node]
  @type = @attributes[:type]
  @status = @attributes[:status]
  @exitstatus = @attributes[:exitstatus]
  @starttime = @attributes[:starttime]
  @endtime = @attributes[:endtime]
  @user = @attributes[:user]
  @id = @attributes[:id]
  @pid = @attributes[:pid]
  @pstart = @attributes[:pstart]
end

Instance Attribute Details

#endtimeObject (readonly)

Returns the value of attribute endtime.



16
17
18
# File 'lib/pvectl/models/task_entry.rb', line 16

def endtime
  @endtime
end

#exitstatusObject (readonly)

Returns the value of attribute exitstatus.



16
17
18
# File 'lib/pvectl/models/task_entry.rb', line 16

def exitstatus
  @exitstatus
end

#idObject (readonly)

Returns the value of attribute id.



16
17
18
# File 'lib/pvectl/models/task_entry.rb', line 16

def id
  @id
end

#nodeObject (readonly)

Returns the value of attribute node.



16
17
18
# File 'lib/pvectl/models/task_entry.rb', line 16

def node
  @node
end

#pidObject (readonly)

Returns the value of attribute pid.



16
17
18
# File 'lib/pvectl/models/task_entry.rb', line 16

def pid
  @pid
end

#pstartObject (readonly)

Returns the value of attribute pstart.



16
17
18
# File 'lib/pvectl/models/task_entry.rb', line 16

def pstart
  @pstart
end

#starttimeObject (readonly)

Returns the value of attribute starttime.



16
17
18
# File 'lib/pvectl/models/task_entry.rb', line 16

def starttime
  @starttime
end

#statusObject (readonly)

Returns the value of attribute status.



16
17
18
# File 'lib/pvectl/models/task_entry.rb', line 16

def status
  @status
end

#typeObject (readonly)

Returns the value of attribute type.



16
17
18
# File 'lib/pvectl/models/task_entry.rb', line 16

def type
  @type
end

#upidObject (readonly)

Returns the value of attribute upid.



16
17
18
# File 'lib/pvectl/models/task_entry.rb', line 16

def upid
  @upid
end

#userObject (readonly)

Returns the value of attribute user.



16
17
18
# File 'lib/pvectl/models/task_entry.rb', line 16

def user
  @user
end

Instance Method Details

#completed?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/pvectl/models/task_entry.rb', line 42

def completed?
  status != "running"
end

#durationObject



46
47
48
49
# File 'lib/pvectl/models/task_entry.rb', line 46

def duration
  return nil unless endtime && starttime
  endtime - starttime
end

#failed?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/pvectl/models/task_entry.rb', line 38

def failed?
  completed? && exitstatus != "OK"
end

#successful?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/pvectl/models/task_entry.rb', line 34

def successful?
  completed? && exitstatus == "OK"
end