providers/hyperv: verify cmdlet is available [GH-3398]
This commit is contained in:
parent
b5f32e59c2
commit
c02eae2279
|
@ -17,6 +17,7 @@ BUG FIXES:
|
||||||
- guests/fedora: Fix hostname setting. [GH-3382]
|
- guests/fedora: Fix hostname setting. [GH-3382]
|
||||||
- guests/fedora: Support predictable network interface names for
|
- guests/fedora: Support predictable network interface names for
|
||||||
public/private networks. [GH-3207]
|
public/private networks. [GH-3207]
|
||||||
|
- providers/hyperv: Check for PowerShell features. [GH-3398]
|
||||||
- synced\_folders/smb: Only set the chmod properly by default on Windows
|
- synced\_folders/smb: Only set the chmod properly by default on Windows
|
||||||
if it isn't already set. [GH-3394]
|
if it isn't already set. [GH-3394]
|
||||||
- synced\_folders/smb: Sharing folders with odd characters like parens
|
- synced\_folders/smb: Sharing folders with odd characters like parens
|
||||||
|
|
|
@ -107,6 +107,7 @@ module VagrantPlugins
|
||||||
|
|
||||||
def self.action_up
|
def self.action_up
|
||||||
Vagrant::Action::Builder.new.tap do |b|
|
Vagrant::Action::Builder.new.tap do |b|
|
||||||
|
b.use CheckEnabled
|
||||||
b.use HandleBox
|
b.use HandleBox
|
||||||
b.use ConfigValidate
|
b.use ConfigValidate
|
||||||
b.use Call, IsState, :not_created do |env1, b1|
|
b.use Call, IsState, :not_created do |env1, b1|
|
||||||
|
@ -163,6 +164,7 @@ module VagrantPlugins
|
||||||
|
|
||||||
# The autoload farm
|
# The autoload farm
|
||||||
action_root = Pathname.new(File.expand_path("../action", __FILE__))
|
action_root = Pathname.new(File.expand_path("../action", __FILE__))
|
||||||
|
autoload :CheckEnabled, action_root.join("check_enabled")
|
||||||
autoload :DeleteVM, action_root.join("delete_vm")
|
autoload :DeleteVM, action_root.join("delete_vm")
|
||||||
autoload :Import, action_root.join("import")
|
autoload :Import, action_root.join("import")
|
||||||
autoload :IsWindows, action_root.join("is_windows")
|
autoload :IsWindows, action_root.join("is_windows")
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
require "fileutils"
|
||||||
|
|
||||||
|
require "log4r"
|
||||||
|
|
||||||
|
module VagrantPlugins
|
||||||
|
module HyperV
|
||||||
|
module Action
|
||||||
|
class CheckEnabled
|
||||||
|
def initialize(app, env)
|
||||||
|
@app = app
|
||||||
|
end
|
||||||
|
|
||||||
|
def call(env)
|
||||||
|
env[:ui].output("Verifying Hyper-V is enabled...")
|
||||||
|
result = env[:machine].provider.driver.execute("check_hyperv.ps1", {})
|
||||||
|
raise Errors::PowerShellFeaturesDisabled if !result["result"]
|
||||||
|
|
||||||
|
@app.call(env)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -22,6 +22,10 @@ module VagrantPlugins
|
||||||
error_key(:no_switches)
|
error_key(:no_switches)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class PowerShellFeaturesDisabled < HyperVError
|
||||||
|
error_key(:powershell_features_disabled)
|
||||||
|
end
|
||||||
|
|
||||||
class PowerShellError < HyperVError
|
class PowerShellError < HyperVError
|
||||||
error_key(:powershell_error)
|
error_key(:powershell_error)
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
# Include the following modules
|
||||||
|
$Dir = Split-Path $script:MyInvocation.MyCommand.Path
|
||||||
|
. ([System.IO.Path]::Combine($Dir, "utils\write_messages.ps1"))
|
||||||
|
|
||||||
|
$check = $(-Not (-Not (Get-Command "Get-VMSwitch" -errorAction SilentlyContinue)))
|
||||||
|
$result = @{
|
||||||
|
result = $check
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Output-Message $(ConvertTo-Json $result)
|
|
@ -51,6 +51,10 @@ en:
|
||||||
|
|
||||||
For more help, please see the documentation on the Vagrant website
|
For more help, please see the documentation on the Vagrant website
|
||||||
for Hyper-V.
|
for Hyper-V.
|
||||||
|
powershell_features_disabled: |-
|
||||||
|
The Hyper-V cmdlets for PowerShell are not available! Vagrant
|
||||||
|
requires these to control Hyper-V. Please enable them in the
|
||||||
|
"Windows Features" control panel and try again.
|
||||||
powershell_error: |-
|
powershell_error: |-
|
||||||
An error occurred while executing a PowerShell script. This error
|
An error occurred while executing a PowerShell script. This error
|
||||||
is shown below. Please read the error message and see if this is
|
is shown below. Please read the error message and see if this is
|
||||||
|
|
Loading…
Reference in New Issue