class VagrantPlugins::DockerProvider::Provider
Attributes
driver[R]
Public Class Methods
new(machine)
click to toggle source
# File lib/docker-provider/provider.rb, line 9 def initialize(machine) @logger = Log4r::Logger.new("vagrant::provider::docker") @machine = machine @driver = Driver.new end
Public Instance Methods
action(name)
click to toggle source
@see Vagrant::Plugin::V2::Provider#action
# File lib/docker-provider/provider.rb, line 16 def action(name) action_method = "action_#{name}" return Action.send(action_method) if Action.respond_to?(action_method) nil end
ssh_info()
click to toggle source
Returns the SSH info for accessing the Container.
# File lib/docker-provider/provider.rb, line 23 def ssh_info # If the Container is not created then we cannot possibly SSH into it, so # we return nil. return nil if state == :not_created network = @driver.inspect_container(@machine.id)['NetworkSettings'] ip = network['IPAddress'] # If we were not able to identify the container's IP, we return nil # here and we let Vagrant core deal with it ;) return nil unless ip { :host => ip, :port => @machine.config.ssh.guest_port } end
state()
click to toggle source
# File lib/docker-provider/provider.rb, line 41 def state state_id = nil state_id = :not_created if !@machine.id || !@driver.created?(@machine.id) state_id = @driver.state(@machine.id) if @machine.id && !state_id state_id = :unknown if !state_id short = state_id.to_s.gsub("_", " ") long = I18n.t("vagrant.commands.status.#{state_id}") Vagrant::MachineState.new(state_id, short, long) end
to_s()
click to toggle source
# File lib/docker-provider/provider.rb, line 53 def to_s id = @machine.id ? @machine.id : "new container" "Docker (#{id})" end