Skip to content

Commit

Permalink
vzdump api call
Browse files Browse the repository at this point in the history
  • Loading branch information
Pivnoy committed Mar 13, 2024
1 parent 6a14f51 commit a53a116
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
26 changes: 26 additions & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1242,3 +1242,29 @@ type FirewallIPSet struct {
Digest string `json:"digest,omitempty"`
Comment string `json:"comment,omitempty"`
}

type (
ModeType = string
CompressType = string
)

const (
ModeSnapshot = ModeType("snapshot")
ModeSuspend = ModeType("suspend")
ModeStop = ModeType("stop")

CompressZero = CompressType("0")
CompressOne = CompressType("1")
CompressGzip = CompressType("gzip")
CompressLzo = CompressType("lzo")
CompressZstd = CompressType("zstd")
)

type VirtualMachineBackupOptions struct {
VMID uint64 `json:"vmid"`
Storage string `json:"storage,omitempty"`
Remove int `json:"remove,omitempty"`
Mode ModeType `json:"mode,omitempty"`
Compress CompressType `json:"compess,omitempty"`
Notes string `json:"notes,omitempty"`
}
13 changes: 13 additions & 0 deletions virtual_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,3 +643,16 @@ func (v *VirtualMachine) ConvertToTemplate(ctx context.Context) (task *Task, err
}
return NewTask(upid, v.client), nil
}

func (v *VirtualMachine) Vzdump(ctx context.Context, params *VirtualMachineBackupOptions) (task *Task, err error) {
var upid UPID

if params == nil {
params = &VirtualMachineBackupOptions{}
}

if err = v.client.Post(ctx, fmt.Sprintf("/nodes/%s/vzdump", v.Node), params, &upid); err != nil {
return nil, err
}
return NewTask(upid, v.client), nil
}

0 comments on commit a53a116

Please sign in to comment.