Ensure all remote plugins handle client setup
This commit is contained in:
parent
7e9dad2b3e
commit
0ad82cf04a
@ -6,11 +6,15 @@ module Vagrant
|
||||
# when applied to the Communicator class
|
||||
attr_accessor :client
|
||||
|
||||
def initialize(machine)
|
||||
def initialize(machine, **kwargs)
|
||||
@logger = Log4r::Logger.new("vagrant::remote::communicator")
|
||||
@logger.debug("initializing communicator with remote backend")
|
||||
@machine = machine
|
||||
@client = machine.client.communicate
|
||||
@client = kwargs.fetch(:client, machine.client.communicate)
|
||||
if @client.nil?
|
||||
raise ArgumentError,
|
||||
"Remote client is required for `#{self.class.name}`"
|
||||
end
|
||||
end
|
||||
|
||||
def ready?
|
||||
|
||||
@ -1,23 +1,22 @@
|
||||
module Vagrant
|
||||
module Plugin
|
||||
module Remote
|
||||
class Guest
|
||||
# This module enables Guest for server mode
|
||||
module Remote
|
||||
class Guest < V2::Guest
|
||||
attr_accessor :client
|
||||
|
||||
# Add an attribute accesor for the client
|
||||
# when applied to the Guest class
|
||||
def self.prepended(klass)
|
||||
klass.class_eval do
|
||||
attr_accessor :client
|
||||
end
|
||||
def initialize(*_, **kwargs)
|
||||
@client = kwargs.delete(:client)
|
||||
if @client.nil?
|
||||
raise ArgumentError,
|
||||
"Remote client is required for `#{self.class.name}`"
|
||||
end
|
||||
super
|
||||
end
|
||||
|
||||
# @return [Boolean]
|
||||
def detect?(machine)
|
||||
client = machine.client.guest
|
||||
client.detect(machine)
|
||||
end
|
||||
# @return [Boolean]
|
||||
def detect?(machine)
|
||||
client = machine.client.guest
|
||||
client.detect(machine)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -24,8 +24,7 @@ module Vagrant
|
||||
raise ArgumentError,
|
||||
"Remote client is required for `#{self.class.name}`"
|
||||
end
|
||||
@client = opts[:client]
|
||||
super(machine)
|
||||
@client = opts.delete(:client)
|
||||
end
|
||||
|
||||
def action(name)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user