Class: VagrantPlugins::WinAzure::Action::WaitForCommunicate

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-azure/action/wait_for_communicate.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ WaitForCommunicate

Returns a new instance of WaitForCommunicate.



12
13
14
15
# File 'lib/vagrant-azure/action/wait_for_communicate.rb', line 12

def initialize(app, env)
  @app = app
  @logger = Log4r::Logger.new("vagrant_azure::action::wait_for_communicate")
end

Instance Method Details

#call(env) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/vagrant-azure/action/wait_for_communicate.rb', line 17

def call(env)

  if !env[:interrupted]
      # Wait for SSH to be ready.

      env[:ui].info(I18n.t("vagrant_azure.waiting_for_ssh"))
      while true
        # If we're interrupted then just back out

        break if env[:interrupted]
        break if env[:machine].communicate.ready?
        sleep 5
      end

    # Ready and booted!

    env[:ui].info(I18n.t("vagrant_azure.ssh_ready"))
  end

  @app.call(env)
end