goproxmox

package module
v0.1.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2017 License: MIT Imports: 18 Imported by: 1

README

goproxmox

golang library for interaction with proxmox

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool added in v0.1.1

func Bool(v bool) *bool

Bool returns a pointer to the bool value passed in.

func BoolMap added in v0.1.1

func BoolMap(src map[string]bool) map[string]*bool

BoolMap converts a string map of bool values into a string map of bool pointers

func BoolSlice added in v0.1.1

func BoolSlice(src []bool) []*bool

BoolSlice converts a slice of bool values into a slice of bool pointers

func BoolValue added in v0.1.1

func BoolValue(v *bool) bool

BoolValue returns the value of the bool pointer passed in or false if the pointer is nil.

func BoolValueMap added in v0.1.1

func BoolValueMap(src map[string]*bool) map[string]bool

BoolValueMap converts a string map of bool pointers into a string map of bool values

func BoolValueSlice added in v0.1.1

func BoolValueSlice(src []*bool) []bool

BoolValueSlice converts a slice of bool pointers into a slice of bool values

func CheckResponse

func CheckResponse(r *http.Response) error

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.

func Float64 added in v0.1.1

func Float64(v float64) *float64

Float64 returns a pointer to the float64 value passed in.

func Float64Map added in v0.1.1

func Float64Map(src map[string]float64) map[string]*float64

Float64Map converts a string map of float64 values into a string map of float64 pointers

func Float64Slice added in v0.1.1

func Float64Slice(src []float64) []*float64

Float64Slice converts a slice of float64 values into a slice of float64 pointers

func Float64Value added in v0.1.1

func Float64Value(v *float64) float64

Float64Value returns the value of the float64 pointer passed in or 0 if the pointer is nil.

func Float64ValueMap added in v0.1.1

func Float64ValueMap(src map[string]*float64) map[string]float64

Float64ValueMap converts a string map of float64 pointers into a string map of float64 values

func Float64ValueSlice added in v0.1.1

func Float64ValueSlice(src []*float64) []float64

Float64ValueSlice converts a slice of float64 pointers into a slice of float64 values

func Int added in v0.1.1

func Int(v int) *int

Int returns a pointer to the int value passed in.

func Int64 added in v0.1.1

func Int64(v int64) *int64

Int64 returns a pointer to the int64 value passed in.

func Int64Map added in v0.1.1

func Int64Map(src map[string]int64) map[string]*int64

Int64Map converts a string map of int64 values into a string map of int64 pointers

func Int64Slice added in v0.1.1

func Int64Slice(src []int64) []*int64

Int64Slice converts a slice of int64 values into a slice of int64 pointers

func Int64Value added in v0.1.1

func Int64Value(v *int64) int64

Int64Value returns the value of the int64 pointer passed in or 0 if the pointer is nil.

func Int64ValueMap added in v0.1.1

func Int64ValueMap(src map[string]*int64) map[string]int64

Int64ValueMap converts a string map of int64 pointers into a string map of int64 values

func Int64ValueSlice added in v0.1.1

func Int64ValueSlice(src []*int64) []int64

Int64ValueSlice converts a slice of int64 pointers into a slice of int64 values

func IntMap added in v0.1.1

func IntMap(src map[string]int) map[string]*int

IntMap converts a string map of int values into a string map of int pointers

func IntSlice added in v0.1.1

func IntSlice(src []int) []*int

IntSlice converts a slice of int values into a slice of int pointers

func IntValue added in v0.1.1

func IntValue(v *int) int

IntValue returns the value of the int pointer passed in or 0 if the pointer is nil.

func IntValueMap added in v0.1.1

func IntValueMap(src map[string]*int) map[string]int

IntValueMap converts a string map of int pointers into a string map of int values

func IntValueSlice added in v0.1.1

func IntValueSlice(src []*int) []int

IntValueSlice converts a slice of int pointers into a slice of int values

func MillisecondsTimeValue added in v0.1.1

func MillisecondsTimeValue(v *int64) time.Time

MillisecondsTimeValue converts an int64 pointer to a time.Time value representing milliseconds sinch Epoch or time.Time{} if the pointer is nil.

func NewRawQMOption added in v0.1.1

func NewRawQMOption(value string) *rawQMOption

func SecondsTimeValue added in v0.1.1

func SecondsTimeValue(v *int64) time.Time

SecondsTimeValue converts an int64 pointer to a time.Time value representing seconds since Epoch or time.Time{} if the pointer is nil.

func String added in v0.1.1

func String(v string) *string

String returns a pointer to the string value passed in.

