Differentiate checkpoints and automatic checkpoints
Provide separate configuration settings for enabling/disabling checkpoints and automatic checkpoints with Hyper-V provider.
This commit is contained in:
parent
a9bc0bb800
commit
8aa74a03a0
|
@ -70,6 +70,7 @@ module VagrantPlugins
|
||||||
"AutoStartAction" => env[:machine].provider_config.auto_start_action,
|
"AutoStartAction" => env[:machine].provider_config.auto_start_action,
|
||||||
"AutoStopAction" => env[:machine].provider_config.auto_stop_action,
|
"AutoStopAction" => env[:machine].provider_config.auto_stop_action,
|
||||||
"EnableCheckpoints" => env[:machine].provider_config.enable_checkpoints,
|
"EnableCheckpoints" => env[:machine].provider_config.enable_checkpoints,
|
||||||
|
"EnableAutomaticCheckpoints" => env[:machine].provider_config.enable_automatic_checkpoints,
|
||||||
"VirtualizationExtensions" => !!env[:machine].provider_config.enable_virtualization_extensions,
|
"VirtualizationExtensions" => !!env[:machine].provider_config.enable_virtualization_extensions,
|
||||||
}
|
}
|
||||||
options.delete_if{|_,v| v.nil? }
|
options.delete_if{|_,v| v.nil? }
|
||||||
|
|
|
@ -40,8 +40,10 @@ module VagrantPlugins
|
||||||
attr_accessor :auto_start_action
|
attr_accessor :auto_start_action
|
||||||
# @return [String] Automatic action on stop of host. Default: ShutDown (ShutDown, TurnOff, Save)
|
# @return [String] Automatic action on stop of host. Default: ShutDown (ShutDown, TurnOff, Save)
|
||||||
attr_accessor :auto_stop_action
|
attr_accessor :auto_stop_action
|
||||||
# @return [Boolean] Enable automatic checkpoints. Default: false
|
# @return [Boolean] Enable checkpoints. Default: true
|
||||||
attr_accessor :enable_checkpoints
|
attr_accessor :enable_checkpoints
|
||||||
|
# @return [Boolean] Enable automatic checkpoints. Default: false
|
||||||
|
attr_accessor :enable_automatic_checkpoints
|
||||||
# @return [Boolean] Enable virtualization extensions
|
# @return [Boolean] Enable virtualization extensions
|
||||||
attr_accessor :enable_virtualization_extensions
|
attr_accessor :enable_virtualization_extensions
|
||||||
# @return [Hash] Options for VMServiceIntegration
|
# @return [Hash] Options for VMServiceIntegration
|
||||||
|
@ -60,6 +62,7 @@ module VagrantPlugins
|
||||||
@auto_start_action = UNSET_VALUE
|
@auto_start_action = UNSET_VALUE
|
||||||
@auto_stop_action = UNSET_VALUE
|
@auto_stop_action = UNSET_VALUE
|
||||||
@enable_virtualization_extensions = UNSET_VALUE
|
@enable_virtualization_extensions = UNSET_VALUE
|
||||||
|
@enable_automatic_checkpoints = UNSET_VALUE
|
||||||
@enable_checkpoints = UNSET_VALUE
|
@enable_checkpoints = UNSET_VALUE
|
||||||
@vm_integration_services = {}
|
@vm_integration_services = {}
|
||||||
end
|
end
|
||||||
|
@ -85,11 +88,20 @@ module VagrantPlugins
|
||||||
@auto_start_action = "Nothing" if @auto_start_action == UNSET_VALUE
|
@auto_start_action = "Nothing" if @auto_start_action == UNSET_VALUE
|
||||||
@auto_stop_action = "ShutDown" if @auto_stop_action == UNSET_VALUE
|
@auto_stop_action = "ShutDown" if @auto_stop_action == UNSET_VALUE
|
||||||
@enable_virtualization_extensions = false if @enable_virtualization_extensions == UNSET_VALUE
|
@enable_virtualization_extensions = false if @enable_virtualization_extensions == UNSET_VALUE
|
||||||
|
|
||||||
|
if @enable_automatic_checkpoints == UNSET_VALUE
|
||||||
|
@enable_automatic_checkpoints = false
|
||||||
|
else
|
||||||
|
@enable_automatic_checkpoints = !!@enable_automatic_checkpoints
|
||||||
|
end
|
||||||
if @enable_checkpoints == UNSET_VALUE
|
if @enable_checkpoints == UNSET_VALUE
|
||||||
@enable_checkpoints = false
|
@enable_checkpoints = true
|
||||||
else
|
else
|
||||||
@enable_checkpoints = !!@enable_checkpoints
|
@enable_checkpoints = !!@enable_checkpoints
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# If automatic checkpoints are enabled, checkpoints will automatically be enabled
|
||||||
|
@enable_checkpoints ||= @enable_automatic_checkpoints
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate(machine)
|
def validate(machine)
|
||||||
|
|
|
@ -18,7 +18,9 @@ param(
|
||||||
[parameter (Mandatory=$false)]
|
[parameter (Mandatory=$false)]
|
||||||
[switch] $VirtualizationExtensions,
|
[switch] $VirtualizationExtensions,
|
||||||
[parameter (Mandatory=$false)]
|
[parameter (Mandatory=$false)]
|
||||||
[switch] $EnableCheckpoints
|
[switch] $EnableCheckpoints,
|
||||||
|
[parameter (Mandatory=$false)]
|
||||||
|
[switch] $EnableAutomaticCheckpoints
|
||||||
)
|
)
|
||||||
|
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
@ -76,6 +78,7 @@ if($SwitchID) {
|
||||||
Set-VagrantVMSwitch -VM $VM -SwitchName $SwitchName
|
Set-VagrantVMSwitch -VM $VM -SwitchName $SwitchName
|
||||||
} catch {
|
} catch {
|
||||||
Write-ErrorMessage "Failed to configure network adapter: ${PSItem}"
|
Write-ErrorMessage "Failed to configure network adapter: ${PSItem}"
|
||||||
|
exit 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,3 +96,18 @@ try {
|
||||||
Write-ErrorMessage "Failed to ${CheckpointAction} checkpoints on VM: ${PSItem}"
|
Write-ErrorMessage "Failed to ${CheckpointAction} checkpoints on VM: ${PSItem}"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($EnableAutomaticCheckpoints) {
|
||||||
|
$autochecks = 1
|
||||||
|
$AutoAction = "enabled"
|
||||||
|
} else {
|
||||||
|
$autochecks = 0
|
||||||
|
$AutoAction = "disable"
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Hyper-V\Set-VM -VM $VM -AutomaticCheckpointsEnabled $autochecks
|
||||||
|
} catch {
|
||||||
|
Write-ErrorMessage "Failed to ${AutoAction} automatic checkpoints on VM: ${PSItem}"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ describe VagrantPlugins::HyperV::Action::Configure do
|
||||||
auto_start_action: "Nothing",
|
auto_start_action: "Nothing",
|
||||||
auto_stop_action: "Save",
|
auto_stop_action: "Save",
|
||||||
enable_checkpoints: false,
|
enable_checkpoints: false,
|
||||||
|
enable_automatic_checkpoints: true,
|
||||||
enable_virtualization_extensions: false,
|
enable_virtualization_extensions: false,
|
||||||
vm_integration_services: vm_integration_services
|
vm_integration_services: vm_integration_services
|
||||||
)
|
)
|
||||||
|
|
|
@ -163,11 +163,31 @@ describe VagrantPlugins::HyperV::Config do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#enable_checkpoints" do
|
describe "#enable_checkpoints" do
|
||||||
it "is false by default" do
|
it "is true by default" do
|
||||||
|
subject.finalize!
|
||||||
|
expect(subject.enable_checkpoints).to eq(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "can be set" do
|
||||||
|
subject.enable_checkpoints = false
|
||||||
subject.finalize!
|
subject.finalize!
|
||||||
expect(subject.enable_checkpoints).to eq(false)
|
expect(subject.enable_checkpoints).to eq(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "is enabled automatically when enable_automatic_checkpoints is enabled" do
|
||||||
|
subject.enable_checkpoints = false
|
||||||
|
subject.enable_automatic_checkpoints = true
|
||||||
|
subject.finalize!
|
||||||
|
expect(subject.enable_checkpoints).to eq(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#enable_automatic_checkpoints" do
|
||||||
|
it "is false by default" do
|
||||||
|
subject.finalize!
|
||||||
|
expect(subject.enable_automatic_checkpoints).to eq(false)
|
||||||
|
end
|
||||||
|
|
||||||
it "can be set" do
|
it "can be set" do
|
||||||
subject.enable_checkpoints = true
|
subject.enable_checkpoints = true
|
||||||
subject.finalize!
|
subject.finalize!
|
||||||
|
|
Loading…
Reference in New Issue