Class: MescalCli::Task
- Inherits:
-
Object
- Object
- MescalCli::Task
- Defined in:
- lib/mescal-cli/task.rb
Instance Attribute Summary collapse
-
#cmd ⇒ Object
readonly
Returns the value of attribute cmd.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#image ⇒ Object
readonly
Returns the value of attribute image.
-
#slave_id ⇒ Object
readonly
Returns the value of attribute slave_id.
-
#state ⇒ Object
Returns the value of attribute state.
Class Method Summary collapse
Instance Method Summary collapse
- #done? ⇒ Boolean
-
#initialize(client, id, image, cmd) ⇒ Task
constructor
A new instance of Task.
- #slave_ip ⇒ Object
- #ssh_port ⇒ Object
- #to_s ⇒ Object
- #update! ⇒ Object
Constructor Details
#initialize(client, id, image, cmd) ⇒ Task
Returns a new instance of Task.
22 23 24 |
# File 'lib/mescal-cli/task.rb', line 22 def initialize(client, id, image, cmd) @client, @id, @image, @cmd = client, id, image, cmd end |
Instance Attribute Details
#cmd ⇒ Object (readonly)
Returns the value of attribute cmd.
3 4 5 |
# File 'lib/mescal-cli/task.rb', line 3 def cmd @cmd end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/mescal-cli/task.rb', line 3 def id @id end |
#image ⇒ Object (readonly)
Returns the value of attribute image.
3 4 5 |
# File 'lib/mescal-cli/task.rb', line 3 def image @image end |
#slave_id ⇒ Object (readonly)
Returns the value of attribute slave_id.
3 4 5 |
# File 'lib/mescal-cli/task.rb', line 3 def slave_id @slave_id end |
#state ⇒ Object
Returns the value of attribute state.
4 5 6 |
# File 'lib/mescal-cli/task.rb', line 4 def state @state end |
Class Method Details
Instance Method Details
#done? ⇒ Boolean
34 35 36 |
# File 'lib/mescal-cli/task.rb', line 34 def done? ['TASK_FINISHED', 'TASK_LOST', 'TASK_FAILED'].include?(@state) end |
#slave_ip ⇒ Object
38 39 40 41 42 |
# File 'lib/mescal-cli/task.rb', line 38 def slave_ip resp = @client.slave.get(@slave_id) obj = MultiJson.load(resp) obj['hostname'] end |
#ssh_port ⇒ Object
44 45 46 |
# File 'lib/mescal-cli/task.rb', line 44 def ssh_port @ports.find { |p| p[0] == 22 }[1] end |
#to_s ⇒ Object
48 49 50 |
# File 'lib/mescal-cli/task.rb', line 48 def to_s "#{@id} #{@image} #{@cmd}" end |
#update! ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/mescal-cli/task.rb', line 26 def update! resp = @client.task.get(@id) obj = MultiJson.load(resp) @state = obj['state'] @slave_id = obj['slaveId'] @ports = obj['ports'] end |