Fixup handling parameters for hyper-v powershell disk scripts
This commit is contained in:
parent
bb4541a2a5
commit
1d8db27340
@ -37,7 +37,7 @@ module VagrantPlugins
|
||||
# @param [String] controller_location
|
||||
# @param [Hash] opts
|
||||
def attach_disk(disk_file_path, **opts)
|
||||
execute(:attach_disk_drive, VmId: @vm_id, DiskFilePath: disk_file_path, ControllerType: opts[:ControllerType],
|
||||
execute(:attach_disk_drive, VmId: @vm_id, Path: disk_file_path, ControllerType: opts[:ControllerType],
|
||||
ControllerNumber: opts[:ControllerNumber], ControllerLocation: opts[:ControllerLocation])
|
||||
end
|
||||
|
||||
@ -48,7 +48,9 @@ module VagrantPlugins
|
||||
# ensure size_bytes is a uint64
|
||||
execute(:new_vhd, Path: path, SizeBytes: size_bytes, Fixed: opts[:Fixed],
|
||||
BlockSizeBytes: opts[:BlockSizeBytes], LogicalSectorSizeBytes: opts[:LogicalSectorSizeBytes],
|
||||
PhysicalSectorSizeBytes: opts[:PhsyicalSectorSizeBytes])
|
||||
PhysicalSectorSizeBytes: opts[:PhysicalSectorSizeBytes],
|
||||
SourceDisk: opts[:SourceDisk], Differencing: opts[:Differencing],
|
||||
ParentPath: opts[:ParentPath])
|
||||
end
|
||||
|
||||
# @param [String] controller_type
|
||||
|
||||
@ -3,18 +3,25 @@
|
||||
param(
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$VmId,
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$Path,
|
||||
[string]$ControllerType,
|
||||
[string]$ControllerNumber,
|
||||
[string]$ControllerLocation,
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$DiskFilePath
|
||||
[string]$ControllerLocation
|
||||
)
|
||||
|
||||
$Params = @{}
|
||||
|
||||
foreach ($key in $MyInvocation.BoundParameters.keys) {
|
||||
$value = (Get-Variable -Exclude "ErrorAction" $key).Value
|
||||
if (($key -ne "VmId") -and ($key -ne "ErrorAction")) {
|
||||
$Params.Add($key, $value)
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$VM = Hyper-V\Get-VM -Id $VmId
|
||||
#Hyper-V\Add-VMHardDiskDrive -VMName $vm -ControllerType $ControllerType -ControllerNumber $ControllerNumber -ControllerLocation $ControllerLocation -Path $DiskFilePath
|
||||
# Add logic to support missing params. Below is the simple case for attaching a disk
|
||||
Hyper-V\Add-VMHardDiskDrive -VMName $VM.Name -Path $DiskFilePath
|
||||
Hyper-V\Add-VMHardDiskDrive -VMName $VM.Name @Params
|
||||
} catch {
|
||||
Write-ErrorMessage "Failed to attach disk ${DiskFilePath} to VM ${VM}: ${PSItem}"
|
||||
exit 1
|
||||
|
||||
@ -6,9 +6,12 @@ param(
|
||||
[Parameter(Mandatory=$true)]
|
||||
[UInt64]$SizeBytes,
|
||||
[switch]$Fixed,
|
||||
[switch]$Differencing,
|
||||
[string]$ParentPath,
|
||||
[string]$BlockSizeBytes,
|
||||
[string]$LogicalSectorSizeBytes,
|
||||
[string]$PhysicalSectorSizeBytes
|
||||
[string]$PhysicalSectorSizeBytes,
|
||||
[UInt64]$SourceDisk
|
||||
)
|
||||
|
||||
$Params = @{}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user