func StringMap added in v0.1.1

func StringMap(src map[string]string) map[string]*string

StringMap converts a string map of string values into a string map of string pointers

func StringSlice added in v0.1.1

func StringSlice(src []string) []*string

StringSlice converts a slice of string values into a slice of string pointers

func StringValue added in v0.1.1

func StringValue(v *string) string

StringValue returns the value of the string pointer passed in or "" if the pointer is nil.

func StringValueMap added in v0.1.1

func StringValueMap(src map[string]*string) map[string]string

StringValueMap converts a string map of string pointers into a string map of string values

func StringValueSlice added in v0.1.1

func StringValueSlice(src []*string) []string

StringValueSlice converts a slice of string pointers into a slice of string values

func Time added in v0.1.1

func Time(v time.Time) *time.Time

Time returns a pointer to the time.Time value passed in.

func TimeMap added in v0.1.1

func TimeMap(src map[string]time.Time) map[string]*time.Time

TimeMap converts a string map of time.Time values into a string map of time.Time pointers

func TimeSlice added in v0.1.1

func TimeSlice(src []time.Time) []*time.Time

TimeSlice converts a slice of time.Time values into a slice of time.Time pointers

func TimeUnixMilli added in v0.1.1

func TimeUnixMilli(t time.Time) int64

TimeUnixMilli returns a Unix timestamp in milliseconds from "January 1, 1970 UTC". The result is undefined if the Unix time cannot be represented by an int64. Which includes calling TimeUnixMilli on a zero Time is undefined.

This utility is useful for service API's such as CloudWatch Logs which require their unix time values to be in milliseconds.

See Go stdlib https://golang.org/pkg/time/#Time.UnixNano for more information.

func TimeValue added in v0.1.1

func TimeValue(v *time.Time) time.Time

TimeValue returns the value of the time.Time pointer passed in or time.Time{} if the pointer is nil.

func TimeValueMap added in v0.1.1

func TimeValueMap(src map[string]*time.Time) map[string]time.Time

TimeValueMap converts a string map of time.Time pointers into a string map of time.Time values

func TimeValueSlice added in v0.1.1

func TimeValueSlice(src []*time.Time) []time.Time

TimeValueSlice converts a slice of time.Time pointers into a slice of time.Time values

Types

type ArgError added in v0.1.1

type ArgError struct {
	// contains filtered or unexported fields
}

ArgError is an error that represents an error with an input to goproxmox. It identifies the argument and the cause (if possible).

func NewArgError added in v0.1.1

func NewArgError(arg, reason string) *ArgError

NewArgError creates an InputError.

func (*ArgError) Error added in v0.1.1

func (e *ArgError) Error() string

type Bios added in v0.1.1

type Bios int
const (
	BIOS_SeaBIOS Bios = 1 + iota
	BIOS_OVMF
)

func BiosFromString added in v0.1.1

func BiosFromString(s string) (Bios, error)

func (Bios) String added in v0.1.1

func (m Bios) String() string

String returns the name of the Bios.

type BootDevice added in v0.1.1

type BootDevice int
const (
	BOOT_Floppy BootDevice = 1 + iota
	BOOT_HardDisk
	BOOT_CDROM
	BOOT_Network
)

func BootDeviceFromString added in v0.1.1

func BootDeviceFromString(s string) (BootDevice, error)

func (BootDevice) String added in v0.1.1

func (m BootDevice) String() string

String returns the name of the BootDevice.

type CPUType added in v0.1.1

type CPUType int
const (
	CPU_486 CPUType = 1 + iota
	CPU_Broadwell
	CPU_Broadwell_noTSX
	CPU_Conroe
	CPU_Haswell
	CPU_Haswell_noTSX
	CPU_IvyBridge
	CPU_Nehalem
	CPU_Opteron_G1
	CPU_Opteron_G2
	CPU_Opteron_G3
	CPU_Opteron_G4
	CPU_Opteron_G5
	CPU_Penryn
	CPU_SandyBridge
	CPU_Skylake_Client
	CPU_Westmere
	CPU_Athlon
	CPU_Core2duo
	CPU_CoreDuo
	CPU_HOST
	CPU_KVM32
	CPU_KVM64
	CPU_Pentium
	CPU_Pentium2
	CPU_Pentium3
	CPU_Phenom
	CPU_Qemu32
	CPU_Qemu64
)

func CPUTypeFromString added in v0.1.1

func CPUTypeFromString(s string) (CPUType, error)

func (CPUType) String added in v0.1.1

func (m CPUType) String() string

String returns the name of the CPUType.

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
	Storages StorageService
	// contains filtered or unexported fields
}

