It looks like I might have been the first to hit provider cabability invocation in testing these changes, and so I found these few missing methods on the client. They're just copied over from the other capability hosts. Calling capabilities on a provider also revealed that the wrong Machine type was being pulled out of the funcspec args, so we had to correct that too in order to get the capability calls working.
76 lines
2.0 KiB
Ruby
76 lines
2.0 KiB
Ruby
module Vagrant
|
|
module Plugin
|
|
module Remote
|
|
class Provider < V2::Provider
|
|
class << self
|
|
attr_reader :client
|
|
end
|
|
|
|
attr_accessor :client
|
|
|
|
def self.usable?(raise_error=false)
|
|
client.usable?
|
|
end
|
|
|
|
def self.installed?
|
|
client.installed?
|
|
end
|
|
|
|
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
|
|
|
|
def action(name)
|
|
client.action(@machine.to_proto, name)
|
|
end
|
|
|
|
# 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
|
|
def capability(cap_name, *args)
|
|
@logger.debug("running remote provider capability #{cap_name} with args #{args}")
|
|
client.capability(cap_name, *args)
|
|
end
|
|
|
|
# Tests whether the given capability is possible.
|
|
#
|
|
# @param [Symbol] cap_name Capability name
|
|
# @return [Boolean]
|
|
def capability?(cap_name)
|
|
@logger.debug("checking for remote provider capability #{cap_name}")
|
|
client.has_capability?(cap_name)
|
|
end
|
|
|
|
def machine_id_changed
|
|
client.machine_id_changed(@machine.to_proto)
|
|
end
|
|
|
|
def ssh_info
|
|
client.ssh_info(@machine.to_proto)
|
|
end
|
|
|
|
def state
|
|
client.state(@machine.to_proto)
|
|
end
|
|
|
|
def initialize_capabilities!(*args, **opts)
|
|
# no-op
|
|
end
|
|
|
|
def to_proto
|
|
client.proto
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|