Method: Vagrant::Machine#communicate

Defined in:
lib/vagrant/machine.rb

#communicateObject

Returns a communication object for executing commands on the remote machine. Note that the exact semantics of this are up to the communication provider itself. Despite this, the semantics are expected to be consistent across operating systems. For example, all linux-based systems should have similar communication (usually a shell). All Windows systems should have similar communication as well. Therefore, prior to communicating with the machine, users of this method are expected to check the guest OS to determine their behavior.

This method will always return some valid communication object. The ready? API can be used on the object to check if communication is actually ready.

Returns:

  • (Object)


146
147
148
149
150
151
152
153
154
155
# File 'lib/vagrant/machine.rb', line 146

def communicate
  if !@communicator
    # For now, we always return SSH. In the future, we'll abstract
    # this and allow plugins to define new methods of communication.
    klass = Vagrant.plugin("2").manager.communicators[:ssh]
    @communicator = klass.new(self)
  end

  @communicator
end