Client manages communication with proxmox API.

func NewClient

func NewClient(host, username, password string) *Client

NewClient returns a new proxmox API client.

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)

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

func (c *Client) NewRequest(method, urlStr string, body map[string]string) (*http.Request, error)

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 {
	// HTTP response that caused this error
	Response *http.Response

	// Errors map
	Errors map[string]string `json:"errors"`

	// ResponseCode returned from the API
	ResponseCode int
}

An ErrorResponse reports the error caused by an API request

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type HugePages added in v0.1.1

type HugePages int
const (
	HugePages_1024 HugePages = 1 + iota
	HugePages_2
	HugePages_ANY
)

func HugePagesFromString added in v0.1.1

func HugePagesFromString(s string) (HugePages, error)

func (HugePages) String added in v0.1.1

func (m HugePages) String() string

String returns the name of the HugePages.

type IDEDevice added in v0.1.3

type IDEDevice struct {
	File  *string
	Media *MediaType
	Size  *string
}

IDE device

func NewIDEDeviceFromString added in v0.1.3

func NewIDEDeviceFromString(value string) *IDEDevice

func (*IDEDevice) GetQMOptionValue added in v0.1.3

func (c *IDEDevice) GetQMOptionValue() string

type KeyboardLayout added in v0.1.1

type KeyboardLayout int
const (
	KeyboardLayout_DA KeyboardLayout = 1 + iota
	KeyboardLayout_DE
	KeyboardLayout_DE_CH
	KeyboardLayout_EN_GB
	KeyboardLayout_EN_US
	KeyboardLayout_ES
	KeyboardLayout_FI
	KeyboardLayout_FR
	KeyboardLayout_FR_BE
	KeyboardLayout_FR_CA
	KeyboardLayout_FR_CH
	KeyboardLayout_HU
	KeyboardLayout_IS
	KeyboardLayout_IT
	KeyboardLayout_JA
	KeyboardLayout_LT
	KeyboardLayout_MK
	KeyboardLayout_NL
	KeyboardLayout_NO
	KeyboardLayout_PL
	KeyboardLayout_PT
	KeyboardLayout_PT_BR
	KeyboardLayout_SL
	KeyboardLayout_SV
	KeyboardLayout_TR
)

func KeyboardLayoutFromString added in v0.1.1

func KeyboardLayoutFromString(s string) (KeyboardLayout, error)

func (KeyboardLayout) String added in v0.1.1

func (m KeyboardLayout) String() string

String returns the name of the KeyboardLayout.

type Lock added in v0.1.1

type Lock int
const (
	Lock_Migrate Lock = 1 + iota
	Lock_Backup
	Lock_Snapshot
	Lock_Rollback
)

func LockFromString added in v0.1.1

func LockFromString(s string) (Lock, error)

func (Lock) String added in v0.1.1

func (m Lock) String() string

String returns the name of the Lock.

type MediaType added in v0.1.3

type MediaType int
const (
	MediaType_CDROM MediaType = 1 + iota
	MediaType_DISK
)

func MediaTypeFromString added in v0.1.3

func MediaTypeFromString(s string) (MediaType, error)

func (MediaType) String added in v0.1.3

func (m MediaType) String() string

String returns the name of the MediaType.

type NetworkCardModel added in v0.1.1

type NetworkCardModel int
const (
	NetworkCard_E1000 NetworkCardModel = 1 + iota
	NetworkCard_E1000_82540em
	NetworkCard_E1000_82544gc
	NetworkCard_E1000_82545em
	NetworkCard_I82551
	NetworkCard_I82557b
	NetworkCard_I82559er
	NetworkCard_NE2K_ISA
	NetworkCard_NE2K_PCI
	NetworkCard_PCNET
	NetworkCard_RTL8139
	NetworkCard_VIRTIO
	NetworkCard_VMXNET3
)

func NetworkCardModelFromString added in v0.1.1

func NetworkCardModelFromString(s string) (NetworkCardModel, error)

func (NetworkCardModel) String added in v0.1.1

func (m NetworkCardModel) String() string

String returns the name of the NetworkCardModel.

type NetworkDevice added in v0.1.1

