Skip to content

Commit

Permalink
add Clone()
Browse files Browse the repository at this point in the history
  • Loading branch information
sp-yduck committed Dec 12, 2023
1 parent 1d590a6 commit 328eed9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions proxmox/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,17 @@ func ConvertSMBiosToUUID(smbios string) (string, error) {
return strings.Split(match, "=")[1], nil
}

func (c *VirtualMachine) Clone(ctx context.Context, newid int, option api.VirtualMachineCloneOption) (*VirtualMachine, error) {
taskid, err := c.restclient.CreateVirtualMachineClone(ctx, c.Node, c.VM.VMID, newid, option)
if err != nil {
return nil, err
}
if err := c.service.EnsureTaskDone(ctx, c.Node, *taskid); err != nil {
return nil, err
}
return c.service.VirtualMachine(ctx, newid)
}

func (c *VirtualMachine) Delete(ctx context.Context) error {
path := fmt.Sprintf("/nodes/%s/qemu/%d", c.Node, c.VM.VMID)
var upid string
Expand Down

0 comments on commit 328eed9

Please sign in to comment.