Documentation ¶
Index ¶
- Constants
- Variables
- func GetMaxVmId() (max int, err error)
- func GetNextVmId(currentId int) (nextId int, err error)
- func GetNodeList() (list map[string]interface{}, err error)
- func GetStorageAndVolumeName(fullDiskName string, separator string) (storageName string, volumeName string)
- func GetStorageList() (list map[string]interface{}, err error)
- func GetVmList() (vmlist []interface{}, err error)
- func Itob(i int) bool
- func ParamsToBody(params map[string]interface{}) (body []byte)
- func ParseSubConf(element string, separator string) (key string, value interface{})
- func ResponseJSON(resp *http.Response) (jbody map[string]interface{}, err error)
- func TypedResponse(resp *http.Response, v interface{}) error
- type AgentNetworkInterface
- type Client
- func (c *Client) GetJsonRetryable(url string, data *map[string]interface{}, tries int) error
- func (c *Client) GetTaskExitstatus(taskUpid string) (exitStatus interface{}, err error)
- func (c *Client) Login(username string, password string) (err error)
- func (c *Client) Set()
- func (c *Client) WaitForCompletion(taskResponse map[string]interface{}) (waitExitStatus string, err error)
- type ConfigLxc
- type ConfigQemu
- func (c ConfigQemu) CreateDisksParams(vmID int, params map[string]interface{}, cloned bool)
- func (c ConfigQemu) CreateNetParams(vmID int, params map[string]interface{})
- func (config ConfigQemu) CreateVm(vm *Vm) (err error)
- func (config ConfigQemu) HasCloudInit() bool
- func (config ConfigQemu) UpdateConfig(vm *Vm) (err error)
- type Node
- func (node *Node) Check() (err error)
- func (node *Node) CreateVolume(fullDiskName string, diskParams map[string]interface{}) (err error)
- func (node *Node) DeleteVolume(fullDiskName string) (err error)
- func (node *Node) GetInfo() (nodeInfo map[string]interface{}, err error)
- func (node *Node) Name() string
- type Response
- type Session
- func (s *Session) Delete(url string, params *url.Values, headers *http.Header) (resp *http.Response, err error)
- func (s *Session) Do(req *http.Request) (*http.Response, error)
- func (s *Session) Get(url string, params *url.Values, headers *http.Header) (resp *http.Response, err error)
- func (s *Session) GetJSON(url string, params *url.Values, headers *http.Header, ...) (resp *http.Response, err error)
- func (s *Session) Head(url string, params *url.Values, headers *http.Header) (resp *http.Response, err error)
- func (s *Session) Login(username string, password string) (err error)
- func (s *Session) NewRequest(method, url string, headers *http.Header, body io.Reader) (req *http.Request, err error)
- func (s *Session) Post(url string, params *url.Values, headers *http.Header, body *[]byte) (resp *http.Response, err error)
- func (s *Session) PostJSON(url string, params *url.Values, headers *http.Header, body interface{}, ...) (resp *http.Response, err error)
- func (s *Session) Put(url string, params *url.Values, headers *http.Header, body *[]byte) (resp *http.Response, err error)
- func (s *Session) Request(method string, url string, params *url.Values, headers *http.Header, ...) (resp *http.Response, err error)
- func (s *Session) RequestJSON(method string, url string, params *url.Values, headers *http.Header, ...) (resp *http.Response, err error)
- type Storage
- type Vm
- func (vm *Vm) Check() (err error)
- func (vm *Vm) Clone(newid int, cloneParams map[string]interface{}) (exitStatus interface{}, err error)
- func (vm *Vm) Create(vmParams map[string]interface{}) (exitStatus string, err error)
- func (vm *Vm) CreateBackup(bkpParams map[string]interface{}) (exitStatus string, err error)
- func (vm *Vm) CreateSnapshot(snapParams map[string]interface{}) (exitStatus string, err error)
- func (vm *Vm) CreateTemplate() (exitStatus interface{}, err error)
- func (vm *Vm) Delete() (exitStatus string, err error)
- func (vm *Vm) DeleteSnapshot(snapName string) (exitStatus interface{}, err error)
- func (vm *Vm) GetAgentNetworkInterfaces() (ifs []AgentNetworkInterface, err error)
- func (vm *Vm) GetConfig() (config map[string]interface{}, err error)
- func (vm *Vm) GetInfo() (vmInfo map[string]interface{}, err error)
- func (vm *Vm) GetSnapshotList() (list map[string]interface{}, err error)
- func (vm *Vm) GetSpiceProxy() (vmSpiceProxy map[string]interface{}, err error)
- func (vm *Vm) GetStatus() (vmState map[string]interface{}, err error)
- func (vm *Vm) Id() int
- func (vm *Vm) Migrate(migrateParams map[string]interface{}) (exitStatus interface{}, err error)
- func (vm *Vm) MonitorCmd(command string) (monitorRes map[string]interface{}, err error)
- func (vm *Vm) MoveDisk(moveParams map[string]interface{}) (exitStatus interface{}, err error)
- func (vm *Vm) Node() *Node
- func (vm *Vm) RemoveSshForwardUsernet() (err error)
- func (vm *Vm) Reset() (exitStatus string, err error)
- func (vm *Vm) ResizeDisk(disk string, sizeGB string) (exitStatus interface{}, err error)
- func (vm *Vm) Resume() (exitStatus string, err error)
- func (vm *Vm) Rollback(snapName string) (exitStatus string, err error)
- func (vm *Vm) SendKeysString(keys string) (err error)
- func (vm *Vm) SetConfig(vmParams map[string]interface{}) (exitStatus interface{}, err error)
- func (vm *Vm) SetNode(n *Node)
- func (vm *Vm) SetStatus(status string) (exitStatus string, err error)
- func (vm *Vm) SetType(t string)
- func (vm *Vm) Shutdown() (exitStatus string, err error)
- func (vm *Vm) SshForwardUsernet() (sshPort string, err error)
- func (vm *Vm) Start() (exitStatus string, err error)
- func (vm *Vm) Stop() (exitStatus string, err error)
- func (vm *Vm) Suspend() (exitStatus string, err error)
- func (vm *Vm) Type() string
- func (vm *Vm) WaitForShutdown() (err error)
- type VmDevice
- type VmDeviceParam
- type VmDevices
Constants ¶
const TaskStatusCheckInterval = 2
TaskStatusCheckInterval - time between async checks in seconds
const TaskTimeout = 300
TaskTimeout - default async task call timeout in seconds
Variables ¶
var Debug = new(bool)
Functions ¶
func GetMaxVmId ¶
func GetNextVmId ¶
func GetNodeList ¶
func GetStorageAndVolumeName ¶
func GetStorageAndVolumeName( fullDiskName string, separator string, ) (storageName string, volumeName string)
Extract disk storage and disk volume, since disk name is saved in Proxmox with its storage.
func GetStorageList ¶
func ParamsToBody ¶
func ParseSubConf ¶
ParseSubConf - Parse standard sub-conf strings `key=value`.
func ResponseJSON ¶
func TypedResponse ¶
Types ¶
type AgentNetworkInterface ¶
type AgentNetworkInterface struct { MACAddress string IPAddresses []net.IP Name string Statistics map[string]int64 }
func (*AgentNetworkInterface) UnmarshalJSON ¶
func (a *AgentNetworkInterface) UnmarshalJSON(b []byte) (err error)
type Client ¶
type Client struct { ApiUrl string Username string Password string // contains filtered or unexported fields }
Client - URL, user and password to specifc Proxmox node
func (*Client) GetJsonRetryable ¶
func (*Client) GetTaskExitstatus ¶
type ConfigLxc ¶
type ConfigLxc struct { Arch string `json:"arch"` Cmode string `json:"cmode"` Console bool `json:"console"` Cores int `json:"cores"` Cpuunits int `json:"cpuunits"` Description string `json:"description"` Digest string `json:"digest"` Hostname string `json:"hostname"` Memory int `json:"memory"` Mp VmDevices `json:"mp"` Nameserver string `json:"nameserver"` Net VmDevices `json:"net"` Onboot bool `json:"onboot"` Ostype string `json:"ostype"` Ostemplate string `json:"ostemplate"` Password string `json:"password"` Protection bool `json:"protection"` Rootfs VmDevice `json:"rootfs"` Searchdomain string `json:"searchdomain"` Startup string `json:"startup"` Sshkeys string `json:"ssh-public-keys"` Swap int `json:"swap"` Tty int `json:"tty"` Unprivileged bool `json:"unprivileged"` }
ConfigLxc - Proxmox API LXC options
func NewConfigLxc ¶
func NewConfigLxc() *ConfigLxc
this factory returns a new struct with the members set to defaults
func NewConfigLxcFromApi ¶
func NewConfigLxcFromJson ¶
func (ConfigLxc) CreateDisksParams ¶
Create parameters for each mountpoint
func (ConfigLxc) CreateNetParams ¶
Create parameters for each Nic device.
func (ConfigLxc) UpdateConfig ¶
type ConfigQemu ¶
type ConfigQemu struct { Name string `json:"name"` Description string `json:"desc"` Onboot bool `json:"onboot"` Agent string `json:"agent"` Memory int `json:"memory"` Ostype string `json:"ostype"` Cores int `json:"cores"` Sockets int `json:"sockets"` Iso string `json:"iso"` Disk VmDevices `json:"disk"` Net VmDevices `json:"net"` // cloud-init options CIuser string `json:"ciuser"` CIpassword string `json:"cipassword"` Searchdomain string `json:"searchdomain"` Nameserver string `json:"nameserver"` Sshkeys string `json:"sshkeys"` // arrays are hard, support 2 interfaces for now Ipconfig0 string `json:"ipconfig0"` Ipconfig1 string `json:"ipconfig1"` Delete string `json:"delete"` }
ConfigQemu - Proxmox API QEMU options
func NewConfigQemuFromApi ¶
func NewConfigQemuFromApi(vm *Vm) (config *ConfigQemu, err error)
func NewConfigQemuFromJson ¶
func NewConfigQemuFromJson(io io.Reader) (config *ConfigQemu, err error)
func (ConfigQemu) CreateDisksParams ¶
func (c ConfigQemu) CreateDisksParams( vmID int, params map[string]interface{}, cloned bool, )
Create parameters for each disk.
func (ConfigQemu) CreateNetParams ¶
func (c ConfigQemu) CreateNetParams(vmID int, params map[string]interface{})
Create parameters for each Nic device.
func (ConfigQemu) CreateVm ¶
func (config ConfigQemu) CreateVm(vm *Vm) (err error)
CreateVm - Tell Proxmox API to make the VM
func (ConfigQemu) HasCloudInit ¶
func (config ConfigQemu) HasCloudInit() bool
HasCloudInit - are there cloud-init options?
func (ConfigQemu) UpdateConfig ¶
func (config ConfigQemu) UpdateConfig(vm *Vm) (err error)
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
func (*Node) CreateVolume ¶
TODO: add autodetection of existant volumes and act accordingly
func (*Node) DeleteVolume ¶
type Session ¶
type Session struct { ApiUrl string AuthTicket string CsrfToken string Headers http.Header // contains filtered or unexported fields }
func NewSession ¶
func (*Session) NewRequest ¶
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
func FindStorage ¶
factory by name getInfo for storage already looks up by name, so use that
type Vm ¶
type Vm struct {
// contains filtered or unexported fields
}
func (*Vm) CreateBackup ¶
func (*Vm) CreateSnapshot ¶
func (*Vm) CreateTemplate ¶
func (*Vm) DeleteSnapshot ¶
func (*Vm) GetAgentNetworkInterfaces ¶
func (vm *Vm) GetAgentNetworkInterfaces() (ifs []AgentNetworkInterface, err error)
func (*Vm) GetSnapshotList ¶
func (*Vm) GetSpiceProxy ¶
func (*Vm) MonitorCmd ¶
func (*Vm) RemoveSshForwardUsernet ¶
device_del net1 netdev_del net1
func (*Vm) ResizeDisk ¶
sizeGB can be a number to set an absolute size, or a number preceded by + to grow the volume by that many GB. If using an absolute size this has to be larger than the current size (shrinking is not supported by PVE)
func (*Vm) SendKeysString ¶
func (*Vm) SshForwardUsernet ¶
This is because proxmox create/config API won't let us make usernet devices
func (*Vm) WaitForShutdown ¶
Useful waiting for ISO install to complete
type VmDeviceParam ¶
type VmDeviceParam []string