Class: Armada::Host

Inherits:
Object
  • Object
show all
Defined in:
lib/armada/docker/host.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(docker_connection) ⇒ Host

Returns a new instance of Host.



4
5
6
# File 'lib/armada/docker/host.rb', line 4

def initialize(docker_connection)
  @docker_connection = docker_connection
end

Instance Attribute Details

#docker_connectionObject (readonly)

Returns the value of attribute docker_connection.



3
4
5
# File 'lib/armada/docker/host.rb', line 3

def docker_connection
  @docker_connection
end

Class Method Details

.create(host, options = {}) ⇒ Object



64
65
66
# File 'lib/armada/docker/host.rb', line 64

def self.create(host, options = {})
  Host.new(Armada::Connection::Docker.new(host, options[:ssh_gateway], options[:ssh_gateway_user]))
end

Instance Method Details

#connectionObject



48
49
50
# File 'lib/armada/docker/host.rb', line 48

def connection
  @docker_connection.connection
end

#get_all_containersObject



36
37
38
# File 'lib/armada/docker/host.rb', line 36

def get_all_containers
  ::Docker::Container.all({:all => true}, connection)
end

#get_all_imagesObject



32
33
34
# File 'lib/armada/docker/host.rb', line 32

def get_all_images
  ::Docker::Image.all({:all => true}, connection)
end

#get_container(id) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/armada/docker/host.rb', line 40

def get_container(id)
  begin
    return ::Docker::Container.get(id, {}, connection)
  rescue Exception => e
    return nil
  end
end

#get_image(name, tag, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/armada/docker/host.rb', line 8

def get_image(name, tag, options = {})
  begin
    image = ::Docker::Image.get("#{name}:#{tag}", {}, connection)
    options[:docker_image] = image
    options[:id] = image.id if image
  rescue Exception => e
    Armada.ui.warn "#{host} -- #{e.message}"
  ensure
    return Image.new(self, options)
  end
end

#get_image_by_id(id, options) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/armada/docker/host.rb', line 20

def get_image_by_id(id, options)
  begin
    image = ::Docker::Image.get(id, {}, connection)
    options[:docker_image] = image
    options[:id] = id
  rescue Exception => e
    Armada.ui.warn "#{host} -- #{e.message}"
  ensure
    return Image.new(self, options)
  end
end

#hostObject



52
53
54
# File 'lib/armada/docker/host.rb', line 52

def host
  @docker_connection.host
end

#portObject



56
57
58
# File 'lib/armada/docker/host.rb', line 56

def port
  @docker_connection.port
end

#to_sObject



60
61
62
# File 'lib/armada/docker/host.rb', line 60

def to_s
  "#{host}:#{port} -- #{connection}"
end