Use remote plugin module when in server mode
This commit is contained in:
parent
e951c4d971
commit
d5007d4d85
@ -199,9 +199,10 @@ begin
|
|||||||
# Doing this prevents Vagrant from attempting to load an
|
# Doing this prevents Vagrant from attempting to load an
|
||||||
# Environment directly.
|
# Environment directly.
|
||||||
if sub_cmd == "serve"
|
if sub_cmd == "serve"
|
||||||
|
cmd = Vagrant.plugin("2").manager.commands[:serve].first
|
||||||
Vagrant.enable_server_mode!
|
Vagrant.enable_server_mode!
|
||||||
cmd = Vagrant.plugin("2").manager.commands[:serve].first.call
|
cmd_call = cmd.call
|
||||||
result = cmd.new([], nil).execute
|
result = cmd_call.new([], nil).execute
|
||||||
exit(result)
|
exit(result)
|
||||||
else
|
else
|
||||||
# Create the environment, which is the cwd of wherever the
|
# Create the environment, which is the cwd of wherever the
|
||||||
|
|||||||
@ -181,6 +181,8 @@ module Vagrant
|
|||||||
c.register([:"2", :provisioner]) { Plugin::V2::Provisioner }
|
c.register([:"2", :provisioner]) { Plugin::V2::Provisioner }
|
||||||
c.register([:"2", :push]) { Plugin::V2::Push }
|
c.register([:"2", :push]) { Plugin::V2::Push }
|
||||||
c.register([:"2", :synced_folder]) { Plugin::V2::SyncedFolder }
|
c.register([:"2", :synced_folder]) { Plugin::V2::SyncedFolder }
|
||||||
|
|
||||||
|
c.register(:remote) { Plugin::Remote::Plugin }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Configure a Vagrant environment. The version specifies the version
|
# Configure a Vagrant environment. The version specifies the version
|
||||||
@ -229,6 +231,10 @@ module Vagrant
|
|||||||
# @param [String] component
|
# @param [String] component
|
||||||
# @return [Class]
|
# @return [Class]
|
||||||
def self.plugin(version, component=nil)
|
def self.plugin(version, component=nil)
|
||||||
|
# TODO
|
||||||
|
if component.nil? && Vagrant.server_mode?
|
||||||
|
version = "remote"
|
||||||
|
end
|
||||||
# Build up the key and return a result
|
# Build up the key and return a result
|
||||||
key = version.to_s.to_sym
|
key = version.to_s.to_sym
|
||||||
key = [key, component.to_s.to_sym] if component
|
key = [key, component.to_s.to_sym] if component
|
||||||
|
|||||||
@ -18,25 +18,32 @@ module Vagrant
|
|||||||
@registered = {}
|
@registered = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
# This returns all the registered communicators.
|
# This returns all the registered commands.
|
||||||
|
#
|
||||||
|
# @return [Registry<Symbol, Array<Proc, Hash>>]
|
||||||
|
def commands
|
||||||
|
@registered[:command]
|
||||||
|
end
|
||||||
|
|
||||||
|
# This returns all the registered communicators.
|
||||||
#
|
#
|
||||||
# @return [Hash]
|
# @return [Hash]
|
||||||
def communicators
|
def communicators
|
||||||
registered[:communincator]
|
@registered[:communincator]
|
||||||
end
|
end
|
||||||
|
|
||||||
# This returns all the registered guests.
|
# This returns all the registered guests.
|
||||||
#
|
#
|
||||||
# @return [Hash]
|
# @return [Hash]
|
||||||
def guests
|
def guests
|
||||||
registered[:guest]
|
@registered[:guest]
|
||||||
end
|
end
|
||||||
|
|
||||||
# This returns all the registered guests.
|
# This returns all the registered guests.
|
||||||
#
|
#
|
||||||
# @return [Hash]
|
# @return [Hash]
|
||||||
def hosts
|
def hosts
|
||||||
registered[:host]
|
@registered[:host]
|
||||||
end
|
end
|
||||||
|
|
||||||
# This returns all synced folder implementations.
|
# This returns all synced folder implementations.
|
||||||
|
|||||||
@ -2,7 +2,21 @@ module Vagrant
|
|||||||
module Plugin
|
module Plugin
|
||||||
module Remote
|
module Remote
|
||||||
# This is the wrapper class for all Remote plugins.
|
# This is the wrapper class for all Remote plugins.
|
||||||
class Plugin
|
class Plugin < Vagrant::Plugin::V2::Plugin
|
||||||
|
|
||||||
|
# This returns the manager for all Remote plugins.
|
||||||
|
#
|
||||||
|
# @return [Remote::Manager]
|
||||||
|
def self.manager
|
||||||
|
@manager ||= Manager.new
|
||||||
|
end
|
||||||
|
|
||||||
|
# Returns the {Components} for this plugin.
|
||||||
|
#
|
||||||
|
# @return [Components]
|
||||||
|
def self.components
|
||||||
|
@components ||= Vagrant::Plugin::V2::Components.new
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -8,7 +8,7 @@ module VagrantPlugins
|
|||||||
include CapabilityPlatformService
|
include CapabilityPlatformService
|
||||||
|
|
||||||
def initialize(*args, **opts, &block)
|
def initialize(*args, **opts, &block)
|
||||||
caps = Vagrant.plugin("2").manager.guest_capabilities
|
caps = Vagrant::Plugin::V2::Plugin.manager.guest_capabilities
|
||||||
default_args = {
|
default_args = {
|
||||||
Client::Target => SDK::FuncSpec::Value.new(
|
Client::Target => SDK::FuncSpec::Value.new(
|
||||||
type: "hashicorp.vagrant.sdk.Args.Target",
|
type: "hashicorp.vagrant.sdk.Args.Target",
|
||||||
@ -40,7 +40,7 @@ module VagrantPlugins
|
|||||||
with_info(ctx) do |info|
|
with_info(ctx) do |info|
|
||||||
plugin_name = info.plugin_name
|
plugin_name = info.plugin_name
|
||||||
machine = mapper.funcspec_map(req, expect: Vagrant::Machine)
|
machine = mapper.funcspec_map(req, expect: Vagrant::Machine)
|
||||||
plugin = Vagrant.plugin("2").manager.guests[plugin_name.to_s.to_sym].to_a.first
|
plugin = Vagrant::Plugin::V2::Plugin.manager.guests[plugin_name.to_s.to_sym].to_a.first
|
||||||
if !plugin
|
if !plugin
|
||||||
logger.debug("Failed to locate guest plugin for: #{plugin_name}")
|
logger.debug("Failed to locate guest plugin for: #{plugin_name}")
|
||||||
raise "Failed to locate guest plugin for: #{plugin_name.inspect}"
|
raise "Failed to locate guest plugin for: #{plugin_name.inspect}"
|
||||||
@ -72,7 +72,7 @@ module VagrantPlugins
|
|||||||
def parent(req, ctx)
|
def parent(req, ctx)
|
||||||
with_info(ctx) do |info|
|
with_info(ctx) do |info|
|
||||||
plugin_name = info.plugin_name
|
plugin_name = info.plugin_name
|
||||||
guest_hash = Vagrant.plugin("2").manager.guests[plugin_name.to_s.to_sym].to_a
|
guest_hash = Vagrant::Plugin::V2::Plugin.manager.guests[plugin_name.to_s.to_sym].to_a
|
||||||
plugin = guest_hash.first
|
plugin = guest_hash.first
|
||||||
if !plugin
|
if !plugin
|
||||||
raise "Failed to locate guest plugin for: #{plugin_name.inspect}"
|
raise "Failed to locate guest plugin for: #{plugin_name.inspect}"
|
||||||
|
|||||||
@ -8,7 +8,7 @@ module VagrantPlugins
|
|||||||
include CapabilityPlatformService
|
include CapabilityPlatformService
|
||||||
|
|
||||||
def initialize(*args, **opts, &block)
|
def initialize(*args, **opts, &block)
|
||||||
caps = Vagrant.plugin("2").manager.host_capabilities
|
caps =Vagrant::Plugin::V2::Plugin.manager.host_capabilities
|
||||||
default_args = {
|
default_args = {
|
||||||
Vagrant::Environment => SDK::FuncSpec::Value.new(
|
Vagrant::Environment => SDK::FuncSpec::Value.new(
|
||||||
type: "hashicorp.vagrant.sdk.Args.Project",
|
type: "hashicorp.vagrant.sdk.Args.Project",
|
||||||
@ -39,7 +39,7 @@ module VagrantPlugins
|
|||||||
with_info(ctx) do |info|
|
with_info(ctx) do |info|
|
||||||
plugin_name = info.plugin_name
|
plugin_name = info.plugin_name
|
||||||
statebag = mapper.funcspec_map(req, expect: Client::StateBag)
|
statebag = mapper.funcspec_map(req, expect: Client::StateBag)
|
||||||
plugin = Vagrant.plugin("2").manager.hosts[plugin_name.to_s.to_sym].to_a.first
|
plugin = Vagrant::Plugin::V2::Plugin.manager.hosts[plugin_name.to_s.to_sym].to_a.first
|
||||||
if !plugin
|
if !plugin
|
||||||
raise "Failed to locate host plugin for: #{plugin_name.inspect}"
|
raise "Failed to locate host plugin for: #{plugin_name.inspect}"
|
||||||
end
|
end
|
||||||
@ -70,7 +70,7 @@ module VagrantPlugins
|
|||||||
def parent(req, ctx)
|
def parent(req, ctx)
|
||||||
with_info(ctx) do |info|
|
with_info(ctx) do |info|
|
||||||
plugin_name = info.plugin_name
|
plugin_name = info.plugin_name
|
||||||
host_hash = Vagrant.plugin("2").manager.hosts[plugin_name.to_s.to_sym].to_a
|
host_hash = Vagrant::Plugin::V2::Plugin.manager.hosts[plugin_name.to_s.to_sym].to_a
|
||||||
plugin = host_hash.first
|
plugin = host_hash.first
|
||||||
if !plugin
|
if !plugin
|
||||||
raise "Failed to locate host plugin for: #{plugin_name.inspect}"
|
raise "Failed to locate host plugin for: #{plugin_name.inspect}"
|
||||||
|
|||||||
@ -43,7 +43,7 @@ module VagrantPlugins
|
|||||||
project = target.project
|
project = target.project
|
||||||
env = Vagrant::Environment.new({client: project})
|
env = Vagrant::Environment.new({client: project})
|
||||||
machine = env.machine(target.name.to_sym, target.provider_name.to_sym)
|
machine = env.machine(target.name.to_sym, target.provider_name.to_sym)
|
||||||
|
|
||||||
sf = get_synced_folder_plugin(plugin_name)
|
sf = get_synced_folder_plugin(plugin_name)
|
||||||
logger.debug("got sf #{sf}")
|
logger.debug("got sf #{sf}")
|
||||||
usable = sf.usable?(machine)
|
usable = sf.usable?(machine)
|
||||||
@ -153,9 +153,9 @@ module VagrantPlugins
|
|||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def get_synced_folder_plugin(plugin_name)
|
def get_synced_folder_plugin(plugin_name)
|
||||||
synced_folders = Vagrant.plugin("2").manager.synced_folders
|
synced_folders = Vagrant::Plugin::V2::Plugin.manager.synced_folders
|
||||||
logger.debug("got synced folders #{synced_folders}")
|
logger.debug("got synced folders #{synced_folders}")
|
||||||
plugin = [plugin_name.to_s.to_sym].to_a.first
|
plugin = [plugin_name.to_s.to_sym].to_a.first
|
||||||
logger.debug("got plugin #{plugin}")
|
logger.debug("got plugin #{plugin}")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user