type NetworkDevice struct {
	// Network Card Model. The virtio model provides the best performance with very low CPU overhead.
	// If your guest does not support this driver, it is usually best to use e1000.
	Model *NetworkCardModel

	// Bridge to attach the network device to. The Proxmox VE standard bridge is called vmbr0.
	Bridge *string

	// Whether this interface should be protected by the firewall.
	Firewall *bool

	// Whether this interface should be disconnected (like pulling the plug).
	LinkDown *bool

	// <XX:XX:XX:XX:XX:XX> MAC address.
	// That address must be unique withing your network. This is automatically generated if not specified.
	MacAddr *string

	// (0 - 16) Number of packet queues to be used on the device.
	Queues *int

	// (0 - N) Rate limit in mbps (megabytes per second) as floating point number.
	Rate *float64

	// (1 - 4094) VLAN tag to apply to packets on this interface.
	Tag *int

	// <vlanid[;vlanid...]> VLAN trunks to pass through this interface.
	Trunks *string
}

func NewNetworkDeviceFromString added in v0.1.1

func NewNetworkDeviceFromString(value string) *NetworkDevice

func (*NetworkDevice) GetQMOptionValue added in v0.1.1

func (c *NetworkDevice) GetQMOptionValue() 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 NodeDoesNotExistError added in v0.1.6

type NodeDoesNotExistError struct {
	Node string
}

func (*NodeDoesNotExistError) Error added in v0.1.6

func (e *NodeDoesNotExistError) Error() string

type NodesService

type NodesService interface {
	GetNodes() ([]Node, error)
}

type NodesServiceOp

type NodesServiceOp struct {
	// contains filtered or unexported fields
}

func (*NodesServiceOp) GetNodes

func (s *NodesServiceOp) GetNodes() ([]Node, error)

type OSType added in v0.1.1

type OSType int
const (
	OS_Unspecified OSType = 1 + iota
	OS_WindowsXP
	OS_Windows2000
	OS_Windows2003
	OS_Windows2008
	OS_WindowsVista
	OS_Windows7
	OS_Windows8_2012
	OS_Linux24
	OS_Linux26_3X
	OS_Solaris
)

func OSTypeFromString added in v0.1.1

func OSTypeFromString(s string) (OSType, error)

func (OSType) String added in v0.1.1

func (m OSType) String() string

String returns the name of the OSType.

type QMOption added in v0.1.1

type QMOption interface {
	GetQMOptionValue() string
}

type QemuService

type QemuService interface {
	GetVMList(node string) ([]VM, error)
	GetVMCurrentStatus(node string, vmID int) (*VMStatus, error)
	StartVM(node string, vmID int) error
	StopVM(node string, vmID int) error
	ShutdownVM(node string, vmID int) error
	ResetVM(node string, vmID int) error
	SuspendVM(node string, vmID int) error
	ResumeVM(node string, vmID int) error
	GetVMConfig(node string, vmID int) (*VMConfig, error)
	CreateVM(node string, vmID int, config *VMConfig) error
	UpdateVM(node string, vmID int, config *VMConfig, async bool) error
	DeleteVM(node string, vmID int) error
	CreateVMTemplate(node string, vmID int, disk string) error
	CloneVM(node string, vmID int, newID int, config *VMCloneConfig) error
}

type QemuServiceOp

type QemuServiceOp struct {
	// contains filtered or unexported fields
}

func (*QemuServiceOp) CloneVM added in v0.1.7

func (s *QemuServiceOp) CloneVM(node string, vmID int, newID int, config *VMCloneConfig) error

Clone VM.

func (*QemuServiceOp) CreateVM

func (s *QemuServiceOp) CreateVM(node string, vmID int, config *VMConfig) error

Create virtual machine.

func (*QemuServiceOp) CreateVMTemplate added in v0.1.7

func (s *QemuServiceOp) CreateVMTemplate(node string, vmID int, disk string) error

Create a template from VM.

func (*QemuServiceOp) DeleteVM

func (s *QemuServiceOp) DeleteVM(node string, vmID int) error

Create virtual machine.

func (*QemuServiceOp) GetVMConfig added in v0.1.1

func (s *QemuServiceOp) GetVMConfig(node string, vmID int) (*VMConfig, error)

Get config for the virtual machine

func (*QemuServiceOp) GetVMCurrentStatus

func (s *QemuServiceOp) GetVMCurrentStatus(node string, vmID int) (*VMStatus, error)

Get virtual machine status.

func (*QemuServiceOp) GetVMList added in v0.1.1

func (s *QemuServiceOp) GetVMList(node string) ([]VM, error)

Virtual machine index (per node).

func (*QemuServiceOp) ResetVM

func (s *QemuServiceOp) ResetVM(node string, vmID int) error

Reset virtual machine.

func (*QemuServiceOp) ResumeVM

func (s *QemuServiceOp) ResumeVM(node string, vmID int) error

Resume virtual machine.

func (*QemuServiceOp) ShutdownVM

