class Vagrant::Plugin::Remote::Communicator

Attributes

client[RW]

Add an attribute accesor for the client when applied to the Communicator class

Public Class Methods

new(machine, **kwargs) click to toggle source
# File lib/vagrant/plugin/remote/communicator.rb, line 9
def initialize(machine, **kwargs)
  @logger = Log4r::Logger.new("vagrant::remote::communicator")
  @logger.debug("initializing communicator with remote backend")
  @machine = machine
  @client = kwargs.fetch(:client, machine.client.communicate)
  if @client.nil?
    raise ArgumentError,
      "Remote client is required for `#{self.class.name}`"
  end
end

Public Instance Methods

download(from, to) click to toggle source
# File lib/vagrant/plugin/remote/communicator.rb, line 30
def download(from, to)
  @logger.debug("remote communicator, downloading #{from} -> #{to}")
  @client.download(@machine, from, to)
end
execute(cmd, opts=nil) { |:stdout, stdout| ... } click to toggle source
# File lib/vagrant/plugin/remote/communicator.rb, line 40
def execute(cmd, opts=nil, &block)
  @logger.debug("remote communicator, executing command")
  res = @client.execute(@machine, cmd, opts)
  yield :stdout, res.stdout if block_given?
  yield :stderr, res.stderr if block_given?
  res.exit_code
end
ready?() click to toggle source
# File lib/vagrant/plugin/remote/communicator.rb, line 20
def ready?
  @logger.debug("remote communicator, checking if it's ready")
  @client.ready(@machine)
end
reset!() click to toggle source
# File lib/vagrant/plugin/remote/communicator.rb, line 61
def reset!
  @logger.debug("remote communicator, reseting")
  @client.reset(@machine)
end
sudo(cmd, opts=nil) { |:stdout, stdout| ... } click to toggle source
# File lib/vagrant/plugin/remote/communicator.rb, line 48
def sudo(cmd, opts=nil, &block)
  @logger.debug("remote communicator, executing (privileged) command")
  res = @client.privileged_execute(@machine, cmd, opts)
  yield :stdout, res.stdout if block_given?
  yield :stderr, res.stderr if block_given?
  res.exit_code
end
test(cmd, opts=nil) click to toggle source
# File lib/vagrant/plugin/remote/communicator.rb, line 56
def test(cmd, opts=nil)
  @logger.debug("remote communicator, testing command")
  @client.test(@machine, cmd, opts)
end
to_proto() click to toggle source
# File lib/vagrant/plugin/remote/communicator.rb, line 66
def to_proto
  client.proto
end
upload(from, to) click to toggle source
# File lib/vagrant/plugin/remote/communicator.rb, line 35
def upload(from, to)
  @logger.debug("remote communicator, uploading #{from} -> #{to}")
  @client.upload(@machine, from, to)
end
wait_for_ready(time) click to toggle source
# File lib/vagrant/plugin/remote/communicator.rb, line 25
def wait_for_ready(time)
  @logger.debug("remote communicator, waiting for ready")
  @client.wait_for_ready(@machine, time)
end