Permalink
Browse files

Just always return the SSH communicator for machines for now.

In the future we'll actually find a matching communicator but for now
since we're just focusing on machine abstraction, we just return SSH.
  • Loading branch information...
1 parent 5ae3e0e commit 64afd578b3e0baace6243e587c0f2117bcb973d0 @mitchellh committed Aug 9, 2012
Showing with 26 additions and 4 deletions.
  1. +13 −2 lib/vagrant/machine.rb
  2. +2 −2 plugins/communicators/ssh/communicator.rb
  3. +11 −0 test/unit/vagrant/machine_test.rb
View
@@ -107,9 +107,20 @@ def action(name, extra_env=nil)
#
# @return [Object]
def communicate
- # For now, we always return SSH. In the future, we'll abstract
- # this and allow plugins to define new methods of communication.
+ if !@communicator
+ # For now, we always return SSH. In the future, we'll abstract
+ # this and allow plugins to define new methods of communication.
+ Vagrant.plugin("1").registered.each do |plugin|
+ klass = plugin.communicator[:ssh]
+ if klass
+ # This plugin has the SSH communicator, use it.
+ @communicator = klass.new(self)
+ break
+ end
+ end
+ end
+ @communicator
end
# This sets the unique ID associated with this machine. This will
@@ -14,8 +14,8 @@ module VagrantPlugins
module CommunicatorSSH
# This class provides communication with the VM via SSH.
class Communicator < Vagrant.plugin("1", :communicator)
- include Util::ANSIEscapeCodeRemover
- include Util::Retryable
+ include Vagrant::Util::ANSIEscapeCodeRemover
+ include Vagrant::Util::Retryable
def self.match?(machine)
# All machines are currently expected to have SSH.
@@ -170,6 +170,17 @@ def provider_init_test
end
end
+ describe "communicator" do
+ it "should always return the SSH communicator" do
+ instance.communicate.should be_kind_of(VagrantPlugins::CommunicatorSSH::Communicator)
+ end
+
+ it "should memoize the result" do
+ obj = instance.communicate
+ instance.communicate.should eql(obj)
+ end
+ end
+
describe "setting the ID" do
it "should not have an ID by default" do
instance.id.should be_nil

0 comments on commit 64afd57

Please sign in to comment.