Class: Docker::Swarm::Task
- Inherits:
-
Object
- Object
- Docker::Swarm::Task
- Defined in:
- lib/docker/swarm/task.rb
Overview
This class represents a Docker Swarm Node.
Instance Attribute Summary collapse
-
#hash ⇒ Object
readonly
include Docker::Base.
Instance Method Summary collapse
- #created_at ⇒ Object
- #id ⇒ Object
- #image ⇒ Object
-
#initialize(swarm, hash) ⇒ Task
constructor
A new instance of Task.
- #networks ⇒ Object
- #node ⇒ Object
- #node_id ⇒ Object
- #service ⇒ Object
- #service_id ⇒ Object
- #status ⇒ Object
- #status_message ⇒ Object
- #status_timestamp ⇒ Object
Constructor Details
#initialize(swarm, hash) ⇒ Task
Returns a new instance of Task.
6 7 8 9 |
# File 'lib/docker/swarm/task.rb', line 6 def initialize(swarm, hash) @hash = hash @swarm = swarm end |
Instance Attribute Details
#hash ⇒ Object (readonly)
include Docker::Base
4 5 6 |
# File 'lib/docker/swarm/task.rb', line 4 def hash @hash end |
Instance Method Details
#created_at ⇒ Object
37 38 39 |
# File 'lib/docker/swarm/task.rb', line 37 def created_at return DateTime.parse(@hash.first['CreatedAt']) end |
#id ⇒ Object
11 12 13 |
# File 'lib/docker/swarm/task.rb', line 11 def id return @hash['ID'] end |
#image ⇒ Object
15 16 17 |
# File 'lib/docker/swarm/task.rb', line 15 def image return @hash['Spec']['ContainerSpec']['Image'] end |
#networks ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/docker/swarm/task.rb', line 53 def networks all_networks = @swarm.networks nets = [] self.hash['NetworksAttachments'].each do |net_hash| hash = net_hash['Network'] network_id = hash['ID'] nets << all_networks.find {|net| net.id == network_id} end return nets end |
#node ⇒ Object
33 34 35 |
# File 'lib/docker/swarm/task.rb', line 33 def node return @swarm.nodes.find {|n| n.id == self.node_id} end |
#node_id ⇒ Object
29 30 31 |
# File 'lib/docker/swarm/task.rb', line 29 def node_id @hash['NodeID'] end |
#service ⇒ Object
23 24 25 26 27 |
# File 'lib/docker/swarm/task.rb', line 23 def service return @swarm.services.find { |service| self.service_id == service.id } end |
#service_id ⇒ Object
19 20 21 |
# File 'lib/docker/swarm/task.rb', line 19 def service_id @hash['ServiceID'] end |
#status ⇒ Object
41 42 43 |
# File 'lib/docker/swarm/task.rb', line 41 def status @hash['Status']['State'].to_sym end |
#status_message ⇒ Object
49 50 51 |
# File 'lib/docker/swarm/task.rb', line 49 def @hash['Status']['Message'] end |
#status_timestamp ⇒ Object
45 46 47 |
# File 'lib/docker/swarm/task.rb', line 45 def return DateTime.parse(@hash['Status']['Timestamp']) end |