Skip to content

Commit 5fe932f

Browse files
authored
Merge pull request #373 from mizhka/master
clone: choose template located on target node if possible
2 parents 1d4aac5 + d596893 commit 5fe932f

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/Telmate/terraform-provider-proxmox
33
go 1.16
44

55
require (
6-
github.com/Telmate/proxmox-api-go v0.0.0-20210708200918-d27e0fa5a4a4
6+
github.com/Telmate/proxmox-api-go v0.0.0-20210713150936-9bfd169c655f
77
github.com/hashicorp/terraform-plugin-sdk/v2 v2.6.1
88
github.com/rs/zerolog v1.21.0
99
)

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ github.com/Telmate/proxmox-api-go v0.0.0-20210507143528-c60bbda13c0c h1:s8BXeCeP
4444
github.com/Telmate/proxmox-api-go v0.0.0-20210507143528-c60bbda13c0c/go.mod h1:keBhXWLa+UBajvf79xvKcfiqeIc7vZL9wOqxuy1CBGw=
4545
github.com/Telmate/proxmox-api-go v0.0.0-20210708200918-d27e0fa5a4a4 h1:nPcdJDO4MVAAUPsJtVV7rgjQGFvjxUEBkP53XrUve88=
4646
github.com/Telmate/proxmox-api-go v0.0.0-20210708200918-d27e0fa5a4a4/go.mod h1:keBhXWLa+UBajvf79xvKcfiqeIc7vZL9wOqxuy1CBGw=
47+
github.com/Telmate/proxmox-api-go v0.0.0-20210713150936-9bfd169c655f h1:Lb9VXSg+7bJSVAf5pzUqc5X6GTN502NQsP+64tF+T4w=
48+
github.com/Telmate/proxmox-api-go v0.0.0-20210713150936-9bfd169c655f/go.mod h1:keBhXWLa+UBajvf79xvKcfiqeIc7vZL9wOqxuy1CBGw=
4749
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
4850
github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE=
4951
github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=

proxmox/resource_vm_qemu.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,11 +813,19 @@ func resourceVmQemuCreate(d *schema.ResourceData, meta interface{}) error {
813813
}
814814
config.FullClone = &fullClone
815815

816-
sourceVmr, err := client.GetVmRefByName(d.Get("clone").(string))
816+
sourceVmrs, err := client.GetVmRefsByName(d.Get("clone").(string))
817817
if err != nil {
818818
return err
819819
}
820820

821+
// prefer source Vm located on same node
822+
sourceVmr := sourceVmrs[0]
823+
for _, candVmr := range sourceVmrs {
824+
if candVmr.Node() == vmr.Node() {
825+
sourceVmr = candVmr
826+
}
827+
}
828+
821829
log.Print("[DEBUG] cloning VM")
822830
err = config.CloneVm(sourceVmr, vmr, client)
823831

0 commit comments

Comments
 (0)