func (s *QemuServiceOp) ShutdownVM(node string, vmID int) 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 int) error

Start virtual machine.

func (*QemuServiceOp) StopVM

func (s *QemuServiceOp) StopVM(node string, vmID int) error

Stop virtual machine. The qemu process will exit immediately. This is akin to pulling the power plug of a running computer and may damage the VM data.

func (*QemuServiceOp) SuspendVM

func (s *QemuServiceOp) SuspendVM(node string, vmID int) error

Suspend virtual machine.

func (*QemuServiceOp) UpdateVM added in v0.1.1

func (s *QemuServiceOp) UpdateVM(node string, vmID int, config *VMConfig, async bool) error

Update virtual machine.

type RequestCompletionCallback

type RequestCompletionCallback func(*http.Request, *http.Response)

RequestCompletionCallback defines the type of the request callback function

type SCSIControllerType added in v0.1.1

type SCSIControllerType int
const (
	SCSI_LSI SCSIControllerType = 1 + iota
	SCSI_LSI53C810
	SCSI_VirtIO_SCSI_PCI
	SCSI_VirtIO_SCSI_SINGLE
	SCSI_MEGASAS
	SCSI_PVSCSI
)

func SCSIControllerTypeFromString added in v0.1.1

func SCSIControllerTypeFromString(s string) (SCSIControllerType, error)

func (SCSIControllerType) String added in v0.1.1

func (m SCSIControllerType) String() string

String returns the name of the SCSIControllerType.

type SerialDevice added in v0.1.3

type SerialDevice struct {
	Value string
}

Serial device

func NewSerialDeviceFromString added in v0.1.3

func NewSerialDeviceFromString(value string) *SerialDevice

func (*SerialDevice) GetQMOptionValue added in v0.1.3

func (c *SerialDevice) GetQMOptionValue() string

type Storage added in v0.1.3

type Storage struct {
	StorageName string `json:"storage"`
	Content     string `json:"content"`
	Type        string `json:"type"`
	Active      int    `json:"active"`
	Enabled     int    `json:"enabled"`
	Shared      int    `json:"shared"`
	Used        int64  `json:"used"`
	Available   int64  `json:"avail"`
	Total       int64  `json:"total"`
}

type StorageService added in v0.1.3

type StorageService interface {
	GetStorageList(node string) ([]Storage, error)
	GetStorageVolumes(node, storageName string) ([]StorageVolume, error)
	GetVolume(node, storageName, volumeId string) (*StorageVolume, error)
	CreateVolume(node, storageName string, vmID int, filename string, size string, format *string) error
	DeleteVolume(node, storageName, volumeId string) error
}

type StorageServiceOp added in v0.1.3

type StorageServiceOp struct {
	// contains filtered or unexported fields
}

func (*StorageServiceOp) CreateVolume added in v0.1.3

func (s *StorageServiceOp) CreateVolume(node, storageName string, vmID int, filename string, size string, format *string) error

Create new volume.

func (*StorageServiceOp) DeleteVolume added in v0.1.3

func (s *StorageServiceOp) DeleteVolume(node, storageName, volumeId string) error

Delete existing volume.

func (*StorageServiceOp) GetStorageList added in v0.1.3

func (s *StorageServiceOp) GetStorageList(node string) ([]Storage, error)

Storage list (per node).

func (*StorageServiceOp) GetStorageVolumes added in v0.1.3

func (s *StorageServiceOp) GetStorageVolumes(node, storageName string) ([]StorageVolume, error)

Get list of volumes per node and storage

func (*StorageServiceOp) GetVolume added in v0.1.3

func (s *StorageServiceOp) GetVolume(node, storageName, volumeId string) (*StorageVolume, error)

Get volume attributes

type StorageVolume added in v0.1.3

type StorageVolume struct {
	Format   string      `json:"format"`
	VolumeId string      `json:"volid"`
	Parent   interface{} `json:"parent"`
	Size     int64       `json:"size"`
	Content  string      `json:"content"`
	Used     int64       `json:"used"`
	VMID     string      `json:"vmid"`
	Path     string      `json:"path"`
}

type VGAType added in v0.1.1

type VGAType int
const (
	VGA_Cirrus VGAType = 1 + iota
	VGA_QXL
	VGA_QXL2
	VGA_QXL3
	VGA_QXL4
	VGA_Serial0
	VGA_Serial1
	VGA_Serial2
	VGA_Serial3
	VGA_std
	VGA_VMWare
)

func VGATypeFromString added in v0.1.1

func VGATypeFromString(s string) (VGAType, error)

