Class: Pvectl::Models::Task
Overview
Represents a Proxmox task (asynchronous operation).
Tasks are returned by lifecycle operations (start, stop, etc.). The UPID (Unique Process ID) identifies the task.
Instance Attribute Summary collapse
-
#endtime ⇒ Integer?
readonly
Task end time (Unix timestamp).
-
#exitstatus ⇒ String?
readonly
Exit status (OK, ERROR, etc.).
-
#node ⇒ String
readonly
Node where task runs.
-
#starttime ⇒ Integer?
readonly
Task start time (Unix timestamp).
-
#status ⇒ String
readonly
Task status (running, stopped).
-
#type ⇒ String
readonly
Task type (qmstart, qmstop, etc.).
-
#upid ⇒ String
readonly
Unique Process ID.
-
#user ⇒ String?
readonly
User who started the task.
Instance Method Summary collapse
-
#completed? ⇒ Boolean
Checks if the task has completed.
-
#duration ⇒ Integer?
Returns task duration in seconds.
-
#failed? ⇒ Boolean
Checks if the task failed.
-
#initialize(attrs = {}) ⇒ Task
constructor
Creates a new Task model from attributes.
-
#pending? ⇒ Boolean
Checks if the task is still running.
-
#successful? ⇒ Boolean
Checks if the task completed successfully.
Constructor Details
#initialize(attrs = {}) ⇒ Task
Creates a new Task model from attributes.
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/pvectl/models/task.rb', line 45 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] end |
Instance Attribute Details
#endtime ⇒ Integer? (readonly)
Returns Task end time (Unix timestamp).
37 38 39 |
# File 'lib/pvectl/models/task.rb', line 37 def endtime @endtime end |
#exitstatus ⇒ String? (readonly)
Returns Exit status (OK, ERROR, etc.).
31 32 33 |
# File 'lib/pvectl/models/task.rb', line 31 def exitstatus @exitstatus end |
#node ⇒ String (readonly)
Returns Node where task runs.
22 23 24 |
# File 'lib/pvectl/models/task.rb', line 22 def node @node end |
#starttime ⇒ Integer? (readonly)
Returns Task start time (Unix timestamp).
34 35 36 |
# File 'lib/pvectl/models/task.rb', line 34 def starttime @starttime end |
#status ⇒ String (readonly)
Returns Task status (running, stopped).
28 29 30 |
# File 'lib/pvectl/models/task.rb', line 28 def status @status end |
#type ⇒ String (readonly)
Returns Task type (qmstart, qmstop, etc.).
25 26 27 |
# File 'lib/pvectl/models/task.rb', line 25 def type @type end |
#upid ⇒ String (readonly)
Returns Unique Process ID.
19 20 21 |
# File 'lib/pvectl/models/task.rb', line 19 def upid @upid end |
#user ⇒ String? (readonly)
Returns User who started the task.
40 41 42 |
# File 'lib/pvectl/models/task.rb', line 40 def user @user end |
Instance Method Details
#completed? ⇒ Boolean
Checks if the task has completed.
67 68 69 |
# File 'lib/pvectl/models/task.rb', line 67 def completed? !pending? end |
#duration ⇒ Integer?
Returns task duration in seconds.
88 89 90 91 92 |
# File 'lib/pvectl/models/task.rb', line 88 def duration return nil unless endtime && starttime endtime - starttime end |
#failed? ⇒ Boolean
Checks if the task failed.
81 82 83 |
# File 'lib/pvectl/models/task.rb', line 81 def failed? completed? && exitstatus != "OK" end |
#pending? ⇒ Boolean
Checks if the task is still running.
60 61 62 |
# File 'lib/pvectl/models/task.rb', line 60 def pending? status == "running" end |
#successful? ⇒ Boolean
Checks if the task completed successfully.
74 75 76 |
# File 'lib/pvectl/models/task.rb', line 74 def successful? completed? && exitstatus == "OK" end |