Documentation
¶
Index ¶
- Constants
- Variables
- func IsNotAuthorized(err error) bool
- func IsTimeout(err error) bool
- type Appliance
- type Appliances
- type Backup
- type Backups
- type CPUInfo
- type Client
- func (c *Client) APIToken(tokenID, secret string)
- func (c *Client) Cluster() (*Cluster, error)
- func (c *Client) Delete(p string, v interface{}) error
- func (c *Client) Get(p string, v interface{}) error
- func (c *Client) Login(username, password string) error
- func (c *Client) Node(name string) (*Node, error)
- func (c *Client) Nodes() (ns NodeStatuses, err error)
- func (c *Client) Post(p string, d interface{}, v interface{}) error
- func (c *Client) Put(p string, d interface{}, v interface{}) error
- func (c *Client) Req(method, path string, data []byte, v interface{}) error
- func (c *Client) Ticket(credentials *Credentials) (*Session, error)
- func (c *Client) Upload(path string, fields map[string]string, file *os.File, v interface{}) error
- func (c *Client) VNCWebSocket(path string, vnc *VNC) (chan string, chan string, chan error, func() error, error)
- func (c *Client) Version() (*Version, error)
- type Cluster
- type ClusterResource
- type ClusterResources
- type Container
- func (c *Container) Reboot() (status *ContainerStatus, err error)
- func (c *Container) Resume() (status *ContainerStatus, err error)
- func (c *Container) Start() (status string, err error)
- func (c *Container) Stop() (status *ContainerStatus, err error)
- func (c *Container) Suspend() (status *ContainerStatus, err error)
- func (c *Container) TermProxy() (vnc *VNC, err error)
- func (c *Container) VNCWebSocket(vnc *VNC) (chan string, chan string, chan error, func() error, error)
- type ContainerStatus
- type ContainerStatuses
- type Containers
- type Content
- type Credentials
- type HA
- type HRes
- type HostnameConfig
- type IPAddress
- type ISO
- type ISOs
- type IsTemplate
- type Ksm
- type LeveledLogger
- type LeveledLoggerInterface
- type Log
- type Memory
- type NetworkConfig
- type Node
- func (n *Node) Appliances() (appliances Appliances, err error)
- func (n *Node) Container(vmid int) (*Container, error)
- func (n *Node) Containers() (c Containers, err error)
- func (n *Node) DownloadAppliance(template, storage string) (ret string, err error)
- func (n *Node) GetVmHostname(vmid int) (*HostnameConfig, error)
- func (n *Node) GetVmInterface(vmid int) (*NetworkConfig, error)
- func (n *Node) GetVmOSName(vmid int) (*OSConfig, error)
- func (n *Node) Network(iface string) (network *NodeNetwork, err error)
- func (n *Node) NetworkReload() (*Task, error)
- func (n *Node) Networks() (networks NodeNetworks, err error)
- func (n *Node) NewNetwork(network *NodeNetwork) (task *Task, err error)
- func (n *Node) NewVirtualMachine(vmid int, options ...VirtualMachineOption) (*Task, error)
- func (n *Node) Storage(name string) (storage *Storage, err error)
- func (n *Node) Storages() (storages Storages, err error)
- func (n *Node) TermProxy() (vnc *VNC, err error)
- func (n *Node) VNCWebSocket(vnc *VNC) (chan string, chan string, chan error, func() error, error)
- func (n *Node) Version() (version *Version, err error)
- func (n *Node) VirtualMachine(vmid int) (*VirtualMachine, error)
- func (n *Node) VirtualMachines() (vms VirtualMachines, err error)
- func (n *Node) VzTmpl(template, storage string) (*VzTmpl, error)
- func (n *Node) VzTmpls(storage string) (templates VzTmpls, err error)
- type NodeNetwork
- type NodeNetworks
- type NodeStatus
- type NodeStatuses
- type OSConfig
- type OSResult
- type Option
- type Res
- type RootFS
- type Session
- type Statistic
- type Storage
- func (s *Storage) Backup(name string) (backup *Backup, err error)
- func (s *Storage) DownloadURL(content, filename, url string) (*Task, error)
- func (s *Storage) ISO(name string) (iso *ISO, err error)
- func (s *Storage) Upload(content, file string) (*Task, error)
- func (s *Storage) VzTmpl(name string) (vztmpl *VzTmpl, err error)
- type Storages
- type StringOrInt
- type StringOrUint64
- type Task
- func (t *Task) Log(start, limit int) (l Log, err error)
- func (t *Task) Ping() error
- func (t *Task) Stop() error
- func (t *Task) UnmarshalJSON(b []byte) error
- func (t *Task) Wait(interval, max time.Duration) error
- func (t *Task) WaitFor(seconds int) error
- func (t *Task) WaitForCompleteStatus(timesNum int, steps ...int) (status bool, completed bool, err error)
- func (t *Task) Watch(start int) (chan string, error)
- type Tasks
- type Time
- type UPID
- type VNC
- type Version
- type VirtualMachine
- func (v *VirtualMachine) Clone(name, target string) (newid int, task *Task, err error)
- func (v *VirtualMachine) Config(options ...VirtualMachineOption) (*Task, error)
- func (v *VirtualMachine) Delete() (task *Task, err error)
- func (v *VirtualMachine) Hibernate() (task *Task, err error)
- func (v *VirtualMachine) IsHibernated() bool
- func (v *VirtualMachine) IsPaused() bool
- func (v *VirtualMachine) IsRunning() bool
- func (v *VirtualMachine) IsStopped() bool
- func (v *VirtualMachine) MoveDisk(disk, storage string) (task *Task, err error)
- func (v *VirtualMachine) Pause() (task *Task, err error)
- func (v *VirtualMachine) Ping() error
- func (v *VirtualMachine) Reboot() (task *Task, err error)
- func (v *VirtualMachine) Reset() (task *Task, err error)
- func (v *VirtualMachine) Resume() (task *Task, err error)
- func (v *VirtualMachine) Shutdown() (task *Task, err error)
- func (v *VirtualMachine) Start() (*Task, error)
- func (v *VirtualMachine) Stop() (task *Task, err error)
- func (v *VirtualMachine) TermProxy() (vnc *VNC, err error)
- func (v *VirtualMachine) VNCWebSocket(vnc *VNC) (chan string, chan string, chan error, func() error, error)
- type VirtualMachineConfig
- func (vmc *VirtualMachineConfig) MergeIDEs() map[string]string
- func (vmc *VirtualMachineConfig) MergeNets() map[string]string
- func (vmc *VirtualMachineConfig) MergeSATAs() map[string]string
- func (vmc *VirtualMachineConfig) MergeSCSIs() map[string]string
- func (vmc *VirtualMachineConfig) MergeUnuseds() map[string]string
- type VirtualMachineOption
- type VirtualMachineOptions
- type VirtualMachines
- type Volume
- type VzTmpl
- type VzTmpls
Constants ¶
const ( LevelError = iota + 1 LevelWarn LevelInfo LevelDebug )
const ( StatusVirtualMachineRunning = "running" StatusVirtualMachineStopped = "stopped" StatusVirtualMachinePaused = "paused" )
const (
DefaultUserAgent = "go-proxmox/dev"
)
const (
TaskRunning = "running"
)
Variables ¶
var DefaultWaitInterval = 1 * time.Second
var ErrNotAuthorized = errors.New("not authorized to access endpoint")
var ErrTimeout = errors.New("the operation has timed out")
Functions ¶
func IsNotAuthorized ¶
Types ¶
type Appliance ¶
type Appliance struct {
Node string `json:",omitempty"`
Os string
Source string
Type string
SHA512Sum string
Package string
Template string
Architecture string
InfoPage string
Description string
ManageURL string
Version string
Section string
Headline string
// contains filtered or unexported fields
}
type Appliances ¶
type Appliances []*Appliance
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) Nodes ¶
func (c *Client) Nodes() (ns NodeStatuses, err error)
func (*Client) Upload ¶
Upload - There is some weird 16kb limit hardcoded in proxmox for the max POST size, hopefully in the future we make a func to scp the file to the node directly as this API endopitn is kind of janky. For now big ISOs/vztmpl should be put somewhere and a use DownloadUrl. code link for posterity, I think they meant to do 16mb and got the bit math wrong https://git.proxmox.com/?p=pve-manager.git;a=blob;f=PVE/HTTPServer.pm;h=8a0c308ea6d6601b886b0dec2bada3d4c3da65d0;hb=HEAD#l36 the task returned is the imgcopy from the tmp file to where the node actually wants the iso and you should wait for that to complete before using the iso
func (*Client) VNCWebSocket ¶
type Cluster ¶
type Cluster struct {
Version int
Quorate int
Nodes NodeStatuses
Name string
ID string
// contains filtered or unexported fields
}
func (*Cluster) Resources ¶
func (cl *Cluster) Resources(filters ...string) (rs ClusterResources, err error)
Resources retrieves a summary list of all resources in the cluster. It calls /cluster/resources api v2 endpoint with an optional "type" parameter to filter searched values. It returns a list of ClusterResources.
func (*Cluster) UnmarshalJSON ¶
type ClusterResource ¶
type ClusterResource struct {
ID string `jsont:"id"`
Type string `json:"type"`
Content string `json:",omitempty"`
CPU float64 `json:",omitempty"`
Disk uint64 `json:",omitempty"` // documented as string but this is an int
HAstate string `json:",omitempty"`
Level string `json:",omitempty"`
MaxCPU uint64 `json:",omitempty"`
MaxDisk uint64 `json:",omitempty"`
MaxMem uint64 `json:",omitempty"`
Mem uint64 `json:",omitempty"` // documented as string but this is an int
Name string `json:",omitempty"`
Node string `json:",omitempty"`
PluginType string `json:",omitempty"`
Pool string `json:",omitempty"`
Status string `json:",omitempty"`
Storage string `json:",omitempty"`
Uptime uint64 `json:",omitempty"`
}
type ClusterResources ¶
type ClusterResources []*ClusterResource
type Container ¶
type Container struct {
Name string
Node string
CPUs int
Status string
VMID StringOrUint64
Uptime uint64
MaxMem uint64
MaxDisk uint64
MaxSwap uint64
// contains filtered or unexported fields
}
func (*Container) Reboot ¶
func (c *Container) Reboot() (status *ContainerStatus, err error)
func (*Container) Resume ¶
func (c *Container) Resume() (status *ContainerStatus, err error)
func (*Container) Stop ¶
func (c *Container) Stop() (status *ContainerStatus, err error)
func (*Container) Suspend ¶
func (c *Container) Suspend() (status *ContainerStatus, err error)
type ContainerStatus ¶
type ContainerStatus struct {
Data string `json:",omitempty"`
}
type ContainerStatuses ¶
type ContainerStatuses []*ContainerStatus
type Containers ¶
type Containers []*Container
type Content ¶
type Content struct {
URL string
Node string
Storage string `json:",omitempty"`
Content string `json:",omitempty"`
VolID string `json:",omitempty"`
CTime uint64 `json:",omitempty"`
Format string
Size StringOrUint64
Used StringOrUint64 `json:",omitempty"`
Path string `json:",omitempty"`
Notes string `json:",omitempty"`
// contains filtered or unexported fields
}
type Credentials ¶
type HostnameConfig ¶
type HostnameConfig struct {
Result HRes `json:"result"`
}
type IsTemplate ¶
type IsTemplate bool
func (*IsTemplate) UnmarshalJSON ¶
func (it *IsTemplate) UnmarshalJSON(b []byte) error
type LeveledLogger ¶
type LeveledLogger struct {
// Level is the minimum logging level that will be emitted by this logger.
//
// For example, a Level set to LevelWarn will emit warnings and errors, but
// not informational or debug messages.
//
// Always set this with a constant like LevelWarn because the individual
// values are not guaranteed to be stable.
Level int
// contains filtered or unexported fields
}
func (*LeveledLogger) Debugf ¶
func (l *LeveledLogger) Debugf(format string, v ...interface{})
Debugf logs a debug message using Printf conventions.
func (*LeveledLogger) Errorf ¶
func (l *LeveledLogger) Errorf(format string, v ...interface{})
Errorf logs a warning message using Printf conventions.
func (*LeveledLogger) Infof ¶
func (l *LeveledLogger) Infof(format string, v ...interface{})
Infof logs an informational message using Printf conventions.
func (*LeveledLogger) Warnf ¶
func (l *LeveledLogger) Warnf(format string, v ...interface{})
Warnf logs a warning message using Printf conventions.
type LeveledLoggerInterface ¶
type Log ¶
func (*Log) UnmarshalJSON ¶
line numbers in the response start a 1 but the start param indexes from 0 so converting to that
type NetworkConfig ¶
type NetworkConfig struct {
Result []Res `json:"result"`
}
type Node ¶
type Node struct {
Name string
Kversion string
LoadAvg []string
CPU float64
RootFS RootFS
PVEVersion string
CPUInfo CPUInfo
Swap Memory
Idle int
Memory Memory
Ksm Ksm
Uptime uint64
Wait float64
// contains filtered or unexported fields
}
func (*Node) Appliances ¶
func (n *Node) Appliances() (appliances Appliances, err error)
func (*Node) Containers ¶
func (n *Node) Containers() (c Containers, err error)
func (*Node) DownloadAppliance ¶
func (*Node) GetVmHostname ¶
func (n *Node) GetVmHostname(vmid int) (*HostnameConfig, error)
func (*Node) GetVmInterface ¶
func (n *Node) GetVmInterface(vmid int) (*NetworkConfig, error)
func (*Node) NetworkReload ¶
func (*Node) NewNetwork ¶
func (n *Node) NewNetwork(network *NodeNetwork) (task *Task, err error)
func (*Node) NewVirtualMachine ¶
func (n *Node) NewVirtualMachine(vmid int, options ...VirtualMachineOption) (*Task, error)
func (*Node) VNCWebSocket ¶
VNCWebSocket send, recv, errors, closer, error
func (*Node) VirtualMachine ¶
func (n *Node) VirtualMachine(vmid int) (*VirtualMachine, error)
func (*Node) VirtualMachines ¶
func (n *Node) VirtualMachines() (vms VirtualMachines, err error)
type NodeNetwork ¶
type NodeNetwork struct {
Node string `json:"-"`
NodeApi *Node `json:"-"`
Iface string `json:"iface,omitempty"`
BondMode string `json:"bond_mode,omitempty"`
Autostart int `json:"autostart,omitempty"`
CIDR string `json:"cidr,omitempty"`
CIDR6 string `json:"cidr6,omitempty"`
Gateway string `json:"gateway,omitempty"`
Gateway6 string `json:"gateway6,omitempty"`
Netmask string `json:"netmask,omitempty"`
Netmask6 string `json:"netmask6,omitempty"`
BridgeVlanAware bool `json:"bridge_vlan_aware,omitempty"`
BridgePorts string `json:"bridge_ports,omitempty"`
Comments string `json:"comments,omitempty"`
Comments6 string `json:"comments6,omitempty"`
BridgeStp string `json:"bridge_stp,omitempty"`
BridgeFd string `json:"bridge_fd,omitempty"`
BondPrimary string `json:"bond-primary,omitempty"`
Address string `json:"address,omitempty"`
Address6 string `json:"address6,omitempty"`
Type string `json:"type,omitempty"`
Active int `json:"active,omitempty"`
Method string `json:"method,omitempty"`
Method6 string `json:"method6,omitempty"`
Priority int `json:"priority,omitempty"`
// contains filtered or unexported fields
}
func (*NodeNetwork) Delete ¶
func (nw *NodeNetwork) Delete() (task *Task, err error)
type NodeNetworks ¶
type NodeNetworks []*NodeNetwork
type NodeStatus ¶
type NodeStatus struct {
// shared
Status string `json:",omitempty"`
Level string `json:",omitempty"`
ID string `json:",omitempty"` // format "node/<name>"
// from /nodes endpoint
Node string `json:",omitempty"`
MaxCPU int `json:",omitempty"`
MaxMem uint64 `json:",omitempty"`
Disk uint64 `json:",omitempty"`
SSLFingerprint string `json:"ssl_fingerprint,omitempty"`
MaxDisk uint64 `json:",omitempty"`
Mem uint64 `json:",omitempty"`
CPU float64 `json:",omitempty"`
// from /cluster endpoint
NodeID int `json:",omitempty"` // the internal id of the node
Name string `json:",omitempty"`
IP string `json:",omitempty"`
Online int `json:",omitempty"`
Local int `json:",omitempty"`
}
type NodeStatuses ¶
type NodeStatuses []*NodeStatus
type OSResult ¶
type OSResult struct {
PrettyName string `json:"pretty-name"`
VersionID string `json:"version-id"`
Machine string `json:"machine"`
KernelRelease string `json:"kernel-release"`
KernelVersion string `json:"kernel-version"`
Name string `json:"name"`
ID string `json:"id"`
Version string `json:"version"`
}
type Option ¶
type Option func(*Client)
func WithAPIToken ¶
func WithClient ¶
func WithLogger ¶
func WithLogger(logger LeveledLoggerInterface) Option
func WithLogins ¶
func WithUserAgent ¶
type Storage ¶
type Storage struct {
Node string
Name string `json:"storage"`
Enabled int
UsedFraction float64 `json:"used_fraction"`
Active int
Content string
Avail uint64
Type string
Used uint64
Total uint64
Storage string
// contains filtered or unexported fields
}
func (*Storage) DownloadURL ¶
type StringOrInt ¶
type StringOrInt int
func (*StringOrInt) UnmarshalJSON ¶
func (d *StringOrInt) UnmarshalJSON(b []byte) error
type StringOrUint64 ¶
type StringOrUint64 uint64
func (*StringOrUint64) UnmarshalJSON ¶
func (d *StringOrUint64) UnmarshalJSON(b []byte) error
type Task ¶
type Task struct {
UPID UPID
ID string
Type string
User string
Status string
Node string
PID uint64 `json:",omitempty"`
PStart uint64 `json:",omitempty"`
Saved string `json:",omitempty"`
ExitStatus string `json:",omitempty"`
IsCompleted bool
IsRunning bool
IsFailed bool
IsSuccessful bool
StartTime time.Time `json:"-"`
EndTime time.Time `json:"-"`
Duration time.Duration `json:"-"`
// contains filtered or unexported fields
}
func (*Task) UnmarshalJSON ¶
func (*Task) WaitForCompleteStatus ¶
type VirtualMachine ¶
type VirtualMachine struct {
VirtualMachineConfig *VirtualMachineConfig
NetworkConfig *NetworkConfig
HostnameConfig *HostnameConfig
Name string
Node string
NetIn uint64
CPUs int
DiskWrite uint64
Status string
Lock string `json:",omitempty"`
VMID StringOrUint64
PID StringOrUint64
Netout uint64
Disk uint64
Uptime uint64
Mem uint64
CPU float64
MaxMem uint64
MaxDisk uint64
DiskRead uint64
QMPStatus string `json:"qmpstatus,omitempty"`
Template IsTemplate // empty str if a vm, int 1 if a template
HA HA `json:",omitempty"`
// contains filtered or unexported fields
}
func (*VirtualMachine) Clone ¶
func (v *VirtualMachine) Clone(name, target string) (newid int, task *Task, err error)
func (*VirtualMachine) Config ¶
func (v *VirtualMachine) Config(options ...VirtualMachineOption) (*Task, error)
func (*VirtualMachine) Delete ¶
func (v *VirtualMachine) Delete() (task *Task, err error)
func (*VirtualMachine) Hibernate ¶
func (v *VirtualMachine) Hibernate() (task *Task, err error)
func (*VirtualMachine) IsHibernated ¶
func (v *VirtualMachine) IsHibernated() bool
func (*VirtualMachine) IsPaused ¶
func (v *VirtualMachine) IsPaused() bool
func (*VirtualMachine) IsRunning ¶
func (v *VirtualMachine) IsRunning() bool
func (*VirtualMachine) IsStopped ¶
func (v *VirtualMachine) IsStopped() bool
func (*VirtualMachine) MoveDisk ¶
func (v *VirtualMachine) MoveDisk(disk, storage string) (task *Task, err error)
func (*VirtualMachine) Pause ¶
func (v *VirtualMachine) Pause() (task *Task, err error)
func (*VirtualMachine) Ping ¶
func (v *VirtualMachine) Ping() error
func (*VirtualMachine) Reboot ¶
func (v *VirtualMachine) Reboot() (task *Task, err error)
func (*VirtualMachine) Reset ¶
func (v *VirtualMachine) Reset() (task *Task, err error)
func (*VirtualMachine) Resume ¶
func (v *VirtualMachine) Resume() (task *Task, err error)
func (*VirtualMachine) Shutdown ¶
func (v *VirtualMachine) Shutdown() (task *Task, err error)
func (*VirtualMachine) Start ¶
func (v *VirtualMachine) Start() (*Task, error)
func (*VirtualMachine) Stop ¶
func (v *VirtualMachine) Stop() (task *Task, err error)
func (*VirtualMachine) TermProxy ¶
func (v *VirtualMachine) TermProxy() (vnc *VNC, err error)
func (*VirtualMachine) VNCWebSocket ¶
func (v *VirtualMachine) VNCWebSocket(vnc *VNC) (chan string, chan string, chan error, func() error, error)
VNCWebSocket copy/paste when calling to get the channel names right send, recv, errors, closer, errors := vm.VNCWebSocket(vnc) for this to work you need to first setup a serial terminal on your vm https://pve.proxmox.com/wiki/Serial_Terminal
type VirtualMachineConfig ¶
type VirtualMachineConfig struct {
Cores int
Numa int
Memory int
Sockets int
IDE2 string
OSType string
SMBios1 string
SCSIHW string
Net0 string
Digest string
Meta string
SCSI0 string
Boot string
VMGenID string
Name string
IDEs map[string]string
IDE0 string
IDE1 string
IDE3 string
IDE4 string
IDE5 string
IDE6 string
IDE7 string
IDE8 string
IDE9 string
SCSIs map[string]string
SCSI1 string
SCSI2 string
SCSI3 string
SCSI4 string
SCSI5 string
SCSI6 string
SCSI7 string
SCSI8 string
SCSI9 string
SATAs map[string]string
SATA0 string
SATA1 string
SATA2 string
SATA3 string
SATA4 string
SATA5 string
SATA6 string
SATA7 string
SATA8 string
SATA9 string
Nets map[string]string
Net1 string
Net2 string
Net3 string
Net4 string
Net5 string
Net6 string
Net7 string
Net8 string
Net9 string
Unuseds map[string]string
Unused0 string
Unused1 string
Unused2 string
Unused3 string
Unused4 string
Unused5 string
Unused6 string
Unused7 string
Unused8 string
Unused9 string
}
func (*VirtualMachineConfig) MergeIDEs ¶
func (vmc *VirtualMachineConfig) MergeIDEs() map[string]string
func (*VirtualMachineConfig) MergeNets ¶
func (vmc *VirtualMachineConfig) MergeNets() map[string]string
func (*VirtualMachineConfig) MergeSATAs ¶
func (vmc *VirtualMachineConfig) MergeSATAs() map[string]string
func (*VirtualMachineConfig) MergeSCSIs ¶
func (vmc *VirtualMachineConfig) MergeSCSIs() map[string]string
func (*VirtualMachineConfig) MergeUnuseds ¶
func (vmc *VirtualMachineConfig) MergeUnuseds() map[string]string
type VirtualMachineOption ¶
type VirtualMachineOption struct {
Name string
Value interface{}
}
type VirtualMachineOptions ¶
type VirtualMachineOptions []*VirtualMachineOption
type VirtualMachines ¶
type VirtualMachines []*VirtualMachine