func (VGAType) String added in v0.1.1

func (m VGAType) String() string

String returns the name of the VGAType.

type VM

type VM struct {
	VMID      int         `json:"vmid"`
	Name      string      `json:"name"`
	Status    string      `json:"status"`
	PID       string      `json:"pid"`
	Template  interface{} `json:"template"`
	CPU       float64     `json:"cpu"`
	CPUs      int         `json:"cpus"`
	Memory    int         `json:"mem"`
	MaxMemory int         `json:"maxmem"`
	Disk      int         `json:"disk"`
	DiskRead  int         `json:"diskread"`
	DiskWrite int         `json:"diskwrite"`
	MaxDisk   int         `json:"maxdisk"`
	NetIn     int         `json:"netin"`
	NetOut    int         `json:"netout"`
	Uptime    int         `json:"uptime"`
}

type VMCloneConfig added in v0.1.7

type VMCloneConfig struct {
	Name          *string // Set a name for the new VM
	Description   *string // Description for the new VM
	Full          *bool   // Create a full copy of all disk. This is always done when you clone a normal VM. For VM templates, we try to create a linked clone by default
	Pool          *string // Add the new VM to the specified pool
	SnapshotName  *string // The name of the snapshot
	Storage       *string // Target storage for full clone
	StorageFormat *string // Target format for file storage
	TargetNode    *string // Target node. Only allowed if the original VM is on shared storage
}

type VMConfig added in v0.1.1

