Documentation
¶
Index ¶
- func CheckResponse(r *http.Response) error
- type Client
- type ErrorResponse
- type Node
- type NodesService
- type NodesServiceOp
- type QemuService
- type QemuServiceOp
- func (s *QemuServiceOp) CreateVM(node string, vmID string, options *VMCreateOptions) error
- func (s *QemuServiceOp) DeleteVM(node string, vmID string) error
- func (s *QemuServiceOp) GetVMCurrentStatus(node string, vmID string) (*VMStatus, error)
- func (s *QemuServiceOp) GetVMs(node string) ([]VM, error)
- func (s *QemuServiceOp) ResetVM(node string, vmID string) error
- func (s *QemuServiceOp) ResumeVM(node string, vmID string) error
- func (s *QemuServiceOp) ShutdownVM(node string, vmID string) error
- func (s *QemuServiceOp) StartVM(node string, vmID string) error
- func (s *QemuServiceOp) StopVM(node string, vmID string) error
- func (s *QemuServiceOp) SuspendVM(node string, vmID string) error
- type RequestCompletionCallback
- type VM
- type VMCreateOptions
- type VMStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckResponse ¶
CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. API error responses are expected to have either no response body, or a JSON response body that maps to ErrorResponse. Any other response body will be silently ignored.
Types ¶
type Client ¶
type Client struct { // Base URL for API requests. BaseURL *url.URL // Control panel username Username string // Control panel password Password string // Services used for communicating with the API Nodes NodesService VMs QemuService // contains filtered or unexported fields }
Client manages communication with proxmox API.
func (*Client) Do ¶
Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response will be written to v, without attempting to decode it.
func (*Client) NewRequest ¶
NewRequest creates an API request. A relative URL can be provided in urlStr, which will be resolved to the BaseURL of the Client. Relative URLS should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included in as the request body.
func (*Client) OnRequestCompleted ¶
func (c *Client) OnRequestCompleted(rc RequestCompletionCallback)
OnRequestCompleted sets the API request completion callback
type ErrorResponse ¶
type ErrorResponse struct { Success bool // HTTP response that caused this error Response *http.Response // Error message Message string `json:"ResultMessage"` // ResultCode returned from the API ResultCode int `json:"ResultCode"` }
An ErrorResponse reports the error caused by an API request
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
type Node ¶
type Node struct { Id string `json:"id"` Node string `json:"node"` Type string `json:"type"` Cpu float64 `json:"cpu"` Mem uint64 `json:"mem"` Disk uint64 `json:"disk"` Maxcpu int `json:"maxcpu"` Maxmem uint64 `json:"maxmem"` Maxdisk uint64 `json:"maxdisk"` Uptime uint `json:"uptime"` Level string `json:"level"` }
type NodesService ¶
type NodesServiceOp ¶
type NodesServiceOp struct {
// contains filtered or unexported fields
}
func (*NodesServiceOp) GetNodes ¶
func (s *NodesServiceOp) GetNodes() ([]Node, error)
type QemuService ¶
type QemuService interface { GetVMs(node string) ([]VM, error) GetVMCurrentStatus(node string, vmID string) (*VMStatus, error) StartVM(node string, vmID string) error StopVM(node string, vmID string) error ShutdownVM(node string, vmID string) error ResetVM(node string, vmID string) error SuspendVM(node string, vmID string) error ResumeVM(node string, vmID string) error CreateVM(node string, vmID string, options *VMCreateOptions) error DeleteVM(node string, vmID string) error }
type QemuServiceOp ¶
type QemuServiceOp struct {
// contains filtered or unexported fields
}
func (*QemuServiceOp) CreateVM ¶
func (s *QemuServiceOp) CreateVM(node string, vmID string, options *VMCreateOptions) error
Create virtual machine.
func (*QemuServiceOp) DeleteVM ¶
func (s *QemuServiceOp) DeleteVM(node string, vmID string) error
Create virtual machine.
func (*QemuServiceOp) GetVMCurrentStatus ¶
func (s *QemuServiceOp) GetVMCurrentStatus(node string, vmID string) (*VMStatus, error)
Get virtual machine status.
func (*QemuServiceOp) GetVMs ¶
func (s *QemuServiceOp) GetVMs(node string) ([]VM, error)
Virtual machine index (per node).
func (*QemuServiceOp) ResetVM ¶
func (s *QemuServiceOp) ResetVM(node string, vmID string) error
Reset virtual machine.
func (*QemuServiceOp) ResumeVM ¶
func (s *QemuServiceOp) ResumeVM(node string, vmID string) error
Resume virtual machine.
func (*QemuServiceOp) ShutdownVM ¶
func (s *QemuServiceOp) ShutdownVM(node string, vmID string) error
Shutdown virtual machine. This is similar to pressing the power button on a physical machine. This will send an ACPI event for the guest OS, which should then proceed to a clean shutdown.
func (*QemuServiceOp) StartVM ¶
func (s *QemuServiceOp) StartVM(node string, vmID string) error
Start virtual machine.
type RequestCompletionCallback ¶
RequestCompletionCallback defines the type of the request callback function
type VM ¶
type VM struct { VMID int `json:"vmid"` Name string `json:"name"` Status string `json:"status"` Pid string `json:"pid"` Template string `json:"template"` Cpu float64 `json:"cpu"` Mem int `json:"mem"` Maxmem int `json:"maxmem"` Cpus int `json:"cpus"` Disk int `json:"disk"` Maxdisk int `json:"maxdisk"` Diskread int `json:"diskread"` Diskwrite int `json:"diskwrite"` Uptime int `json:"uptime"` Netout int `json:"netout"` Netin int `json:"netin"` }
type VMCreateOptions ¶
type VMStatus ¶
type VMStatus struct { Name string `json:"name"` Status string `json:"status"` Qmpstatus string `json:"qmpstatus"` Template string `json:"template"` Cpus int `json:"cpus"` Diskread int `json:"diskread"` Cpu int `json:"cpu"` Netin int `json:"netin"` Netout int `json:"netout"` Disk int `json:"disk"` Diskwrite int `json:"diskwrite"` Maxdisk int `json:"maxdisk"` Maxmem int `json:"maxmem"` Ha interface{} `json:"ha"` Uptime int `json:"uptime"` Pid int `json:"pid"` Mem int `json:"mem"` }