Documentation ¶
Index ¶
- Constants
- Variables
- func Itob(i int) bool
- func MaxVmId(client *Client) (max int, err error)
- func ParamsToBody(params map[string]interface{}) (body []byte)
- func ParseSubConf(element string, separator string) (key string, value interface{})
- func RemoveSshForwardUsernet(vmr *VmRef, client *Client) (err error)
- func ResponseJSON(resp *http.Response) (jbody map[string]interface{})
- func SendKeysString(vmr *VmRef, client *Client, keys string) (err error)
- func SshForwardUsernet(vmr *VmRef, client *Client) (sshPort string, err error)
- func WaitForShutdown(vmr *VmRef, client *Client) (err error)
- type ApiError
- type Client
- func (c *Client) CheckVmRef(vmr *VmRef) (err error)
- func (c *Client) CloneQemuVm(vmr *VmRef, vmParams map[string]interface{}) (exitStatus string, err error)
- func (c *Client) CreateQemuVm(node string, vmParams map[string]interface{}) (exitStatus string, err error)
- func (c *Client) CreateVMDisk(nodeName string, storageName string, fullDiskName string, ...) error
- func (c *Client) DeleteVMDisks(node string, disks []string) error
- func (c *Client) DeleteVm(vmr *VmRef) (exitStatus string, err error)
- func (c *Client) GetJsonRetryable(url string, data *map[string]interface{}, tries int) error
- func (c *Client) GetNextID(currentID int) (nextID int, err error)
- func (c *Client) GetNodeList() (list map[string]interface{}, err error)
- func (c *Client) GetTaskExitstatus(taskUpid string) (exitStatus interface{}, err error)
- func (c *Client) GetVmConfig(vmr *VmRef) (vmConfig map[string]interface{}, err error)
- func (c *Client) GetVmInfo(vmr *VmRef) (vmInfo map[string]interface{}, err error)
- func (c *Client) GetVmList() (list map[string]interface{}, err error)
- func (c *Client) GetVmRefByName(vmName string) (vmr *VmRef, err error)
- func (c *Client) GetVmState(vmr *VmRef) (vmState map[string]interface{}, err error)
- func (c *Client) Login() (err error)
- func (c *Client) MonitorCmd(vmr *VmRef, command string) (monitorRes map[string]interface{}, err error)
- func (c *Client) ResetVm(vmr *VmRef) (exitStatus string, err error)
- func (c *Client) ResizeQemuDisk(vmr *VmRef, disk string, moreSizeGB int) (exitStatus interface{}, err error)
- func (c *Client) ResumeVm(vmr *VmRef) (exitStatus string, err error)
- func (c *Client) RollbackQemuVm(vmr *VmRef, snapshot string) (exitStatus string, err error)
- func (c *Client) SetVmConfig(vmr *VmRef, vmParams map[string]interface{}) (exitStatus interface{}, err error)
- func (c *Client) ShutdownVm(vmr *VmRef) (exitStatus string, err error)
- func (c *Client) StartVm(vmr *VmRef) (exitStatus string, err error)
- func (c *Client) StatusChangeVm(vmr *VmRef, setStatus string) (exitStatus string, err error)
- func (c *Client) StopVm(vmr *VmRef) (exitStatus string, err error)
- func (c *Client) SuspendVm(vmr *VmRef) (exitStatus string, err error)
- func (c *Client) WaitForCompletion(taskResponse map[string]interface{}) (waitExitStatus string, err error)
- type ConfigQemu
- func (config ConfigQemu) CloneVm(sourceVmr *VmRef, vmr *VmRef, client *Client) (err error)
- func (c ConfigQemu) CreateQemuDisksParams(vmID int, params map[string]interface{}) error
- func (c ConfigQemu) CreateQemuNetworksParams(vmID int, params map[string]interface{}) error
- func (config ConfigQemu) CreateVm(vmr *VmRef, client *Client) (err error)
- func (config ConfigQemu) HasCloudInit() bool
- func (config ConfigQemu) UpdateConfig(vmr *VmRef, client *Client) (err error)
- type Configuration
- type QemuDevice
- type QemuDeviceParam
- type QemuDevices
- 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 VmRef
Constants ¶
const ApiErrorTooManyRedirections = 599
const HiddenPassword = "**********"
const HttpTimeout = 30
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 ParamsToBody ¶
func ParseSubConf ¶
ParseSubConf - Parse standard sub-conf strings `key=value`.
func RemoveSshForwardUsernet ¶
device_del net1 netdev_del net1
func ResponseJSON ¶
func SshForwardUsernet ¶
This is because proxmox create/config API won't let us make usernet devices
func WaitForShutdown ¶
Useful waiting for ISO install to complete
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client - URL, user and password to specifc Proxmox node
func NewClient ¶
func NewClient(configuration *Configuration, autoLogin bool) (client *Client, err error)
func (*Client) CheckVmRef ¶
func (*Client) CloneQemuVm ¶
func (*Client) CreateQemuVm ¶
func (*Client) CreateVMDisk ¶
func (c *Client) CreateVMDisk( nodeName string, storageName string, fullDiskName string, diskParams map[string]interface{}, ) error
CreateVMDisk - Create single disk for VM on host node.
func (*Client) DeleteVMDisks ¶
DeleteVMDisks - Delete VM disks from host node. By default the VM disks are deteled when the VM is deleted, so mainly this is used to delete the disks in case VM creation didn't complete.
func (*Client) GetJsonRetryable ¶
func (*Client) GetNodeList ¶
func (*Client) GetTaskExitstatus ¶
func (*Client) GetVmConfig ¶
func (*Client) GetVmRefByName ¶
func (*Client) GetVmState ¶
func (*Client) MonitorCmd ¶
func (*Client) ResizeQemuDisk ¶
func (*Client) RollbackQemuVm ¶
func (*Client) SetVmConfig ¶
func (c *Client) SetVmConfig(vmr *VmRef, vmParams map[string]interface{}) (exitStatus interface{}, err error)
SetVmConfig - send config options
func (*Client) StatusChangeVm ¶
type ConfigQemu ¶
type ConfigQemu struct { Name string `json:"name"` Description string `json:"desc"` Onboot bool `json:"onboot"` Memory int `json:"memory"` QemuOs string `json:"os"` QemuCores int `json:"cores"` QemuSockets int `json:"sockets"` QemuIso string `json:"iso"` FullClone *int `json:"fullclone"` QemuDisks QemuDevices `json:"disk"` QemuNetworks QemuDevices `json:"network"` // Deprecated single disk. DiskSize float64 `json:"diskGB"` Storage string `json:"storage"` StorageType string `json:"storageType"` // virtio|scsi (cloud-init defaults to scsi) // Deprecated single nic. QemuNicModel string `json:"nic"` QemuBrige string `json:"bridge"` QemuVlanTag int `json:"vlan"` QemuMacAddr string `json:"mac"` // 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"` }
ConfigQemu - Proxmox API QEMU options
func NewConfigQemuFromApi ¶
func NewConfigQemuFromApi(vmr *VmRef, client *Client) (config *ConfigQemu, err error)
func NewConfigQemuFromJson ¶
func NewConfigQemuFromJson(io io.Reader) (config *ConfigQemu, err error)
func (ConfigQemu) CloneVm ¶
func (config ConfigQemu) CloneVm(sourceVmr *VmRef, vmr *VmRef, client *Client) (err error)
CloneVm Example: Request
nodes/proxmox1-xx/qemu/1012/clone
newid:145 name:tf-clone1 target:proxmox1-xx full:1 storage:xxx
func (ConfigQemu) CreateQemuDisksParams ¶
func (c ConfigQemu) CreateQemuDisksParams( vmID int, params map[string]interface{}, ) error
Create parameters for each disk.
func (ConfigQemu) CreateQemuNetworksParams ¶
func (c ConfigQemu) CreateQemuNetworksParams(vmID int, params map[string]interface{}) error
Create parameters for each Nic device.
func (ConfigQemu) CreateVm ¶
func (config ConfigQemu) CreateVm(vmr *VmRef, client *Client) (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(vmr *VmRef, client *Client) (err error)
type Configuration ¶
type QemuDevice ¶
type QemuDevice map[string]interface{}
type QemuDeviceParam ¶
type QemuDeviceParam []string
type QemuDevices ¶
type Session ¶
type Session struct { ApiUrl string AuthTicket string CsrfToken string Headers http.Header // contains filtered or unexported fields }
func NewSession ¶
func NewSession(configuration *Configuration, httpClient *http.Client) (session *Session, err error)
func (*Session) NewRequest ¶
type VmRef ¶
type VmRef struct {
// contains filtered or unexported fields
}
VmRef - virtual machine ref parts map[type:qemu node:proxmox1-xx id:qemu/132 diskread:5.57424738e+08 disk:0 netin:5.9297450593e+10 mem:3.3235968e+09 uptime:1.4567097e+07 vmid:132 template:0 maxcpu:2 netout:6.053310416e+09 maxdisk:3.4359738368e+10 maxmem:8.592031744e+09 diskwrite:1.49663619584e+12 status:running cpu:0.00386980694947209 name:appt-app1-dev.xxx.xx]