Class: Vagrant::Plugin::Remote::Provider

Inherits:
V2::Provider show all
Defined in:
lib/vagrant/plugin/remote/provider.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from V2::Provider

#_initialize

Methods included from CapabilityHost

#capability_host_chain

Constructor Details

#initialize(machine, **opts) ⇒ Provider

Returns a new instance of Provider.



22
23
24
25
26
27
28
29
30
31
# File 'lib/vagrant/plugin/remote/provider.rb', line 22

def initialize(machine, **opts)
  @logger = Log4r::Logger.new("vagrant::remote::provider")
  @logger.debug("initializing provider with remote backend")
  @machine = machine
  if opts[:client].nil?
    raise ArgumentError,
      "Remote client is required for `#{self.class.name}`"
  end
  @client = opts.delete(:client)
end

Class Attribute Details

.clientObject (readonly)

Returns the value of attribute client.



9
10
11
# File 'lib/vagrant/plugin/remote/provider.rb', line 9

def client
  @client
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



12
13
14
# File 'lib/vagrant/plugin/remote/provider.rb', line 12

def client
  @client
end

Class Method Details

.installed?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/vagrant/plugin/remote/provider.rb', line 18

def self.installed?
  client.installed?
end

.usable?(raise_error = false) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/vagrant/plugin/remote/provider.rb', line 14

def self.usable?(raise_error=false)
  client.usable?
end

Instance Method Details

#action(name) ⇒ Object



33
34
35
# File 'lib/vagrant/plugin/remote/provider.rb', line 33

def action(name)
  client.action(@machine.to_proto, name)
end

#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.

Parameters:

  • cap_name (Symbol)

    Name of the capability



42
43
44
45
# File 'lib/vagrant/plugin/remote/provider.rb', line 42

def capability(cap_name, *args)
  @logger.debug("running remote provider capability #{cap_name} with args #{args}")
  client.capability(cap_name, @machine, *args)
end

#capability?(cap_name) ⇒ Boolean

Tests whether the given capability is possible.

Parameters:

  • cap_name (Symbol)

    Capability name

Returns:

  • (Boolean)


51
52
53
54
# File 'lib/vagrant/plugin/remote/provider.rb', line 51

def capability?(cap_name)
  @logger.debug("checking for remote provider capability #{cap_name}")
  client.has_capability?(cap_name)
end

#initialize_capabilities!(*args, **opts) ⇒ Object



68
69
70
# File 'lib/vagrant/plugin/remote/provider.rb', line 68

def initialize_capabilities!(*args, **opts)
  # no-op
end

#machine_id_changedObject



56
57
58
# File 'lib/vagrant/plugin/remote/provider.rb', line 56

def machine_id_changed
  client.machine_id_changed(@machine.to_proto)
end

#ssh_infoObject



60
61
62
# File 'lib/vagrant/plugin/remote/provider.rb', line 60

def ssh_info
  client.ssh_info(@machine.to_proto)
end

#stateObject



64
65
66
# File 'lib/vagrant/plugin/remote/provider.rb', line 64

def state
  client.state(@machine.to_proto)
end

#to_protoObject



72
73
74
# File 'lib/vagrant/plugin/remote/provider.rb', line 72

def to_proto
  client.proto
end