Update path usages to support Hyper-V provider access from WSL
This commit is contained in:
parent
5357727350
commit
55aaa1d258
|
@ -392,6 +392,7 @@ module Vagrant
|
|||
# @param [String, Pathname] path Path to convert
|
||||
# @return [String]
|
||||
def wsl_to_windows_path(path)
|
||||
path = path.to_s
|
||||
if wsl? && wsl_windows_access? && !path.match(/^[a-zA-Z]:/)
|
||||
if wsl_path?(path)
|
||||
parts = path.split("/")
|
||||
|
|
|
@ -23,7 +23,8 @@ module VagrantPlugins
|
|||
|
||||
def export
|
||||
@env[:ui].info I18n.t("vagrant.actions.vm.export.exporting")
|
||||
@env[:machine].provider.driver.export(@env["export.temp_dir"]) do |progress|
|
||||
export_tmp_dir = Vagrant::Util::Platform.wsl_to_windows_path(@env["export.temp_dir"])
|
||||
@env[:machine].provider.driver.export(export_tmp_dir) do |progress|
|
||||
@env[:ui].clear_line
|
||||
@env[:ui].report_progress(progress.percent, 100, false)
|
||||
end
|
||||
|
|
|
@ -61,11 +61,11 @@ module VagrantPlugins
|
|||
dest_path = env[:machine].data_dir.join("Virtual Hard Disks").join(image_path.basename).to_s
|
||||
|
||||
options = {
|
||||
"VMConfigFile" => config_path.to_s.gsub("/", "\\"),
|
||||
"DestinationPath" => dest_path.to_s.gsub("/", "\\"),
|
||||
"DataPath" => env[:machine].data_dir.to_s.gsub("/", "\\"),
|
||||
"VMConfigFile" => Vagrant::Util::Platform.wsl_to_windows_path(config_path).gsub("/", "\\"),
|
||||
"DestinationPath" => Vagrant::Util::Platform.wsl_to_windows_path(dest_path).gsub("/", "\\"),
|
||||
"DataPath" => Vagrant::Util::Platform.wsl_to_windows_path(env[:machine].data_dir).gsub("/", "\\"),
|
||||
"LinkedClone" => !!env[:machine].provider_config.linked_clone,
|
||||
"SourcePath" => image_path.to_s.gsub("/", "\\"),
|
||||
"SourcePath" => Vagrant::Util::Platform.wsl_to_windows_path(image_path).gsub("/", "\\"),
|
||||
"VMName" => env[:machine].provider_config.vmname,
|
||||
}
|
||||
|
||||
|
|
|
@ -221,8 +221,8 @@ module VagrantPlugins
|
|||
|
||||
def execute_powershell(path, options, &block)
|
||||
lib_path = Pathname.new(File.expand_path("../scripts", __FILE__))
|
||||
mod_path = lib_path.join("utils").to_s.gsub("/", "\\")
|
||||
path = lib_path.join(path).to_s.gsub("/", "\\")
|
||||
mod_path = Vagrant::Util::Platform.wsl_to_windows_path(lib_path.join("utils")).gsub("/", "\\")
|
||||
path = Vagrant::Util::Platform.wsl_to_windows_path(lib_path.join(path)).gsub("/", "\\")
|
||||
options = options || {}
|
||||
ps_options = []
|
||||
options.each do |key, value|
|
||||
|
@ -239,8 +239,9 @@ module VagrantPlugins
|
|||
# Include our module path so we can nicely load helper modules
|
||||
opts = {
|
||||
notify: [:stdout, :stderr, :stdin],
|
||||
env: {"PSModulePath" => "$env:PSModulePath+';#{mod_path}'"}
|
||||
module_path: Vagrant::Util::Platform.wsl_to_windows_path(mod_path)
|
||||
}
|
||||
|
||||
Vagrant::Util::PowerShell.execute(path, *ps_options, **opts, &block)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue