Skip to content

Commit

Permalink
fix(vm): resize image once imported (#753)
Browse files Browse the repository at this point in the history
fix(vm): Resize image once imported #737

Signed-off-by: dandalorinan <[email protected]>
  • Loading branch information
dandaolrian authored Nov 29, 2023
1 parent a4ac84a commit d16b8e1
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions proxmoxtf/resource/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -2809,12 +2809,10 @@ func vmCreateCustomDisks(ctx context.Context, d *schema.ResourceData, m interfac
fmt.Sprintf(`file_path_tmp="%s"`, filePathTmp),
fmt.Sprintf(`vm_id="%d"`, vmID),
`source_image=$(pvesm path "$file_id")`,
`cp "$source_image" "$file_path_tmp"`,
`qemu-img resize -f "$file_format" "$file_path_tmp" "${disk_size}G"`,
`imported_disk="$(qm importdisk "$vm_id" "$file_path_tmp" "$datastore_id_target" -format $file_format | grep "unused0" | cut -d ":" -f 3 | cut -d "'" -f 1)"`,
`imported_disk="$(qm importdisk "$vm_id" "$source_image" "$datastore_id_target" -format $file_format | grep "unused0" | cut -d ":" -f 3 | cut -d "'" -f 1)"`,
`disk_id="${datastore_id_target}:$imported_disk${disk_options}"`,
`qm set "$vm_id" "-${disk_interface}" "$disk_id"`,
`rm -f "$file_path_tmp"`,
`qm resize "$vm_id" "${disk_interface}" "${disk_size}G"`,
)

importedDiskCount++
Expand Down

0 comments on commit d16b8e1

Please sign in to comment.