Class: VagrantPlugins::DockerProvider::Provider
- Inherits:
-
Object
- Object
- VagrantPlugins::DockerProvider::Provider
- Defined in:
- lib/docker-provider/provider.rb
Instance Attribute Summary collapse
-
#driver ⇒ Object
readonly
Returns the value of attribute driver.
Instance Method Summary collapse
- #action(name) ⇒ Object
-
#initialize(machine) ⇒ Provider
constructor
A new instance of Provider.
-
#ssh_info ⇒ Object
Returns the SSH info for accessing the Container.
- #state ⇒ Object
- #to_s ⇒ Object
Constructor Details
Instance Attribute Details
#driver ⇒ Object (readonly)
Returns the value of attribute driver.
7 8 9 |
# File 'lib/docker-provider/provider.rb', line 7 def driver @driver end |
Instance Method Details
#action(name) ⇒ Object
16 17 18 19 20 |
# 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 ⇒ Object
Returns the SSH info for accessing the Container.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# 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 ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# 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 ⇒ Object
53 54 55 56 |
# File 'lib/docker-provider/provider.rb', line 53 def to_s id = @machine.id ? @machine.id : "new container" "Docker (#{id})" end |