Module: Vagrant::Guest::Remote
- Defined in:
- lib/vagrant/guest/remote.rb
Overview
This module enables Guests for server mode
Class Method Summary collapse
-
.prepended(klass) ⇒ Object
Add an attribute accesor for the client when applied to the Guest class.
Instance Method Summary collapse
-
#capability(cap_name, *args) ⇒ Object
Executes the capability with the given name, optionally passing more arguments onwards to the capability.
-
#capability?(cap_name) ⇒ Boolean
Tests whether the given capability is possible.
- #detect! ⇒ Object
- #initialize(machine, guests, capabilities) ⇒ Object
- #initialize_capabilities!(host, hosts, capabilities, *args) ⇒ Object
-
#name ⇒ Symbol
Returns the specified or detected guest type name.
-
#parent ⇒ String
Returns the parent of the guest.
- #ready? ⇒ Boolean
- #to_proto ⇒ Object
Class Method Details
.prepended(klass) ⇒ Object
Add an attribute accesor for the client when applied to the Guest class
11 12 13 14 15 |
# File 'lib/vagrant/guest/remote.rb', line 11 def self.prepended(klass) klass.class_eval do attr_accessor :client end end |
Instance Method Details
#capability(cap_name, *args) ⇒ Object
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.
38 39 40 41 42 43 44 45 46 |
# File 'lib/vagrant/guest/remote.rb', line 38 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) ⇒ Boolean
Tests whether the given capability is possible.
52 53 54 55 |
# File 'lib/vagrant/guest/remote.rb', line 52 def capability?(cap_name) @logger.debug("checking for remote guest capability #{cap_name}") client.has_capability?(cap_name) end |
#detect! ⇒ Object
27 28 29 30 31 |
# File 'lib/vagrant/guest/remote.rb', line 27 def detect! # no-op # This operation not happen in Ruby, instead rely # on getting the guest from the remote machine end |
#initialize(machine, guests, capabilities) ⇒ Object
17 18 19 20 21 |
# File 'lib/vagrant/guest/remote.rb', line 17 def initialize(machine, guests, capabilities) @machine = machine @client = machine.client.guest @logger = Log4r::Logger.new("vagrant::guest") end |
#initialize_capabilities!(host, hosts, capabilities, *args) ⇒ Object
23 24 25 |
# File 'lib/vagrant/guest/remote.rb', line 23 def initialize_capabilities!(host, hosts, capabilities, *args) # no-op end |
#name ⇒ Symbol
Returns the specified or detected guest type name.
68 69 70 |
# File 'lib/vagrant/guest/remote.rb', line 68 def name client.name end |
#parent ⇒ String
Returns the parent of the guest.
75 76 77 |
# File 'lib/vagrant/guest/remote.rb', line 75 def parent client.parent end |
#ready? ⇒ Boolean
58 59 60 61 62 63 |
# File 'lib/vagrant/guest/remote.rb', line 58 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 ⇒ Object
79 80 81 |
# File 'lib/vagrant/guest/remote.rb', line 79 def to_proto client.proto end |