type VMConfig struct {
	// Enable/disable ACPI.
	// default = 1
	ACPI *bool

	// Enable/disable Qemu GuestAgent.
	// default = 0
	QemuAgent *bool

	//
	// The backup file.
	Archive *string // TODO Create only

	//
	// Arbitrary arguments passed to kvm, for example:
	// args: -no-reboot -no-hpet
	Args *string

	// Automatic restart after crash
	// default = 0
	AutoStart *bool

	//
	// Amount of target RAM for the VM in MB. Using zero disables the balloon driver.
	Balloon *int

	//
	// Select BIOS implementation.
	// default = seabios
	Bios *Bios

	//
	// Boot on floppy (a), hard disk (c), CD-ROM (d), or network (n).
	// default = cdn
	BootOrder []BootDevice

	//
	// Enable booting from specified disk.
	// (ide|sata|scsi|virtio)\d+
	BootDisk *string

	//
	// <volume> This is an alias for option -ide2
	CDROM *string

	//
	// The number of cores per socket.
	// default = 1
	Cores *int

	//
	// [cputype=]<enum> [,hidden=<1|0>] Emulated CPU type.
	// default = kvm64
	// hidden=<boolean> Do not identify as a KVM virtual machine.
	// default = 0
	CPU *CPUType

	//
	// (0 - 128) Limit of CPU usage. NOTE: If the computer has 2 CPUs, it has total of '2' CPU time. Value '0' indicates no CPU limit.
	// default = 0
	CPULimit *int

	//
	// (0 - 500000) CPU weight for a VM. Argument is used in the kernel fair scheduler.
	// The larger the number is, the more CPU time this VM gets.
	// Number is relative to weights of all the other running VMs.
	// You can disable fair-scheduler configuration by setting this to 0.
	// default = 1024
	CPUUnits *int

	//
	// Description for the VM. Only used on the configuration web interface.
	// This is saved as comment inside the configuration file.
	Description *string
	//
	// TODO digest. Only post/put
	//
	// Allow to overwrite existing VM.
	Force *bool

	//
	// Freeze CPU at startup (use 'c' monitor command to start execution).
	Freeze *bool

	//
	// Map host PCI devices into guest.
	// NOTE: This option allows direct access to host hardware.
	// So it is no longer possible to migrate such machines - use with special care.
	HostPCI *string

	//
	// Selectively enable hotplug features.
	// This is a comma separated list of hotplug features: 'network', 'disk', 'cpu', 'memory' and 'usb'.
	// Use '0' to disable hotplug completely.
	// Value '1' is an alias for the default 'network,disk,usb'.
	HotPlug *string

	//
	// Enable/disable hugepages memory.
	HugePages *HugePages

	//
	// Use volume as IDE hard disk or CD-ROM
	IDEDevices map[int]*IDEDevice

	//
	// Keyboard layout for vnc server. Default is read from the '/etc/pve/datacenter.conf' configuration file.
	// default = en-us
	KeyboardLayout *KeyboardLayout

	//
	// Enable/disable KVM hardware virtualization.
	// default = 1
	KVMHardwareVirtualization *bool

	//
	// Set the real time clock to local time. This is enabled by default if ostype indicates a Microsoft OS.
	LocalTime *bool

	//
	// Lock/unlock the VM.
	Lock *Lock

	//
	// Specify the Qemu machine type.
	// (pc|pc(-i440fx)?-\d+\.\d+(\.pxe)?|q35|pc-q35-\d+\.\d+(\.pxe)?)
	MachineType *string

	//
	// Amount of RAM for the VM in MB. This is the maximum available memory when you use the balloon device.
	// default = 512
	Memory *int

	//
	// (0 - N) Set maximum tolerated downtime (in seconds) for migrations.
	// default = 0.1
	MigrateDowntime *int

	//
	// Set maximum speed (in MB/s) for migrations. Value 0 is no limit.
	// default = 0
	MigrateSpeed *int

	//
	// Set a name for the VM. Only used on the configuration web interface.
	Name *string

	//
	// Specify network devices.
	NetworkDevices map[int]*NetworkDevice

	//
	// Enable/disable NUMA.
	// default = 0
	NUMA *bool

	//
	// NUMA topology.
	NUMATopologies map[int]QMOption

	//
	// Specifies whether a VM will be started during system bootup.
	// default = 0
	StartAtBoot *bool

	//
	// Specify guest operating system. This is used to enable special optimization/features for specific operating systems.
	OSType *OSType

	//
	// Map host parallel devices (n is 0 to 2).
	// NOTE: This option allows direct access to host hardware.
	// So it is no longer possible to migrate such machines - use with special care.
	ParallelDevices map[int]QMOption

	//
	// Add theVM to the specified pool.
	Pool *string // TODO Create only

	//
	// Sets the protection flag of the VM. This will disable the remove VM and remove disk operations.
	Protection *bool

	//
	// Allow reboot. If set to '0' the VM exit on reboot.
	Reboot *bool

	//
	// Use volume as SATA hard disk or CD-ROM (n is 0 to 5).
	SATADevices map[int]QMOption

	//
	// Use volume as SCSI hard disk or CD-ROM (n is 0 to 13).
	SCSIDevices map[int]QMOption

	//
	// SCSI controller model
	// default = lsi
	SCSIControllerType *SCSIControllerType

	//
	// Create a serial device inside the VM (n is 0 to 3), and pass through a host serial device (i.e. /dev/ttyS0),
	// or create a unix socket on the host side (use 'qm terminal' to open a terminal connection).
	// NOTE: If you pass through a host serial device, it is no longer possible to migrate such machines - use with special care.
	SerialDevices map[int]*SerialDevice

	//
	// Amount of memory shares for auto-ballooning.
	// The larger the number is, the more memory this VM gets.
	// Number is relative to weights of all other running VMs. Using zero disables auto-ballooning
	// default = 1000
	MemoryShares *int

	//
	// Specify SMBIOS type 1 fields.
	SMBIOS1 *string

	//
	// The number of CPUs. Please use option -sockets instead.
	// default = 1
	SMP *int

	//
	// The number of CPU sockets.
	// default = 1
	Sockets *int

	//
	// Set the initial date of the real time clock. Valid format for date are: 'now' or '2006-06-17T16:01:21' or'2006-06-17'.
	// (now |YYYY-MM-DD | YYYY-MM-DDTHH:MM:SS)
	// default = now
	StartDate *string

	//
	// Startup and shutdown behavior.
	// Order is a non-negative number defining the general startup order. Shutdown is done with reverse ordering.
	// Additionally you can set the 'up' or 'down' delay in seconds, which specifies a delay to wait before the next VM is started or stopped.
	// [[order=]\d+] [,up=\d+] [,down=\d+]
	Startup *string

	//
	// Default storage.
	Storage *string // TODO Create only

	//
	// Enable/disable the USB tablet device. This device is usually needed to allow absolute mouse positioning with VNC.
	// Else the mouse runs out of sync with normal VNC clients. If you're running lots of console-only guests on one host,
	// you may consider disabling this to save some context switches. This is turned off by default if you use spice (-vga=qxl).
	// default = 1
	Tablet *bool

	//
	// Enable/disable time drift fix.
	// default = 0
	TDF *bool

	//
	// Enable/disable Template.
	// default = 0
	Template *bool

	//
	// Assign a unique random ethernet address.
	Unique *bool // TODO Create only

	//
	// Configure an USB device (n is 0 to 4).
	USBDevices map[int]QMOption

	//
	// Number of hotplugged vCPUs.
	// default = 0
	VCPUs *int

	//
	// Select the VGA type. If you want to use high resolution modes (>= 1280x1024x16) then you should use the options std or vmware.
	// Default is std for win8/win7/w2k8, and cirrus for other OS types. The qxl option enables the SPICE display sever.
	// For win* OS you can select how many independent displays you want, Linux guests can add displays them self.
	// You can also run without any graphic card, using a serial device as terminal.
	VGAType *VGAType

	//
	// Use volume as VirtIO hard disk (n is 0 to 15).
	VirtIODevices map[int]*VirtIODevice

	//
	// The (unique) ID of the VM.
	VMID *int // TODO Create only

	//
	// Create a virtual hardware watchdog device. Once enabled (by a guest action),
	// the watchdog must be periodically polled by an agent inside the guest or else the watchdog will reset the guest
	// (or execute the respective action specified)
	Watchdog *string
}

