Skip to content

Commit

Permalink
Merge pull request #373 from mizhka/master
Browse files Browse the repository at this point in the history
clone: choose template located on target node if possible
  • Loading branch information
ggongaware authored Jul 14, 2021
2 parents 1d4aac5 + d596893 commit 5fe932f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/Telmate/terraform-provider-proxmox
go 1.16

require (
github.com/Telmate/proxmox-api-go v0.0.0-20210708200918-d27e0fa5a4a4
github.com/Telmate/proxmox-api-go v0.0.0-20210713150936-9bfd169c655f
github.com/hashicorp/terraform-plugin-sdk/v2 v2.6.1
github.com/rs/zerolog v1.21.0
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ github.com/Telmate/proxmox-api-go v0.0.0-20210507143528-c60bbda13c0c h1:s8BXeCeP
github.com/Telmate/proxmox-api-go v0.0.0-20210507143528-c60bbda13c0c/go.mod h1:keBhXWLa+UBajvf79xvKcfiqeIc7vZL9wOqxuy1CBGw=
github.com/Telmate/proxmox-api-go v0.0.0-20210708200918-d27e0fa5a4a4 h1:nPcdJDO4MVAAUPsJtVV7rgjQGFvjxUEBkP53XrUve88=
github.com/Telmate/proxmox-api-go v0.0.0-20210708200918-d27e0fa5a4a4/go.mod h1:keBhXWLa+UBajvf79xvKcfiqeIc7vZL9wOqxuy1CBGw=
github.com/Telmate/proxmox-api-go v0.0.0-20210713150936-9bfd169c655f h1:Lb9VXSg+7bJSVAf5pzUqc5X6GTN502NQsP+64tF+T4w=
github.com/Telmate/proxmox-api-go v0.0.0-20210713150936-9bfd169c655f/go.mod h1:keBhXWLa+UBajvf79xvKcfiqeIc7vZL9wOqxuy1CBGw=
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE=
github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
Expand Down
10 changes: 9 additions & 1 deletion proxmox/resource_vm_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -813,11 +813,19 @@ func resourceVmQemuCreate(d *schema.ResourceData, meta interface{}) error {
}
config.FullClone = &fullClone

sourceVmr, err := client.GetVmRefByName(d.Get("clone").(string))
sourceVmrs, err := client.GetVmRefsByName(d.Get("clone").(string))
if err != nil {
return err
}

// prefer source Vm located on same node
sourceVmr := sourceVmrs[0]
for _, candVmr := range sourceVmrs {
if candVmr.Node() == vmr.Node() {
sourceVmr = candVmr
}
}

log.Print("[DEBUG] cloning VM")
err = config.CloneVm(sourceVmr, vmr, client)

Expand Down

0 comments on commit 5fe932f

Please sign in to comment.