module Vagrant::Guest::Remote

This module enables Guests for server mode

Public Class Methods

new(machine, guests, capabilities) click to toggle source
# File lib/vagrant/guest/remote.rb, line 14
def initialize(machine, guests, capabilities)
  @machine = machine
  @client = machine.client.guest
  @logger = Log4r::Logger.new("vagrant::guest")
end
prepended(klass) click to toggle source

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

# File lib/vagrant/guest/remote.rb, line 8
def self.prepended(klass)
  klass.class_eval do
    attr_accessor :client
  end
end

Public Instance Methods

capability(cap_name, *args) click to toggle source

Executes the capability with the given name, optionally passing more arguments onwards to the capability. If the capability returns a value, it will be returned.

@param [Symbol] cap_name Name of the capability

# File lib/vagrant/guest/remote.rb, line 35
def capability(cap_name, *args)
  @logger.debug("running remote guest capability #{cap_name} with args #{args}")
  if !client.has_capability?(cap_name)
    raise Errors::GuestCapabilityNotFound,
    cap:  cap_name.to_s,
    guest: name
  end
  client.capability(cap_name, @machine.to_proto, *args)
end
capability?(cap_name) click to toggle source

Tests whether the given capability is possible.

@param [Symbol] cap_name Capability name @return [Boolean]

# File lib/vagrant/guest/remote.rb, line 49
def capability?(cap_name)
  @logger.debug("checking for remote guest capability #{cap_name}")
  client.has_capability?(cap_name)
end
detect!() click to toggle source
# File lib/vagrant/guest/remote.rb, line 24
def detect!
  # no-op
  # This operation not happen in Ruby, instead rely
  # on getting the guest from the remote machine
end
initialize_capabilities!(host, hosts, capabilities, *args) click to toggle source
# File lib/vagrant/guest/remote.rb, line 20
def initialize_capabilities!(host, hosts, capabilities, *args)
  # no-op
end
name() click to toggle source

Returns the specified or detected guest type name.

@return [Symbol]

# File lib/vagrant/guest/remote.rb, line 65
def name
  client.name
end
parent() click to toggle source

Returns the parent of the guest.

@return [String]

# File lib/vagrant/guest/remote.rb, line 72
def parent
  client.parent
end
ready?() click to toggle source

@return [Boolean]

# File lib/vagrant/guest/remote.rb, line 55
def ready?
  # A remote guest is always "ready". That is, guest detection has already
  # completed on the go side. So, at this stage and the communicator is
  # certainly available.
  true
end
to_proto() click to toggle source
# File lib/vagrant/guest/remote.rb, line 76
def to_proto
  client.proto
end