Class: Docker::Swarm::Task

Inherits:
Object
  • Object
show all
Defined in:
lib/docker/swarm/task.rb

Overview

This class represents a Docker Swarm Node.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Task

Returns a new instance of Task.

[View source]

6
7
8
# File 'lib/docker/swarm/task.rb', line 6

def initialize(hash)
  @hash = hash
end

Instance Attribute Details

#hashObject (readonly)

include Docker::Base


4
5
6
# File 'lib/docker/swarm/task.rb', line 4

def hash
  @hash
end

Class Method Details

.all(opts = {}, conn = Docker.connection) ⇒ Object

Return all of the Nodes.

[View source]

35
36
37
38
39
40
41
42
43
44
45
# File 'lib/docker/swarm/task.rb', line 35

def self.all(opts = {}, conn = Docker.connection)
  raise "opts needs to be hash" if (opts.class != Hash)
  query = {}
  resp = conn.get('/tasks', query, :body => opts.to_json)
  hashes = JSON.parse(resp)
  items = []
  hashes.each do |hash|
    items << Docker::Swarm::Task.new(hash)
  end
  return items
end

Instance Method Details

#created_atObject

[View source]

26
27
28
# File 'lib/docker/swarm/task.rb', line 26

def created_at
  return DateTime.parse(@hash.first['CreatedAt'])
end

#idObject

[View source]

10
11
12
# File 'lib/docker/swarm/task.rb', line 10

def id 
  return @hash['ID']
end

#imageObject

[View source]

14
15
16
# File 'lib/docker/swarm/task.rb', line 14

def image
  return @hash['Spec']['ContainerSpec']['Image']
end

#node_idObject

[View source]

22
23
24
# File 'lib/docker/swarm/task.rb', line 22

def node_id
  @hash['NodeID']
end

#service_idObject

[View source]

18
19
20
# File 'lib/docker/swarm/task.rb', line 18

def service_id
  @hash['ServiceID']
end

#statusObject

[View source]

30
31
32
# File 'lib/docker/swarm/task.rb', line 30

def status
  @hash['Status']['State'].to_sym
end