func NewVMConfigFromMap added in v0.1.1

func NewVMConfigFromMap(data map[string]interface{}) *VMConfig

func (*VMConfig) AddIDEDevice added in v0.1.1

func (c *VMConfig) AddIDEDevice(number int, value *IDEDevice)

func (*VMConfig) AddNUMATopology added in v0.1.1

func (c *VMConfig) AddNUMATopology(number int, value QMOption)

func (*VMConfig) AddNetworkDevice added in v0.1.1

func (c *VMConfig) AddNetworkDevice(number int, value *NetworkDevice)

func (*VMConfig) AddParallelDevice added in v0.1.1

func (c *VMConfig) AddParallelDevice(number int, value QMOption)

func (*VMConfig) AddSATADevice added in v0.1.1

func (c *VMConfig) AddSATADevice(number int, value QMOption)

func (*VMConfig) AddSCSIDevice added in v0.1.1

func (c *VMConfig) AddSCSIDevice(number int, value QMOption)

func (*VMConfig) AddSerialDevice added in v0.1.1

func (c *VMConfig) AddSerialDevice(number int, value *SerialDevice)

func (*VMConfig) AddUSBDevice added in v0.1.1

func (c *VMConfig) AddUSBDevice(number int, value QMOption)

func (*VMConfig) AddVirtIODevice added in v0.1.1

func (c *VMConfig) AddVirtIODevice(number int, value *VirtIODevice)

func (*VMConfig) GetOptionsMap added in v0.1.1

func (c *VMConfig) GetOptionsMap() (map[string]string, error)

type VMDoesNotExistError added in v0.1.6

type VMDoesNotExistError struct {
	VMID string
}

func (*VMDoesNotExistError) Error added in v0.1.6

func (e *VMDoesNotExistError) Error() string

type VMStatus

type VMStatus struct {
	Name      string      `json:"name"`
	Status    string      `json:"status"`
	QMPstatus string      `json:"qmpstatus"`
	PID       string      `json:"pid"`
	Template  interface{} `json:"template"`
	CPU       float64     `json:"cpu"`
	CPUs      int         `json:"cpus"`
	Memory    int         `json:"mem"`
	MaxMemory int         `json:"maxmem"`
	Disk      int         `json:"disk"`
	DiskRead  int         `json:"diskread"`
	DiskWrite int         `json:"diskwrite"`
	MaxDisk   int         `json:"maxdisk"`
	NetIn     int         `json:"netin"`
	NetOut    int         `json:"netout"`
	Uptime    int         `json:"uptime"`
	HA        interface{} `json:"ha"`
}

type VirtIODevice added in v0.1.1

type VirtIODevice struct {
	File     *string
	Format   *VolumeFormat
	Backup   *bool
	IOThread *bool
	Size     *string
	Snapshot *bool
}

func NewVirtIODeviceFromString added in v0.1.1

func NewVirtIODeviceFromString(value string) *VirtIODevice

func (*VirtIODevice) GetQMOptionValue added in v0.1.1

func (c *VirtIODevice) GetQMOptionValue() string

type VolumeFormat added in v0.1.1

type VolumeFormat int
const (
	VolumeFormat_CLOOP VolumeFormat = 1 + iota
	VolumeFormat_COW
	VolumeFormat_QCOW
	VolumeFormat_QCOW2
	VolumeFormat_QED
	VolumeFormat_RAW
	VolumeFormat_VMDK
)

func VolumeFormatFromString added in v0.1.1

func VolumeFormatFromString(s string) (VolumeFormat, error)

func (VolumeFormat) String added in v0.1.1

func (m VolumeFormat) String() string

String returns the name of the VolumeFormat.

Directories

Path Synopsis
internal
Package internal contains support packages for oauth2 package.
Package internal contains support packages for oauth2 package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL