Remove disk file after detaching from hyper-v guest
This commit is contained in:
parent
318eb4e65a
commit
5405aaac82
@ -43,10 +43,7 @@ module VagrantPlugins
|
||||
|
||||
disk_actual = all_disks.select { |a| a["Path"] == d["path"] }.first
|
||||
|
||||
machine.provider.driver.remove_disk(disk_actual["ControllerType"], disk_actual["ControllerNumber"], disk_actual["ControllerLocation"])
|
||||
|
||||
# TODO: delete disk
|
||||
# maybe we can just "dismount" instead of removing the disk all together
|
||||
machine.provider.driver.remove_disk(disk_actual["ControllerType"], disk_actual["ControllerNumber"], disk_actual["ControllerLocation"], disk_actual["Path"])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -56,9 +56,10 @@ module VagrantPlugins
|
||||
# @param [String] controller_number
|
||||
# @param [String] controller_location
|
||||
# @param [Hash] opts
|
||||
def remove_disk(controller_type, controller_number, controller_location, **opts)
|
||||
def remove_disk(controller_type, controller_number, controller_location, disk_file_path, **opts)
|
||||
execute(:remove_disk_drive, VmId: @vm_id, ControllerType: controller_type,
|
||||
ControllerNumber: controller_number, ControllerLocation: controller_location)
|
||||
ControllerNumber: controller_number, ControllerLocation: controller_location,
|
||||
DiskFilePath: disk_file_path)
|
||||
end
|
||||
|
||||
# @param [String] path
|
||||
|
||||
@ -8,13 +8,17 @@ param(
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$ControllerNumber,
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$ControllerLocation
|
||||
[string]$ControllerLocation,
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$DiskFilePath
|
||||
)
|
||||
|
||||
try {
|
||||
$VM = Hyper-V\Get-VM -Id $VmId
|
||||
|
||||
Hyper-v\Remove-VMHardDiskDrive -VMName $VM.Name -ControllerType $ControllerType -ControllerNumber $ControllerNumber -ControllerLocation $ControllerLocation
|
||||
|
||||
Remove-Item -Path $DiskFilePath
|
||||
} catch {
|
||||
Write-ErrorMessage "Failed to remove disk ${DiskFilePath} to VM ${VM}: ${PSItem}"
|
||||
exit 1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user