Skip to content

Commit 328eed9

Browse files
committed
add Clone()
1 parent 1d590a6 commit 328eed9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

proxmox/qemu.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,17 @@ func ConvertSMBiosToUUID(smbios string) (string, error) {
139139
return strings.Split(match, "=")[1], nil
140140
}
141141

142+
func (c *VirtualMachine) Clone(ctx context.Context, newid int, option api.VirtualMachineCloneOption) (*VirtualMachine, error) {
143+
taskid, err := c.restclient.CreateVirtualMachineClone(ctx, c.Node, c.VM.VMID, newid, option)
144+
if err != nil {
145+
return nil, err
146+
}
147+
if err := c.service.EnsureTaskDone(ctx, c.Node, *taskid); err != nil {
148+
return nil, err
149+
}
150+
return c.service.VirtualMachine(ctx, newid)
151+
}
152+
142153
func (c *VirtualMachine) Delete(ctx context.Context) error {
143154
path := fmt.Sprintf("/nodes/%s/qemu/%d", c.Node, c.VM.VMID)
144155
var upid string

0 commit comments

Comments
 (0)