proxmox

package
v0.0.0-...-a8870b4 Latest Latest
Warning

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

Go to latest
Published: May 21, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LXC_CMODE_CONSOLE = "console"
	LXC_CMODE_SHELL   = "shell"
	LXC_CMODE_TTY     = "tty"

	LXC_ARCH_AMD64 = "amd64"
	LXC_ARCH_I386  = "i386"

	LXC_LOCK_BACKUP   = "backup"
	LXC_LOCK_MIGRATE  = "migrate"
	LXC_LOCK_ROLBACK  = "rollback"
	LXC_LOCK_SNAPSHOT = "snapshot"
)
View Source
const (
	BACKUP_MODE_SNAPSHOT BackupMode = 0
	BACKUP_MODE_SUSPEND  BackupMode = 1
	BACKUP_MODE_STOP     BackupMode = 2
	BACKUP_COMP_LZO      BackupComp = 0
	BACKUP_COMP_GZIP     BackupComp = 1
)
View Source
const (
	HTTP_TIMEOUT           = 5
	API_TARGET             = "/api2/json/"
	API_AUTH_TARGET        = "access/ticket"
	API_TOKEN_LIFETIME     = 120
	API_TOKEN_UPDATEBEFORE = 5
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APICaller

type APICaller interface {
	// contains filtered or unexported methods
}

type APITarget

type APITarget string

type BackupComp

type BackupComp int

func (BackupComp) String

func (bc BackupComp) String() string

type BackupMode

type BackupMode int

func (BackupMode) String

func (bm BackupMode) String() string

type BaseLxcConfig

type BaseLxcConfig struct {
	Arch         string `json:"arch"`
	CMode        string `json:"cmode"`
	Console      bool   `json:"console"`
	Cores        int    `json:"cores"`
	CpuLimit     int    `json:"cpulimit"`
	CpuUnits     int    `json:"cpuunits"`
	Description  string `json:"description"`
	Force        bool   `json:"force"`
	Hostname     string `json:"hostname"`
	Lock         string `json:"lock"`
	Memory       int    `json:"memory"`
	NameServer   string `json:"nameserver"`
	OnBoot       bool   `json:"onboot"`
	OSTemplate   string `json:"ostemplate"`
	OSType       string `json:"ostype"`
	Password     string `json:"password"`
	Pool         string `json:"pool"`
	Protection   bool   `json:"protection"`
	Restore      bool   `json:"restore"`
	SearchDomain string `json:"search_domain"`
	Storage      string `json:"storage"`
	Swap         int    `json:"swap"`
	Template     bool   `json:"template"`
	Tty          int    `json:"tty"`
	Unprivileged bool   `json:"unprivileged"`
	VmId         int64  `json:"vmid"`
	RootFS       string `json:"rootfs"`
}

type BaseStorageItem

type BaseStorageItem struct {
	ACL      bool
	Backup   bool
	Quota    bool
	ReadOnly bool
	Shared   bool
	Size     int
}

type BaseTask

type BaseTask struct {
	Id        string `json:"id"`
	Node      string `json:"node"`
	PID       int    `json:"pid"`
	PStart    int    `json:"pstart"`
	StartTime int    `json:"starttime"`
	Status    string `json:"status"` // Task("OK"),TaskStatus("running","stopped")
	Type      string `json:"type"`
	UPid      TaskID `json:"upid"`
	User      string `json:"user"`
}

type BasicObject

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

func NewBasicObject

func NewBasicObject(parent interface{}) BasicObject

func (BasicObject) GetNode

func (bo BasicObject) GetNode() *Node

func (BasicObject) GetParent

func (bo BasicObject) GetParent() interface{}

func (BasicObject) GetProxmox

func (bo BasicObject) GetProxmox() *Proxmox

type LVMVolumeGroup

type LVMVolumeGroup struct {
	Free int64  `json:"free"`
	Size int64  `json:"size"`
	VG   string `json:"vg"`
}

type Lxc

type Lxc struct {
	Pid int `json:"pid,string"`
	LxcBase
	BasicObject
}

func (*Lxc) GetStatus

func (lxc *Lxc) GetStatus() (*LxcStatus, error)

func (*Lxc) Shutdown

func (lxc *Lxc) Shutdown(forceStop bool, timeout int) (*TaskID, error)

func (*Lxc) Start

func (lxc *Lxc) Start(skiplock bool) (*TaskID, error)

func (*Lxc) Stop

func (lxc *Lxc) Stop(skiplock bool) (*TaskID, error)

func (*Lxc) WaitForStatus

func (lxc *Lxc) WaitForStatus(status string, timeout int) (bool, *LxcStatus, error)

type LxcBase

type LxcBase struct {
	Cpu       float64     `json:"cpu"`
	Cpus      interface{} `json:"cpus"`
	Disk      int64       `json:"disk"`
	DiskRead  interface{} `json:"diskread,omitempty"`
	DiskWrite interface{} `json:"diskwrite,omitempty"`
	MaxDisk   int64       `json:"maxdisk"`
	MaxMem    int64       `json:"maxmem"`
	MaxSwap   int64       `json:"maxswap"`
	Mem       int64       `json:"mem"`
	Name      string      `json:"name"`
	NetIn     int64       `json:"netin"`
	NetOut    int64       `json:"netout"`
	Status    string      `json:"status"`
	Swap      int64       `json:"swap"`
	Template  string      `json:"template"`
	Type      string      `json:"type"`
	Uptime    int64       `json:"uptime"`
	VmId      int64       `json:"vmid,string"`
}

type LxcConfig

type LxcConfig struct {
	MountPoints []MountPoint
	Networks    []NetworkConfig
	Startup     StartupConfig

	BaseLxcConfig
}

func (*LxcConfig) GetUrlDataValues

func (clp *LxcConfig) GetUrlDataValues() url.Values

func (*LxcConfig) Validate

func (clp *LxcConfig) Validate() error

type LxcConfigReceiver

type LxcConfigReceiver struct {
	Mp0 string `json:"mp0"`
	Mp1 string `json:"mp1"`
	Mp2 string `json:"mp2"`
	Mp3 string `json:"mp3"`
	Mp4 string `json:"mp4"`
	Mp5 string `json:"mp5"`
	Mp6 string `json:"mp6"`
	Mp7 string `json:"mp7"`
	Mp8 string `json:"mp8"`
	Mp9 string `json:"mp9"`

	Net0 string `json:"net0"`
	Net1 string `json:"net1"`
	Net2 string `json:"net2"`
	Net3 string `json:"net3"`
	Net4 string `json:"net4"`
	Net5 string `json:"net5"`
	Net6 string `json:"net6"`
	Net7 string `json:"net7"`
	Net8 string `json:"net8"`
	Net9 string `json:"net9"`

	Startup string `json:"startup"`

	Lxc []interface{} `json:"lxc"`

	BaseLxcConfig
}

func (*LxcConfigReceiver) Parse

func (lcr *LxcConfigReceiver) Parse() *LxcConfig

type LxcStatus

type LxcStatus struct {
	HA map[string]interface{} `json:"ha"`
	LxcBase
}

type MountPoint

type MountPoint struct {
	Index  int
	Volume string
	Path   string
	BaseStorageItem
}

func (*MountPoint) SetFromString

func (mp *MountPoint) SetFromString(idx int, str string)

func (*MountPoint) String

func (mp *MountPoint) String() string

type NetworkConfig

type NetworkConfig struct {
	Index      int
	Name       string
	Bridge     string
	Firewall   bool
	Gateway    string
	GatewayV6  string
	HWAddr     string
	IPAddress  string
	IPAddresV6 string
	MTU        int
	Rate       int
	Tag        int
	Trunks     string
	Type       string
}

func (*NetworkConfig) SetFromString

func (nc *NetworkConfig) SetFromString(idx int, str string)

func (*NetworkConfig) String

func (nc *NetworkConfig) String() string

type Node

type Node struct {
	Cpu     float64 `json:"cpu"`
	Disk    int64   `json:"disk"`
	Id      string  `json:"id"`
	Level   string  `json:"level"`
	MaxCpu  int     `json:"maxcpu"`
	MaxDisk int64   `json:"maxdisk"`
	MaxMem  int64   `json:"maxmem"`
	Mem     int64   `json:"mem"`
	Node    string  `json:"node"`
	Type    string  `json:"type"`
	Uptime  int64   `json:"uptime"`

	BasicObject
}

func (*Node) CreateLxc

func (n *Node) CreateLxc(lxcParams LxcConfig) (*TaskID, error)

func (*Node) GetLxc

func (n *Node) GetLxc(vmid int64) (*Lxc, error)

func (*Node) GetLxcList

func (n *Node) GetLxcList() ([]Lxc, error)

func (*Node) GetStorageList

func (n *Node) GetStorageList() ([]Storage, error)

func (*Node) GetTasks

func (n *Node) GetTasks() ([]Task, error)

func (*Node) RemoveLxc

func (n *Node) RemoveLxc(vmid int64) (*TaskID, error)

func (*Node) RestoreLxc

func (n *Node) RestoreLxc(vmid int64, storageContentItem StorageContentItem, storage string, force bool, newLxcParams LxcConfig) (*TaskID, error)

func (*Node) ScanLVM

func (n *Node) ScanLVM() ([]LVMVolumeGroup, error)

func (*Node) ScanUSB

func (n *Node) ScanUSB() ([]USBDevice, error)

func (*Node) VZDump

func (n *Node) VZDump(vmid int64, storage Storage, mode BackupMode, comp BackupComp, remove bool) (*TaskID, error)

type Proxmox

type Proxmox struct {
	*http.Client
	// contains filtered or unexported fields
}

func New

func New(host, port, user, pass, realm string) (*Proxmox, error)

func (*Proxmox) APICall

func (px *Proxmox) APICall(method string, target APITarget, data url.Values) ([]byte, int, error)

func (*Proxmox) APICall2

func (px *Proxmox) APICall2(method string, target string, data url.Values, result interface{}, ac APICaller) (int, error)

func (*Proxmox) DataUnmarshal

func (px *Proxmox) DataUnmarshal(body []byte, v interface{}, ac APICaller) error

func (*Proxmox) GetAuthTicket

func (px *Proxmox) GetAuthTicket() string

func (*Proxmox) GetHost

func (px *Proxmox) GetHost() string

func (*Proxmox) GetNode

func (px *Proxmox) GetNode(nodeName string) (*Node, error)

func (*Proxmox) GetNodes

func (px *Proxmox) GetNodes() ([]Node, error)

func (*Proxmox) GetProxmoxVersion

func (px *Proxmox) GetProxmoxVersion() (*ProxmoxVersionInfo, error)

func (*Proxmox) GetStorageList

func (px *Proxmox) GetStorageList() ([]Storage, error)

func (*Proxmox) MakeAPITarget

func (px *Proxmox) MakeAPITarget(path string) (APITarget, error)

type ProxmoxVersionInfo

type ProxmoxVersionInfo struct {
	Release string
	Repoid  string
	Version string
}

type StartupConfig

type StartupConfig struct {
	Order     int
	UpDelay   int
	DownDelay int
}

func (*StartupConfig) SetFromString

func (sc *StartupConfig) SetFromString(str string)

func (*StartupConfig) String

func (sc *StartupConfig) String() string

type Storage

type Storage struct {
	Content  string `json:"content"`
	Digest   string `json:"digest"`
	Maxfiles int64  `json:"maxfiles"`
	Path     string `json:"path"`
	Shared   int    `json:"shared"`
	Storage  string `json:"storage"`
	Type     string `json:"type"`

	BasicObject
}

func (*Storage) GetContents

func (s *Storage) GetContents() ([]StorageContentItem, error)

type StorageContentItem

type StorageContentItem struct {
	Content string `json:"content"`
	Format  string `json:"format"`
	Parent  string `json:"parent"`
	Size    int    `json:"size"`
	Used    int    `json:"used"`
	VMid    string `json:"vmid"`
	Volid   string `json:"volid"`
}

type Task

type Task struct {
	EndTime int `json:"endtime"`
	BaseTask
	BasicObject
}

func (*Task) GetStatus

func (t *Task) GetStatus() (*TaskStatus, error)

func (*Task) WaitForStatus

func (t *Task) WaitForStatus(status string, timeout int) (bool, *TaskStatus, error)

type TaskID

type TaskID string

type TaskStatus

type TaskStatus struct {
	ExitStatus string `json:"exitstatus,omitempty"`
	BaseTask
}

type USBDevice

type USBDevice struct {
	Busnum       int    `json:"busnum"`
	Class        int    `json:"class"`
	Devnum       int    `json:"devnum"`
	Level        int    `json:"level"`
	Manufacturer string `json:"manufacturer"`
	Port         int    `json:"port"`
	Prodid       string `json:"prodid"`
	Product      string `json:"product"`
	Speed        string `json:"speed"`
	Usbpath      string `json:"usbpath"`
	Vendid       string `json:"vendid"`
}

Jump to

Keyboard shortcuts

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