Class: Spurious::Server::State::Ports

Inherits:
Base
  • Object
show all
Defined in:
lib/spurious/server/state/ports.rb

Instance Attribute Summary

Attributes inherited from Base

#config, #connection

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Spurious::Server::State::Base

Instance Method Details

#execute!Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/spurious/server/state/ports.rb', line 10

def execute!
  ports = {}
  spurious_containers.peach do |container|
    config = container_config(container.json["Name"])
    ports[sanitize(container.json["Name"])] = []

    if !container.json["NetworkSettings"]["Ports"].nil? then

      container.json["NetworkSettings"]["Ports"].each do |guest, mapping|
        mapping.each do |map|
          ports[sanitize(container.json["Name"])] << {
            :GuestPort  => guest.split('/').first,
            :HostPort   => map["HostPort"]
         }
        end
      end

    end

  end
  send ports, true

  connection.unbind
rescue Exception => e
  puts e.message
end