mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-22 16:20:22 -07:00
win_disk_image: return all mount paths in return value (#44799)
This commit is contained in:
parent
78eb4724a0
commit
533656694e
4 changed files with 21 additions and 8 deletions
|
@ -49,19 +49,21 @@ If($state -eq "present") {
|
|||
|
||||
If($di.Attached) { # only try to get the mount_path if the disk is attached (
|
||||
If($di.StorageType -eq 1) { # ISO, we can get the mountpoint directly from Get-Volume
|
||||
$drive_letter = ($di | Get-Volume).DriveLetter
|
||||
$drive_letters = ($di | Get-Volume).DriveLetter
|
||||
}
|
||||
ElseIf($di.StorageType -in @(2,3)) { # VHD/VHDX, need Get-Disk + Get-Partition to discover mountpoint
|
||||
# FUTURE: support multi-partition VHDs
|
||||
$drive_letter = ($di | Get-Disk | Get-Partition)[0].DriveLetter
|
||||
$drive_letters = ($di | Get-Disk | Get-Partition).DriveLetter
|
||||
}
|
||||
# remove any null entries (no drive letter)
|
||||
$drive_letters = $drive_letters | Where-Object { $_ }
|
||||
|
||||
|
||||
If(-not $drive_letter) {
|
||||
If(-not $drive_letters) {
|
||||
Fail-Json -message "Unable to retrieve drive letter from mounted image"
|
||||
}
|
||||
|
||||
$result.mount_path = $drive_letter + ":\"
|
||||
# mount_path is deprecated and will be removed in 2.11, use mount_paths which contains all the partitions instead
|
||||
$result.mount_path = $drive_letters[0] + ":\"
|
||||
$result.mount_paths = @($drive_letters | ForEach-Object { "$($_):\" })
|
||||
}
|
||||
}
|
||||
ElseIf($state -eq "absent") {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue