proxmox

package module
v0.0.0-beta6 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

README

Proxmox API Client Go Package

Continuous Integration GitHub license GitHub issues GitHub release codecov Go Report Card Go Reference

Join the community to discuss ongoing client development usage, the proxmox API or tooling in the #go-proxmox channel on the Gophers Slack and see the self generated docs for more usage details.

Slack

A go client for Proxmox VE. The client implements /api2/json and inspiration was drawn from the existing Telmate package but looking to improve in the following ways...

  • Treated as a proper standalone go package
  • Types and JSON marshal/unmarshalling for all end points
  • Full Testing, unit testing with mocks and integration tests against an API endpoint
  • Configuration options when creating a client for flexible usage
  • Client logging for debugging within your code
  • Context support
  • Added functionality for better go tooling built on this library, some things we'd like
    • Boot VM from qcow URL, inspiration: Proxmox Linux Templates
    • Dynamic host targeting for VM, Proxmox lacks a scheduler when given VM params it will try and locate a host with resources to put it
    • cloud-init support via no-cloud ISOs uploaded to node data stores and auto-mounted before boot, inspiration quiso
    • Unattended XML Support via ISOs similar to cloud-init ideas
    • node/vm/container shell command support via KVM proxy already built into proxmox

Core developers are home lab enthusiasts working in the virtualization and kubernetes space. The common use case we have for Proxmox is dev stress testing and validation of functionality in the products we work on, we plan to build the following tooling around this library to make that easier.

Usage

Create a client and use the public methods to access Proxmox resources.

Basic usage with login with a username and password credential
package main

import (
	"context"
	"fmt"

	"github.com/ParminCloud/go-proxmox"
)

func main() {
    credentials := proxmox.Credentials{
		Username: "root@pam",
		Password: "12345",
    }
    client := proxmox.NewClient("https://localhost:8006/api2/json",
		proxmox.WithCredentials(&credentials),
    )

    version, err := client.Version(context.Background())
    if err != nil {
        panic(err)
    }
    fmt.Println(version.Release) // 7.4
}
Usage with Client Options
package main

import (
	"context"
	"crypto/tls"
	"fmt"
	"net/http"

	"github.com/ParminCloud/go-proxmox"
)

func main() {
    insecureHTTPClient := http.Client{
        Transport: &http.Transport{
            TLSClientConfig: &tls.Config{
                InsecureSkipVerify: true,
            },
        },
    }
    tokenID := "root@pam!mytoken"
    secret := "somegeneratedapitokenguidefromtheproxmoxui"

    client := proxmox.NewClient("https://localhost:8006/api2/json",
        proxmox.WithHTTPClient(&insecureHTTPClient),
        proxmox.WithAPIToken(tokenID, secret),
    )

    version, err := client.Version(context.Background())
    if err != nil {
        panic(err)
    }
    fmt.Println(version.Release) // 6.3
}

Developing

This project relies on Mage for cross os/arch compatibility, please see their installation guide.

Unit Testing

Run mage test to run the unit tests in the root directory.

Integration Testing

To run the integration testing suite against an existing Proxmox API set some env vars in your shell before running mage testIntegration. The integration tests will test logging in and using an API token credentials so make sure you set all five env vars before running tests for them to pass.

Please leave no trace when developing integration tests. All tests should create and remove all testing data they generate then they can be repeatably run against the same proxmox environment. Most people working on this package will likely use their personal Proxmox VE home lab and consuming extra resources via tests will lead to frustration.

Bash
export PROXMOX_URL="https://192.168.1.6:8006/api2/json"
export PROXMOX_USERNAME="root@pam"
export PROXMOX_PASSWORD="password"
export PROXMOX_TOKENID="root@pam!mytoken"
export PROXMOX_SECRET="somegeneratedapitokenguidefromtheproxmoxui"

mage test:integration
Powershell
$Env:PROXMOX_URL = "https://192.168.1.6:8006/api2/json"
$Env:PROXMOX_USERNAME = "root@pam"
$Env:PROXMOX_PASSWORD = "password"
$Env:PROXMOX_TOKENID = "root@pam!mytoken"
$Env:PROXMOX_SECRET = "somegeneratedapitokenguidefromtheproxmoxui"

mage test:integration

Documentation

Index

Constants

View Source
const (
	LevelError = iota + 1
	LevelWarn
	LevelInfo
	LevelDebug
)
View Source
const (
	DefaultUserAgent = "go-proxmox/dev"
	TagFormat        = "go-proxmox+%s"
)
View Source
const (
	TimeframeHour  = Timeframe("hour")
	TimeframeDay   = Timeframe("day")
	TimeframeWeek  = Timeframe("week")
	TimeframeMonth = Timeframe("month")
	TimeframeYear  = Timeframe("year")
)
View Source
const (
	AVERAGE = ConsolidationFunction("AVERAGE")
	MAX     = ConsolidationFunction("MAX")
)
View Source
const (
	DomainTypeAD     = DomainType("ad")
	DomainTypeLDAP   = DomainType("ldap")
	DomainTypeOpenID = DomainType("openid")
	DomainTypePam    = DomainType("pam")
	DomainTypePVE    = DomainType("pve")
)
View Source
const (
	StatusVirtualMachineRunning = "running"
	StatusVirtualMachineStopped = "stopped"
	StatusVirtualMachinePaused  = "paused"

	UserDataISOFormat = "user-data-%d.iso"
	TagCloudInit      = "cloud-init"
	TagSeperator      = ";"
)
View Source
const (
	TaskRunning = "running"
)

Variables

View Source
var DefaultAgentWaitInterval = 100 * time.Millisecond

DefaultAgentWaitInterval is the polling interval when waiting for agent exec commands

View Source
var DefaultWaitInterval = 1 * time.Second
View Source
var ErrNoop = errors.New("nothing to do")
View Source
var ErrNotAuthorized = errors.New("not authorized to access endpoint")
View Source
var ErrNotFound = errors.New("unable to find the item you are looking for")
View Source
var ErrTimeout = errors.New("the operation has timed out")

Functions

func IsErrNoop

func IsErrNoop(err error) bool

func IsNotAuthorized

func IsNotAuthorized(err error) bool

func IsNotFound

func IsNotFound(err error) bool

func IsTimeout

func IsTimeout(err error) bool

func MakeTag

func MakeTag(v string) string

Types

type ACL

type ACL struct {
	Path      string    `json:",omitempty"`
	RoleID    string    `json:",omitempty"`
	Type      string    `json:",omitempty"`
	UGID      string    `json:",omitempty"`
	Propagate IntOrBool `json:",omitempty"`
}

type ACLOptions

type ACLOptions struct {
	Path      string    `json:",omitempty"`
	Roles     string    `json:",omitempty"`
	Groups    string    `json:",omitempty"`
	Users     string    `json:",omitempty"`
	Tokens    string    `json:",omitempty"`
	Propagate IntOrBool `json:",omitempty"`
	Delete    IntOrBool `json:",omitempty"` // true to delete the ACL
}

type ACLs

type ACLs []*ACL

type AgentExecStatus

type AgentExecStatus struct {
	Exited       bool   `json:"exited"`
	ErrData      string `json:"err-data"`
	ErrTruncated bool   `json:"err-truncated"`
	ExitCode     int    `json:"exit-code"`
	OutData      string `json:"out-data"`
	OutTruncated string `json:"out-truncated"`
	Signal       bool   `json:"signal"`
}

type AgentNetworkIPAddress

type AgentNetworkIPAddress struct {
	IPAddressType string `json:"ip-address-type"` //ipv4 ipv6
	IPAddress     string `json:"ip-address"`
	Prefix        int    `json:"prefix"`
	MacAddress    string `json:"mac-address"`
}

type AgentNetworkIface

type AgentNetworkIface struct {
	Name            string                   `json:"name"`
	HardwareAddress string                   `json:"hardware-address"`
	IPAddresses     []*AgentNetworkIPAddress `json:"ip-addresses"`
}

type AgentOsInfo

type AgentOsInfo struct {
	Version       string `json:"version"`
	VersionID     string `json:"version-id"`
	ID            string `json:"id"`
	Machine       string `json:"machine"`
	PrettyName    string `json:"pretty-name"`
	Name          string `json:"name"`
	KernelRelease string `json:"kernel-release"`
	KernelVersion string `json:"kernel-version"`
}

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 Backup

type Backup struct{ Content }

func (*Backup) Delete

func (b *Backup) Delete(ctx context.Context) (*Task, error)

type Backups

type Backups []*Backup

type CPUInfo

type CPUInfo struct {
	UserHz  int `json:"user_hz"`
	MHZ     string
	Mode    string
	Cores   int
	Sockets int
	Flags   string
	CPUs    int
	HVM     string
}

type Client

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

func NewClient

func NewClient(baseURL string, opts ...Option) *Client

func (*Client) ACL

func (c *Client) ACL(ctx context.Context) (acl ACLs, err error)

func (*Client) APIToken deprecated

func (c *Client) APIToken(tokenID, secret string)

Deprecated: Use the WithAPIToken Option

func (*Client) Cluster

func (c *Client) Cluster(ctx context.Context) (*Cluster, error)

func (*Client) Delete

func (c *Client) Delete(ctx context.Context, p string, v interface{}) error

func (*Client) Domain

func (c *Client) Domain(ctx context.Context, realm string) (domain *Domain, err error)

func (*Client) Domains

func (c *Client) Domains(ctx context.Context) (domains Domains, err error)

func (*Client) Get

func (c *Client) Get(ctx context.Context, p string, v interface{}) error

func (*Client) Group

func (c *Client) Group(ctx context.Context, groupid string) (group *Group, err error)

func (*Client) Groups

func (c *Client) Groups(ctx context.Context) (groups Groups, err error)

func (*Client) Login deprecated

func (c *Client) Login(ctx context.Context, username, password string) error

Deprecated: Use WithCredentials Option

func (*Client) NewDomain

func (c *Client) NewDomain(ctx context.Context, realm string, domainType DomainType) error

NewDomain create a new domain with the required two parameters pull it and use domain.Update to configure

func (*Client) NewGroup

func (c *Client) NewGroup(ctx context.Context, groupid, comment string) error

NewGroup makes a new group, comment is option and can be left empty

func (*Client) NewPool

func (c *Client) NewPool(ctx context.Context, poolid, comment string) error

func (*Client) Node

func (c *Client) Node(ctx context.Context, name string) (node *Node, err error)

func (*Client) Nodes

func (c *Client) Nodes(ctx context.Context) (ns NodeStatuses, err error)

func (*Client) Password

func (c *Client) Password(ctx context.Context, userid, password string) error

func (*Client) Permissions

func (c *Client) Permissions(ctx context.Context, o *PermissionsOptions) (permissions Permissions, err error)

Permissions get permissions for the current user for the client which passes no params, use Permission

func (*Client) Pool

func (c *Client) Pool(ctx context.Context, poolid string, filters ...string) (pool *Pool, err error)

Pool optional filter of cluster resources by type, enum can be "qemu", "lxc", "storage".

func (*Client) Pools

func (c *Client) Pools(ctx context.Context) (pools Pools, err error)

func (*Client) Post

func (c *Client) Post(ctx context.Context, p string, d interface{}, v interface{}) error

func (*Client) Put

func (c *Client) Put(ctx context.Context, p string, d interface{}, v interface{}) error

func (*Client) Req

func (c *Client) Req(ctx context.Context, method, path string, data []byte, v interface{}) error

func (*Client) Role

func (c *Client) Role(ctx context.Context, roleid string) (role Permission, err error)

func (*Client) Roles

func (c *Client) Roles(ctx context.Context) (roles Roles, err error)

func (*Client) Ticket

func (c *Client) Ticket(ctx context.Context, credentials *Credentials) (*Session, error)

func (*Client) UpdateACL

func (c *Client) UpdateACL(ctx context.Context, acl ACL) error

func (*Client) Upload

func (c *Client) Upload(path string, fields map[string]string, file *os.File, v interface{}) error

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 endpoint 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) User

func (c *Client) User(ctx context.Context, userid string) (user *User, err error)

func (*Client) Users

func (c *Client) Users(ctx context.Context) (users Users, err error)

func (*Client) VNCWebSocket

func (c *Client) VNCWebSocket(path string, vnc *VNC) (chan string, chan string, chan error, func() error, error)

func (*Client) Version

func (c *Client) Version(ctx context.Context) (*Version, error)

type Cluster

type Cluster struct {
	Version int
	Quorate int
	Nodes   NodeStatuses
	Name    string
	ID      string
	// contains filtered or unexported fields
}

func (*Cluster) FWGroup

func (cl *Cluster) FWGroup(ctx context.Context, name string) (group *FirewallSecurityGroup, err error)

func (*Cluster) FWGroups

func (cl *Cluster) FWGroups(ctx context.Context) (groups []*FirewallSecurityGroup, err error)

func (*Cluster) NewFWGroup

func (cl *Cluster) NewFWGroup(ctx context.Context, group *FirewallSecurityGroup) error

func (*Cluster) NextID

func (cl *Cluster) NextID(ctx context.Context) (int, error)

func (*Cluster) Resources

func (cl *Cluster) Resources(ctx context.Context, 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) Status

func (cl *Cluster) Status(ctx context.Context) error

func (*Cluster) UnmarshalJSON

func (cl *Cluster) UnmarshalJSON(b []byte) error

type ClusterResource

type ClusterResource struct {
	ID         string  `jsont:"id"`
	Type       string  `json:"type"`
	CGroupMode uint64  `json:"cgroup-mode,omitempty"`
	Content    string  `json:",omitempty"`
	CPU        float64 `json:",omitempty"`
	Disk       uint64  `json:",omitempty"` // documented as string but this is an int
	DiskRead   uint64  `json:",omitempty"`
	DiskWrite  uint64  `json:",omitempty"`
	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"`
	NetIn      uint64  `json:",omitempty"`
	NetOut     uint64  `json:",omitempty"`
	Node       string  `json:",omitempty"`
	PluginType string  `json:",omitempty"`
	Pool       string  `json:",omitempty"`
	Shared     uint64  `json:",omitempty"`
	Status     string  `json:",omitempty"`
	Storage    string  `json:",omitempty"`
	Tags       string  `json:",omitempty"`
	Template   uint64  `json:",omitempty"`
	Uptime     uint64  `json:",omitempty"`
	VMID       uint64  `json:",omitempty"`
}

type ClusterResources

type ClusterResources []*ClusterResource

type ConsolidationFunction

type ConsolidationFunction string

type Container

type Container struct {
	Name string
	Node string

	CPUs    int
	Status  string
	VMID    StringOrUint64
	Uptime  uint64
	MaxMem  uint64
	MaxDisk uint64
	MaxSwap uint64
	Tags    string
	// contains filtered or unexported fields
}

func (*Container) Clone

func (c *Container) Clone(ctx context.Context, params *ContainerCloneOptions) (newid int, task *Task, err error)

func (*Container) Config

func (c *Container) Config(ctx context.Context, options ...ContainerOption) (*Task, error)

func (*Container) Delete

func (c *Container) Delete(ctx context.Context) (task *Task, err error)

func (*Container) Reboot

func (c *Container) Reboot(ctx context.Context) (status *ContainerStatus, err error)

func (*Container) Resume

func (c *Container) Resume(ctx context.Context) (status *ContainerStatus, err error)

func (*Container) Start

func (c *Container) Start(ctx context.Context) (status string, err error)

func (*Container) Stop

func (c *Container) Stop(ctx context.Context) (status *ContainerStatus, err error)

func (*Container) Suspend

func (c *Container) Suspend(ctx context.Context) (status *ContainerStatus, err error)

func (*Container) TermProxy

func (c *Container) TermProxy(ctx context.Context) (vnc *VNC, err error)

func (*Container) VNCWebSocket

func (c *Container) VNCWebSocket(vnc *VNC) (chan string, chan string, chan error, func() error, error)

type ContainerCloneOptions

type ContainerCloneOptions struct {
	NewID       int    `json:"newid"`
	BWLimit     uint64 `json:"bwlimit,omitempty"`
	Description string `json:"description,omitempty"`
	Full        uint8  `json:"full,omitempty"`
	Hostname    string `json:"hostname,omitempty"`
	Pool        string `json:"pool,omitempty"`
	SnapName    string `json:"snapname,omitempty"`
	Storage     string `json:"storage,omitempty"`
	Target      string `json:"target,omitempty"`
}

type ContainerOption

type ContainerOption struct {
	Name  string
	Value interface{}
}

type ContainerOptions

type ContainerOptions []*ContainerOption

ContainerOptions A key/value pair used to modify a container(LXC) config Refer to https://pve.proxmox.com/pve-docs/api-viewer/#/nodes/{node}/lxc/{vmid}/config for a list of valid values

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 Credentials struct {
	Username string `json:"username"`
	Password string `json:"password"`
	Otp      string `json:"otp,omitempty"` // One-time password for Two-factor authentication.
	Path     string `json:"path,omitempty"`
	Privs    string `json:"privs,omitempty"`
	Realm    string `json:"realm,omitempty"`
}

type Domain

type Domain struct {
	Realm string `json:",omitempty"`
	Type  string `json:",omitempty"`

	// options https://pve.proxmox.com/pve-docs/api-viewer/#/access/domains
	ACRValues      string    `json:"acr-values,omitempty"`
	AutoCreate     IntOrBool `json:"autocreate,omitempty"`
	BaseDN         string    `json:"base_dn,omitempty"`
	BindDN         string    `json:"bind_dn,omitempty"`
	CAPath         string    `json:"capath,omitempty"`
	CaseSensitive  IntOrBool `json:"case-sensitive,omitempty"`
	Cert           string    `json:"cert,omitempty"`
	CertKey        string    `json:"certkey,omitempty"`
	ClientID       string    `json:"client-id,omitempty"`
	ClientKey      string    `json:"client-key,omitempty"`
	Comment        string    `json:"comment,omitempty"`
	Default        IntOrBool `json:"default,omitempty"`
	DeleteList     string    `json:"delete,omitempty"` // a list of settings you want to delete?
	Digest         string    `json:"digest,omitempty"`
	Domain         string    `json:"domain,omitempty"`
	Filter         string    `json:"filter,omitempty"`
	GroupClasses   string    `json:"group_classes,omitempty"`
	GroupDN        string    `json:"group_dn,omitempty"`
	GroupFilter    string    `json:"group_filter,omitempty"`
	GroupName      string    `json:"group_name,omitempty"`
	IssuerURL      string    `json:"issuer-url,omitempty"`
	Mode           string    `json:"mode,omitempty"` //ldap, ldaps,ldap+starttls
	Password       string    `json:"password,omitempty"`
	Port           int       `json:"port,omitempty"`
	Prompt         string    `json:"prompt,omitempty"`
	Scopes         string    `json:"scopes,omitempty"`
	Secure         IntOrBool `json:"secure,omitempty"`
	Server1        string    `json:"server1,omitempty"`
	Server2        string    `json:"server2,omitempty"`
	SSLVersion     string    `json:"sslversion,omitempty"`
	SyncDefaults   string    `json:"sync-defaults,omitempty"`
	SyncAttributes string    `json:"sync_attributes,omitempty"`
	TFA            string    `json:"tfa,omitempty"`
	UserAttr       string    `json:"user_attr,omitempty"`
	UserClasses    string    `json:"user_classes,omitempty"`
	Verify         IntOrBool `json:"verify,omitempty"`
	// contains filtered or unexported fields
}

func (*Domain) Delete

func (d *Domain) Delete(ctx context.Context) error

func (*Domain) Sync

func (d *Domain) Sync(ctx context.Context, options DomainSyncOptions) error

func (*Domain) Update

func (d *Domain) Update(ctx context.Context) error

type DomainSyncOptions

type DomainSyncOptions struct {
	DryRun         bool   `json:"dry-run,omitempty"`
	EnableNew      bool   `json:"enable-new,omitempty"`
	RemoveVanished string `json:"remove-vanished,omitempty"`
	Scope          string `json:"scope,omitempty"` // users, groups, both
}

DomainSyncOptions see details https://pve.proxmox.com/pve-docs/api-viewer/#/access/domains/{realm}/sync

type DomainType

type DomainType string

type Domains

type Domains []*Domain

type FirewallNodeOption

type FirewallNodeOption struct {
	Enable                           bool   `json:"enable,omitempty"`
	LogLevelIn                       string `json:"log_level_in,omitempty"`
	LogLevelOut                      string `json:"log_level_out,omitempty"`
	LogNfConntrack                   bool   `json:"log_nf_conntrack,omitempty"`
	Ntp                              bool   `json:"ntp,omitempty"`
	NFConntrackAllowInvalid          bool   `json:"nf_conntrack_allow_invalid,omitempty"`
	NFConntrackMax                   int    `json:"nf_conntrack_max,omitempty"`
	NFConntrackTCPTimeoutEstablished int    `json:"nf_conntrack_tcp_timeout_established,omitempty"`
	NFConntrackTCPTimeoutSynRecv     int    `json:"nf_conntrack_tcp_timeout_syn_recv,omitempty"`
	Nosmurfs                         bool   `json:"nosmurfs,omitempty"`
	ProtectionSynflood               bool   `json:"protection_synflood,omitempty"`
	ProtectionSynfloodBurst          int    `json:"protection_synflood_burst,omitempty"`
	ProtectionSynfloodRate           int    `json:"protection_synflood_rate,omitempty"`
	SmurfLogLevel                    string `json:"smurf_log_level,omitempty"`
	TCPFlagsLogLevel                 string `json:"tcp_flags_log_level,omitempty"`
	TCPflags                         bool   `json:"tcpflags,omitempty"`
}

type FirewallRule

type FirewallRule struct {
	Type     string `json:"type,omitempty"`
	Action   string `json:"action,omitempty"`
	Pos      int    `json:"pos,omitempty"`
	Comment  string `json:"comment,omitempty"`
	Dest     string `json:"dest,omitempty"`
	Dport    string `json:"dport,omitempty"`
	Enable   int    `json:"enable,omitempty"`
	IcmpType string `json:"icmp_type,omitempty"`
	Iface    string `json:"iface,omitempty"`
	Log      string `json:"log,omitempty"`
	Macro    string `json:"macro,omitempty"`
	Proto    string `json:"proto,omitempty"`
	Source   string `json:"source,omitempty"`
	Sport    string `json:"sport,omitempty"`
}

func (*FirewallRule) IsEnable

func (r *FirewallRule) IsEnable() bool

type FirewallSecurityGroup

type FirewallSecurityGroup struct {
	Group   string          `json:"group,omitempty"`
	Comment string          `json:"comment,omitempty"`
	Rules   []*FirewallRule `json:"rules,omitempty"`
	// contains filtered or unexported fields
}

func (*FirewallSecurityGroup) Delete

func (g *FirewallSecurityGroup) Delete(ctx context.Context) error

func (*FirewallSecurityGroup) GetRules

func (g *FirewallSecurityGroup) GetRules(ctx context.Context) ([]*FirewallRule, error)

func (*FirewallSecurityGroup) RuleCreate

func (g *FirewallSecurityGroup) RuleCreate(ctx context.Context, rule *FirewallRule) error

func (*FirewallSecurityGroup) RuleDelete

func (g *FirewallSecurityGroup) RuleDelete(ctx context.Context, rulePos int) error

func (*FirewallSecurityGroup) RuleUpdate

func (g *FirewallSecurityGroup) RuleUpdate(ctx context.Context, rule *FirewallRule) error

type FirewallVirtualMachineOption

type FirewallVirtualMachineOption struct {
	Enable      bool   `json:"enable,omitempty"`
	Dhcp        bool   `json:"dhcp,omitempty"`
	Ipfilter    bool   `json:"ipfilter,omitempty"`
	LogLevelIn  string `json:"log_level_in,omitempty"`
	LogLevelOut string `json:"log_level_out,omitempty"`
	Macfilter   bool   `json:"macfilter,omitempty"`
	Ntp         bool   `json:"ntp,omitempty"`
	PolicyIn    string `json:"policy_in,omitempty"`
	PolicyOut   string `json:"policy_out,omitempty"`
	Radv        bool   `json:"radv,omitempty"`
}

type Group

type Group struct {
	GroupID string   `json:"groupid,omitempty"`
	Comment string   `json:"comment,omitempty"`
	Users   string   `json:"users,omitempty"`   // only populated via Groups lister
	Members []string `json:"members,omitempty"` // only populated via Group read
	// contains filtered or unexported fields
}

func (*Group) Delete

func (g *Group) Delete(ctx context.Context) error

func (*Group) Update

func (g *Group) Update(ctx context.Context) error

type Groups

type Groups []*Group

type HA

type HA struct {
	Managed int
}

type ISO

type ISO struct{ Content }

func (*ISO) Delete

func (i *ISO) Delete(ctx context.Context) (*Task, error)

type ISOs

type ISOs []*ISO

type IntOrBool

type IntOrBool bool

func (*IntOrBool) MarshalJSON

func (b *IntOrBool) MarshalJSON() ([]byte, error)

func (*IntOrBool) UnmarshalJSON

func (b *IntOrBool) UnmarshalJSON(i []byte) error

type IsTemplate

type IsTemplate bool

func (*IsTemplate) UnmarshalJSON

func (it *IsTemplate) UnmarshalJSON(b []byte) error

type Ksm

type Ksm struct {
	Shared int64
}

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 LeveledLoggerInterface interface {
	Debugf(format string, v ...interface{})
	Errorf(format string, v ...interface{})
	Infof(format string, v ...interface{})
	Warnf(format string, v ...interface{})
}

type Log

type Log map[int]string

func (*Log) UnmarshalJSON

func (l *Log) UnmarshalJSON(b []byte) error

line numbers in the response start a 1 but the start param indexes from 0 so converting to that

type Memory

type Memory struct {
	Used  uint64
	Free  uint64
	Total uint64
}

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(ctx context.Context) (appliances Appliances, err error)

func (*Node) Container

func (n *Node) Container(ctx context.Context, vmid int) (*Container, error)

func (*Node) Containers

func (n *Node) Containers(ctx context.Context) (c Containers, err error)

func (*Node) DownloadAppliance

func (n *Node) DownloadAppliance(ctx context.Context, template, storage string) (ret string, err error)

func (*Node) FirewallGetRules

func (n *Node) FirewallGetRules(ctx context.Context) (rules []*FirewallRule, err error)

func (*Node) FirewallOptionGet

func (n *Node) FirewallOptionGet(ctx context.Context) (firewallOption *FirewallNodeOption, err error)

func (*Node) FirewallOptionSet

func (n *Node) FirewallOptionSet(ctx context.Context, firewallOption *FirewallNodeOption) error

func (*Node) FirewallRulesCreate

func (n *Node) FirewallRulesCreate(ctx context.Context, rule *FirewallRule) error

func (*Node) FirewallRulesDelete

func (n *Node) FirewallRulesDelete(ctx context.Context, rulePos int) error

func (*Node) FirewallRulesUpdate

func (n *Node) FirewallRulesUpdate(ctx context.Context, rule *FirewallRule) error

func (*Node) Network

func (n *Node) Network(ctx context.Context, iface string) (network *NodeNetwork, err error)

func (*Node) NetworkReload

func (n *Node) NetworkReload(ctx context.Context) (*Task, error)

func (*Node) Networks

func (n *Node) Networks(ctx context.Context) (networks NodeNetworks, err error)

func (*Node) NewNetwork

func (n *Node) NewNetwork(ctx context.Context, network *NodeNetwork) (task *Task, err error)

func (*Node) NewVirtualMachine

func (n *Node) NewVirtualMachine(ctx context.Context, vmid int, options ...VirtualMachineOption) (*Task, error)

func (*Node) Storage

func (n *Node) Storage(ctx context.Context, name string) (storage *Storage, err error)

func (*Node) StorageBackup

func (n *Node) StorageBackup(ctx context.Context) (*Storage, error)

func (*Node) StorageISO

func (n *Node) StorageISO(ctx context.Context) (*Storage, error)

func (*Node) StorageImages

func (n *Node) StorageImages(ctx context.Context) (*Storage, error)

func (*Node) StorageRootDir

func (n *Node) StorageRootDir(ctx context.Context) (*Storage, error)

func (*Node) StorageVZTmpl

func (n *Node) StorageVZTmpl(ctx context.Context) (*Storage, error)

func (*Node) Storages

func (n *Node) Storages(ctx context.Context) (storages Storages, err error)

func (*Node) TermProxy

func (n *Node) TermProxy(ctx context.Context) (vnc *VNC, err error)

func (*Node) VNCWebSocket

func (n *Node) VNCWebSocket(vnc *VNC) (chan string, chan string, chan error, func() error, error)

VNCWebSocket send, recv, errors, closer, error

func (*Node) Version

func (n *Node) Version(ctx context.Context) (version *Version, err error)

func (*Node) VirtualMachine

func (n *Node) VirtualMachine(ctx context.Context, vmid int) (*VirtualMachine, error)

func (*Node) VirtualMachines

func (n *Node) VirtualMachines(ctx context.Context) (vms VirtualMachines, err error)

func (*Node) VzTmpl

func (n *Node) VzTmpl(ctx context.Context, template, storage string) (*VzTmpl, error)

func (*Node) VzTmpls

func (n *Node) VzTmpls(ctx context.Context, storage string) (templates VzTmpls, err error)

type NodeNetwork

type NodeNetwork struct {
	Node    string `json:"-"`
	NodeAPI *Node  `json:"-"`

	Iface     string `json:"iface,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"`
	MTU                string `json:"mtu,omitempty"`
	Netmask            string `json:"netmask,omitempty"`
	Netmask6           string `json:"netmask6,omitempty"`
	VLANID             string `json:"vlan-id,omitempty"`
	VLANRawDevice      string `json:"vlan-raw-device,omitempty"`
	BridgeVLANAware    int    `json:"bridge_vlan_aware,omitempty"`
	BridgePorts        string `json:"bridge_ports,omitempty"`
	BridgeStp          string `json:"bridge_stp,omitempty"` // not in current docs, deprecated?
	BridgeFd           string `json:"bridge_fd,omitempty"`  // not in current docs, deprecated?
	Comments           string `json:"comments,omitempty"`
	Comments6          string `json:"comments6,omitempty"`
	BondPrimary        string `json:"bond-primary,omitempty"`
	BondMode           string `json:"bond_mode,omitempty"`
	BondXmit           string `json:"bond_xmit,omitempty"`
	BondXmitHashPolicy string `json:"bond_xmit_hash_policy,omitempty"`

	OVSBonds   string `json:"ovs_bonds,omitempty"`
	OVSBridge  string `json:"ovs_bridge,omitempty"`
	OVSOptions string `json:"ovs_options,omitempty"`
	OVSPorts   string `json:"ovs_ports,omitempty"`
	OVSTags    string `json:"ovs_tag,omitempty"`

	Slaves   string `json:"slaves,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(ctx context.Context) (task *Task, err error)

func (*NodeNetwork) Update

func (nw *NodeNetwork) Update(ctx context.Context) 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"`
	Type           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"`
	Uptime         uint64  `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 Option

type Option func(*Client)

func WithAPIToken

func WithAPIToken(tokenID, secret string) Option

func WithClient deprecated

func WithClient(client *http.Client) Option

Deprecated: Use WithHTTPClient

func WithCredentials

func WithCredentials(credentials *Credentials) Option

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

func WithLogger

func WithLogger(logger LeveledLoggerInterface) Option

func WithLogins deprecated

func WithLogins(username, password string) Option

Deprecated: Use WithCredential

func WithSession

func WithSession(ticket, CSRFPreventionToken string) Option

WithSession experimental

func WithUserAgent

func WithUserAgent(ua string) Option

type Permission

type Permission map[string]IntOrBool

type Permissions

type Permissions map[string]Permission

type PermissionsOptions

type PermissionsOptions struct {
	Path   string // path to limit the return e.g. / or /nodes
	UserID string // username e.g. root@pam or token
}

type Pool

type Pool struct {
	PoolID  string            `json:"poolid,omitempty"`
	Comment string            `json:"comment,omitempty"`
	Members []ClusterResource `json:"members,omitempty"`
	// contains filtered or unexported fields
}

func (*Pool) Delete

func (p *Pool) Delete(ctx context.Context) error

func (*Pool) Update

func (p *Pool) Update(ctx context.Context, opt *PoolUpdateOption) error

type PoolUpdateOption

type PoolUpdateOption struct {
	Comment string `json:"comment,omitempty"`
	// Delete objects rather than adding them
	Delete bool `json:"delete,omitempty"`
	// Comma separated lists of Storage names to add/delete to the pool
	Storage string `json:"storage,omitempty"`
	// Comma separated lists of Virtual Machine IDs to add/delete to the pool
	VirtualMachines string `json:"vms,omitempty"`
}

type Pools

type Pools []*Pool

type RRDData

type RRDData struct {
	MaxCPU  int
	MaxMem  uint64
	Disk    int
	MaxDisk uint64
	Time    uint64
}

type Role

type Role struct {
	RoleID  string    `json:"roleid,omitempty"`
	Privs   string    `json:"privs,omitempty"`
	Special IntOrBool `json:"special,omitempty"`
	// contains filtered or unexported fields
}

func (*Role) Delete

func (r *Role) Delete(ctx context.Context) error

func (*Role) Update

func (r *Role) Update(ctx context.Context) error

type Roles

type Roles []*Role

type RootFS

type RootFS struct {
	Avail uint64
	Total uint64
	Free  uint64
	Used  uint64
}

type Session

type Session struct {
	Username            string `json:"username"`
	CSRFPreventionToken string `json:"CSRFPreventionToken,omitempty"`

	// Cap is being returned but not documented in the API docs, likely will get rewritten later with better types
	Cap         map[string]map[string]int `json:"cap,omitempty"`
	ClusterName string                    `json:"clustername,omitempty"`
	Ticket      string                    `json:"ticket,omitempty"`
}

type Snapshot

type Snapshot struct {
	Name        string
	Vmstate     int
	Description string
	Snaptime    int64
	Parent      string
	Snapstate   string
}

type Storage

type Storage struct {
	Node         string
	Name         string `json:"storage"`
	Enabled      int
	UsedFraction float64 `json:"used_fraction"`
	Active       int
	Content      string
	Shared       int
	Avail        uint64
	Type         string
	Used         uint64
	Total        uint64
	Storage      string
	// contains filtered or unexported fields
}

func (*Storage) Backup

func (s *Storage) Backup(ctx context.Context, name string) (backup *Backup, err error)

func (*Storage) DownloadURL

func (s *Storage) DownloadURL(ctx context.Context, content, filename, url string) (*Task, error)

func (*Storage) DownloadURLWithHash

func (s *Storage) DownloadURLWithHash(ctx context.Context, content, filename, url string, checksum, checksumAlgorithm string) (*Task, error)

func (*Storage) ISO

func (s *Storage) ISO(ctx context.Context, name string) (iso *ISO, err error)

func (*Storage) Upload

func (s *Storage) Upload(content, file string) (*Task, error)

func (*Storage) UploadWithHash

func (s *Storage) UploadWithHash(content, file string, storageFilename *string, checksum, checksumAlgorithm string) (*Task, error)

func (*Storage) UploadWithName

func (s *Storage) UploadWithName(content, file string, storageFilename string) (*Task, error)

func (*Storage) VzTmpl

func (s *Storage) VzTmpl(ctx context.Context, name string) (vztmpl *VzTmpl, err error)

type Storages

type Storages []*Storage

type StringOrFloat64

type StringOrFloat64 float64

func (*StringOrFloat64) UnmarshalJSON

func (d *StringOrFloat64) UnmarshalJSON(b []byte) error

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 NewTask

func NewTask(upid UPID, client *Client) *Task

func (*Task) Log

func (t *Task) Log(ctx context.Context, start, limit int) (l Log, err error)

func (*Task) Ping

func (t *Task) Ping(ctx context.Context) error

func (*Task) Stop

func (t *Task) Stop(ctx context.Context) error

func (*Task) UnmarshalJSON

func (t *Task) UnmarshalJSON(b []byte) error

func (*Task) Wait

func (t *Task) Wait(ctx context.Context, interval, max time.Duration) error

func (*Task) WaitFor

func (t *Task) WaitFor(ctx context.Context, seconds int) error

func (*Task) WaitForCompleteStatus

func (t *Task) WaitForCompleteStatus(ctx context.Context, timesNum int, steps ...int) (status bool, completed bool, err error)

func (*Task) Watch

func (t *Task) Watch(ctx context.Context, start int) (chan string, error)

type Tasks

type Tasks []*Tasks

type Time

type Time struct {
	Timezone  string
	Time      uint64
	Localtime uint64
}

type Timeframe

type Timeframe string

type Token

type Token struct {
	TokenID string    `json:"tokenid,omitempty"`
	Comment string    `json:"comment,omitempty"`
	Expire  int       `json:"expire,omitempty"`
	Privsep IntOrBool `json:"privsep,omitempty"`
}

type Tokens

type Tokens []*Token

type UPID

type UPID string

type User

type User struct {
	UserID         string           `json:"userid,omitempty"`
	Comment        string           `json:"comment,omitempty"`
	Email          string           `json:"email,omitempty"`
	Enable         IntOrBool        `json:"enable,omitempty"`
	Expire         int              `json:"expire,omitempty"`
	Firstname      string           `json:"firstname,omitempty"`
	Lastname       string           `json:"lastname,omitempty"`
	Groups         []string         `json:"groups,omitempty"`
	Keys           string           `json:"keys,omitempty"`
	Tokens         map[string]Token `json:"tokens,omitempty"`
	RealmType      string           `json:"realm-type,omitempty"`
	TFALockedUntil string           `json:"tfa-locked-until,omitempty"`
	TOTPLocked     IntOrBool        `json:"totp-locked,omitempty"`
	// contains filtered or unexported fields
}

func (*User) Delete

func (u *User) Delete(ctx context.Context) error

func (*User) Update

func (u *User) Update(ctx context.Context) error

type Users

type Users []*User

type VNC

type VNC struct {
	Cert   string
	Port   StringOrInt
	Ticket string
	UPID   string
	User   string
}

type Version

type Version struct {
	Release string `json:"release"`
	RepoID  string `json:"repoid"`
	Version string `json:"version"`
}

type VirtualMachine

type VirtualMachine struct {
	VirtualMachineConfig *VirtualMachineConfig

	Name string
	Node string

	Agent          IntOrBool
	NetIn          uint64
	CPUs           int
	DiskWrite      uint64
	Status         string
	Lock           string `json:",omitempty"`
	VMID           StringOrUint64
	PID            StringOrUint64
	Netout         uint64
	Disk           uint64
	Mem            uint64
	CPU            float64
	MaxMem         uint64
	MaxDisk        uint64
	DiskRead       uint64
	QMPStatus      string `json:"qmpstatus,omitempty"`
	RunningMachine string `json:"running-machine,omitempty"`
	RunningQemu    string `json:"running-qemu,omitempty"`
	Tags           string `json:"tags,omitempty"`
	Uptime         uint64
	Template       IsTemplate // empty str if a vm, int 1 if a template
	HA             HA         `json:",omitempty"`
	// contains filtered or unexported fields
}

func (*VirtualMachine) AddTag

func (v *VirtualMachine) AddTag(ctx context.Context, value string) (*Task, error)

func (*VirtualMachine) AgentExec

func (v *VirtualMachine) AgentExec(ctx context.Context, command, inputData string) (pid int, err error)

func (*VirtualMachine) AgentExecStatus

func (v *VirtualMachine) AgentExecStatus(ctx context.Context, pid int) (status *AgentExecStatus, err error)

func (*VirtualMachine) AgentGetNetworkIFaces

func (v *VirtualMachine) AgentGetNetworkIFaces(ctx context.Context) (iFaces []*AgentNetworkIface, err error)

func (*VirtualMachine) AgentOsInfo

func (v *VirtualMachine) AgentOsInfo(ctx context.Context) (info *AgentOsInfo, err error)

func (*VirtualMachine) AgentSetUserPassword

func (v *VirtualMachine) AgentSetUserPassword(ctx context.Context, password string, username string) error

func (*VirtualMachine) Clone

func (v *VirtualMachine) Clone(ctx context.Context, params *VirtualMachineCloneOptions) (newid int, task *Task, err error)

func (*VirtualMachine) CloudInit

func (v *VirtualMachine) CloudInit(ctx context.Context, device, userdata, metadata, vendordata, networkconfig string) error

CloudInit takes four yaml docs as a string and make an ISO, upload it to the data store as <vmid>-user-data.iso and will mount it as a CD-ROM to be used with nocloud cloud-init. This is NOT how proxmox expects a user to do cloud-init which can be found here: https://pve.proxmox.com/wiki/Cloud-Init_Support#:~:text=and%20meta.-,Cloud%2DInit%20specific%20Options,-cicustom%3A%20%5Bmeta If you want to use the proxmox implementation you'll need to use the cloudinit APIs https://pve.proxmox.com/pve-docs/api-viewer/index.html#/nodes/{node}/qemu/{vmid}/cloudinit

func (*VirtualMachine) Config

func (v *VirtualMachine) Config(ctx context.Context, options ...VirtualMachineOption) (*Task, error)

func (*VirtualMachine) Delete

func (v *VirtualMachine) Delete(ctx context.Context) (task *Task, err error)

func (*VirtualMachine) FirewallGetRules

func (v *VirtualMachine) FirewallGetRules(ctx context.Context) (rules []*FirewallRule, err error)

func (*VirtualMachine) FirewallOptionGet

func (v *VirtualMachine) FirewallOptionGet(ctx context.Context) (firewallOption *FirewallVirtualMachineOption, err error)

func (*VirtualMachine) FirewallOptionSet

func (v *VirtualMachine) FirewallOptionSet(ctx context.Context, firewallOption *FirewallVirtualMachineOption) error

func (*VirtualMachine) FirewallRulesCreate

func (v *VirtualMachine) FirewallRulesCreate(ctx context.Context, rule *FirewallRule) error

func (*VirtualMachine) FirewallRulesDelete

func (v *VirtualMachine) FirewallRulesDelete(ctx context.Context, rulePos int) error

func (*VirtualMachine) FirewallRulesUpdate

func (v *VirtualMachine) FirewallRulesUpdate(ctx context.Context, rule *FirewallRule) error

func (*VirtualMachine) HasTag

func (v *VirtualMachine) HasTag(value string) bool

func (*VirtualMachine) Hibernate

func (v *VirtualMachine) Hibernate(ctx context.Context) (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) Migrate

func (v *VirtualMachine) Migrate(
	ctx context.Context,
	params *VirtualMachineMigrateOptions,
) (task *Task, err error)

func (*VirtualMachine) MoveDisk

func (v *VirtualMachine) MoveDisk(ctx context.Context, disk string, params *VirtualMachineMoveDiskOptions) (task *Task, err error)

func (*VirtualMachine) NewSnapshot

func (v *VirtualMachine) NewSnapshot(ctx context.Context, name string) (task *Task, err error)

func (*VirtualMachine) Pause

func (v *VirtualMachine) Pause(ctx context.Context) (task *Task, err error)

func (*VirtualMachine) Ping

func (v *VirtualMachine) Ping(ctx context.Context) error

func (*VirtualMachine) RRDData

func (v *VirtualMachine) RRDData(ctx context.Context, timeframe Timeframe, consolidationFunction ...ConsolidationFunction) (rrddata []*RRDData, err error)

RRDData takes a timeframe enum and an optional consolidation function usage: vm.RRDData(HOURLY) or vm.RRDData(HOURLY, AVERAGE)

func (*VirtualMachine) Reboot

func (v *VirtualMachine) Reboot(ctx context.Context) (task *Task, err error)

func (*VirtualMachine) RemoveTag

func (v *VirtualMachine) RemoveTag(ctx context.Context, value string) (*Task, error)

func (*VirtualMachine) Reset

func (v *VirtualMachine) Reset(ctx context.Context) (task *Task, err error)

func (*VirtualMachine) ResizeDisk

func (v *VirtualMachine) ResizeDisk(ctx context.Context, disk, size string) (err error)

func (*VirtualMachine) Resume

func (v *VirtualMachine) Resume(ctx context.Context) (task *Task, err error)

func (*VirtualMachine) Shutdown

func (v *VirtualMachine) Shutdown(ctx context.Context) (task *Task, err error)

func (*VirtualMachine) SnapshotRollback

func (v *VirtualMachine) SnapshotRollback(ctx context.Context, name string) (task *Task, err error)

func (*VirtualMachine) Snapshots

func (v *VirtualMachine) Snapshots(ctx context.Context) (snapshots []*Snapshot, err error)

func (*VirtualMachine) SplitTags

func (v *VirtualMachine) SplitTags()

func (*VirtualMachine) Start

func (v *VirtualMachine) Start(ctx context.Context) (task *Task, err error)

func (*VirtualMachine) Stop

func (v *VirtualMachine) Stop(ctx context.Context) (task *Task, err error)

func (*VirtualMachine) TermProxy

func (v *VirtualMachine) TermProxy(ctx context.Context) (vnc *VNC, err error)

func (*VirtualMachine) UnlinkDisk

func (v *VirtualMachine) UnlinkDisk(ctx context.Context, diskID string, force bool) (task *Task, err error)

func (*VirtualMachine) VNCProxy

func (v *VirtualMachine) VNCProxy(ctx context.Context) (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 set up a serial terminal on your vm https://pve.proxmox.com/wiki/Serial_Terminal

func (*VirtualMachine) WaitForAgent

func (v *VirtualMachine) WaitForAgent(ctx context.Context, seconds int) error

func (*VirtualMachine) WaitForAgentExecExit

func (v *VirtualMachine) WaitForAgentExecExit(ctx context.Context, pid, seconds int) (*AgentExecStatus, error)

type VirtualMachineCloneOptions

type VirtualMachineCloneOptions struct {
	NewID       int    `json:"newid"`
	BWLimit     uint64 `json:"bwlimit,omitempty"`
	Description string `json:"description,omitempty"`
	Format      string `json:"format,omitempty"`
	Full        uint8  `json:"full,omitempty"`
	Name        string `json:"name,omitempty"`
	Pool        string `json:"pool,omitempty"`
	SnapName    string `json:"snapname,omitempty"`
	Storage     string `json:"storage,omitempty"`
	Target      string `json:"target,omitempty"`
}

type VirtualMachineConfig

type VirtualMachineConfig struct {
	// PVE Metadata
	Digest      string `json:"digest"`
	Name        string `json:"name,omitempty"`
	Description string `json:"description,omitempty"`
	Meta        string `json:"meta,omitempty"`
	VMGenID     string `json:"vmgenid,omitempty"`
	Hookscript  string `json:"hookscript,omitempty"`
	Hotplug     string `json:"hotplug,omitempty"`
	Template    int    `json:"template,omitempty"`
	Agent       string `json:"agent,omitempty"`
	Autostart   int    `json:"autostart,omitempty"`
	Tablet      int    `json:"tablet,omitempty"`
	KVM         int    `json:"kvm,omitempty"`

	Tags      string   `json:"tags,omitempty"`
	TagsSlice []string `json:"-"` // internal helper to manage tags easier

	Protection int    `json:"protection,omitempty"`
	Lock       string `json:"lock,omitempty"`

	// Boot configuration
	Boot   string `json:"boot,omitempty"`
	OnBoot int    `json:"onboot,omitempty"`

	// Qemu general specs
	OSType  string `json:"ostype,omitempty"`
	Machine string `json:"machine,omitempty"`
	Args    string `json:"args,omitempty"`

	// Qemu firmware specs
	Bios     string `json:"bios,omitempty"`
	EFIDisk0 string `json:"efidisk0,omitempty"`
	SMBios1  string `json:"smbios1,omitempty"`
	Acpi     int    `json:"acpi,omitempty"`

	// Qemu CPU specs
	Sockets  int             `json:"sockets,omitempty"`
	Cores    int             `json:"cores,omitempty"`
	CPU      string          `json:"cpu,omitempty"`
	CPULimit StringOrFloat64 `json:"cpulimit,omitempty"`
	CPUUnits int             `json:"cpuunits,omitempty"`
	Vcpus    int             `json:"vcpus,omitempty"`
	Affinity string          `json:"affinity,omitempty"`

	// Qemu memory specs
	Numa      int         `json:"numa,omitempty"`
	Memory    StringOrInt `json:"memory,omitempty"` // See commit 7f8c808772979f274cdfac1dc7264771a3b7a7ae on qemu-server
	Hugepages string      `json:"hugepages,omitempty"`
	Balloon   int         `json:"balloon,omitempty"`

	// Other Qemu devices
	VGA       string `json:"vga,omitempty"`
	SCSIHW    string `json:"scsihw,omitempty"`
	TPMState0 string `json:"tpmstate0,omitempty"`
	Rng0      string `json:"rng0,omitempty"`
	Audio0    string `json:"audio0,omitempty"`

	// Disk devices
	IDEs map[string]string `json:"-"`
	IDE0 string            `json:"ide0,omitempty"`
	IDE1 string            `json:"ide1,omitempty"`
	IDE2 string            `json:"ide2,omitempty"`
	IDE3 string            `json:"ide3,omitempty"`

	SCSIs  map[string]string `json:"-"`
	SCSI0  string            `json:"scsi0,omitempty"`
	SCSI1  string            `json:"scsi1,omitempty"`
	SCSI2  string            `json:"scsi2,omitempty"`
	SCSI3  string            `json:"scsi3,omitempty"`
	SCSI4  string            `json:"scsi4,omitempty"`
	SCSI5  string            `json:"scsi5,omitempty"`
	SCSI6  string            `json:"scsi6,omitempty"`
	SCSI7  string            `json:"scsi7,omitempty"`
	SCSI8  string            `json:"scsi8,omitempty"`
	SCSI9  string            `json:"scsi9,omitempty"`
	SCSI10 string            `json:"scsi10,omitempty"`
	SCSI11 string            `json:"scsi11,omitempty"`
	SCSI12 string            `json:"scsi12,omitempty"`
	SCSI13 string            `json:"scsi13,omitempty"`
	SCSI14 string            `json:"scsi14,omitempty"`
	SCSI15 string            `json:"scsi15,omitempty"`
	SCSI16 string            `json:"scsi16,omitempty"`
	SCSI17 string            `json:"scsi17,omitempty"`
	SCSI18 string            `json:"scsi18,omitempty"`
	SCSI19 string            `json:"scsi19,omitempty"`
	SCSI20 string            `json:"scsi20,omitempty"`
	SCSI21 string            `json:"scsi21,omitempty"`
	SCSI22 string            `json:"scsi22,omitempty"`
	SCSI23 string            `json:"scsi23,omitempty"`
	SCSI24 string            `json:"scsi24,omitempty"`
	SCSI25 string            `json:"scsi25,omitempty"`
	SCSI26 string            `json:"scsi26,omitempty"`
	SCSI27 string            `json:"scsi27,omitempty"`
	SCSI28 string            `json:"scsi28,omitempty"`
	SCSI29 string            `json:"scsi29,omitempty"`
	SCSI30 string            `json:"scsi30,omitempty"`

	SATAs map[string]string `json:"-"`
	SATA0 string            `json:"sata0,omitempty"`
	SATA1 string            `json:"sata1,omitempty"`
	SATA2 string            `json:"sata2,omitempty"`
	SATA3 string            `json:"sata3,omitempty"`
	SATA4 string            `json:"sata4,omitempty"`
	SATA5 string            `json:"sata5,omitempty"`

	VirtIOs  map[string]string `json:"-"`
	VirtIO0  string            `json:"virtio0,omitempty"`
	VirtIO1  string            `json:"virtio1,omitempty"`
	VirtIO2  string            `json:"virtio2,omitempty"`
	VirtIO3  string            `json:"virtio3,omitempty"`
	VirtIO4  string            `json:"virtio4,omitempty"`
	VirtIO5  string            `json:"virtio5,omitempty"`
	VirtIO6  string            `json:"virtio6,omitempty"`
	VirtIO7  string            `json:"virtio7,omitempty"`
	VirtIO8  string            `json:"virtio8,omitempty"`
	VirtIO9  string            `json:"virtio9,omitempty"`
	VirtIO10 string            `json:"virtio10,omitempty"`
	VirtIO11 string            `json:"virtio11,omitempty"`
	VirtIO12 string            `json:"virtio12,omitempty"`
	VirtIO13 string            `json:"virtio13,omitempty"`
	VirtIO14 string            `json:"virtio14,omitempty"`
	VirtIO15 string            `json:"virtio15,omitempty"`

	Unuseds map[string]string `json:"-"`
	Unused0 string            `json:"unused0,omitempty"`
	Unused1 string            `json:"unused1,omitempty"`
	Unused2 string            `json:"unused2,omitempty"`
	Unused3 string            `json:"unused3,omitempty"`
	Unused4 string            `json:"unused4,omitempty"`
	Unused5 string            `json:"unused5,omitempty"`
	Unused6 string            `json:"unused6,omitempty"`
	Unused7 string            `json:"unused7,omitempty"`
	Unused8 string            `json:"unused8,omitempty"`
	Unused9 string            `json:"unused9,omitempty"`

	// Network devices
	Nets map[string]string `json:"-"`
	Net0 string            `json:"net0,omitempty"`
	Net1 string            `json:"net1,omitempty"`
	Net2 string            `json:"net2,omitempty"`
	Net3 string            `json:"net3,omitempty"`
	Net4 string            `json:"net4,omitempty"`
	Net5 string            `json:"net5,omitempty"`
	Net6 string            `json:"net6,omitempty"`
	Net7 string            `json:"net7,omitempty"`
	Net8 string            `json:"net8,omitempty"`
	Net9 string            `json:"net9,omitempty"`

	// NUMA topology
	Numas map[string]string `json:"-"`
	Numa0 string            `json:"numa0,omitempty"`
	Numa1 string            `json:"numa1,omitempty"`
	Numa2 string            `json:"numa2,omitempty"`
	Numa3 string            `json:"numa3,omitempty"`
	Numa4 string            `json:"numa4,omitempty"`
	Numa5 string            `json:"numa5,omitempty"`
	Numa6 string            `json:"numa6,omitempty"`
	Numa7 string            `json:"numa7,omitempty"`
	Numa8 string            `json:"numa8,omitempty"`
	Numa9 string            `json:"numa9,omitempty"`

	// Host PCI devices
	HostPCIs map[string]string `json:"-"`
	HostPCI0 string            `json:"hostpci0,omitempty"`
	HostPCI1 string            `json:"hostpci1,omitempty"`
	HostPCI2 string            `json:"hostpci2,omitempty"`
	HostPCI3 string            `json:"hostpci3,omitempty"`
	HostPCI4 string            `json:"hostpci4,omitempty"`
	HostPCI5 string            `json:"hostpci5,omitempty"`
	HostPCI6 string            `json:"hostpci6,omitempty"`
	HostPCI7 string            `json:"hostpci7,omitempty"`
	HostPCI8 string            `json:"hostpci8,omitempty"`
	HostPCI9 string            `json:"hostpci9,omitempty"`

	// Serial devices
	Serials map[string]string `json:"-"`
	Serial0 string            `json:"serial0,omitempty"`
	Serial1 string            `json:"serial1,omitempty"`
	Serial2 string            `json:"serial2,omitempty"`
	Serial3 string            `json:"serial3,omitempty"`

	// USB devices
	USBs  map[string]string `json:"-"`
	USB0  string            `json:"usb0,omitempty"`
	USB1  string            `json:"usb1,omitempty"`
	USB2  string            `json:"usb2,omitempty"`
	USB3  string            `json:"usb3,omitempty"`
	USB4  string            `json:"usb4,omitempty"`
	USB5  string            `json:"usb5,omitempty"`
	USB6  string            `json:"usb6,omitempty"`
	USB7  string            `json:"usb7,omitempty"`
	USB8  string            `json:"usb8,omitempty"`
	USB9  string            `json:"usb9,omitempty"`
	USB10 string            `json:"usb10,omitempty"`
	USB11 string            `json:"usb11,omitempty"`
	USB12 string            `json:"usb12,omitempty"`
	USB13 string            `json:"usb13,omitempty"`
	USB14 string            `json:"usb14,omitempty"`

	// Parallel devices
	Parallels map[string]string `json:"-"`
	Parallel0 string            `json:"parallel0,omitempty"`
	Parallel1 string            `json:"parallel1,omitempty"`
	Parallel2 string            `json:"parallel2,omitempty"`

	// Cloud-init
	CIType       string `json:"citype,omitempty"`
	CIUser       string `json:"ciuser,omitempty"`
	CIPassword   string `json:"cipassword,omitempty"`
	Nameserver   string `json:"nameserver,omitempty"`
	Searchdomain string `json:"searchdomain,omitempty"`
	SSHKeys      string `json:"sshkeys,omitempty"`
	CICustom     string `json:"cicustom,omitempty"`

	// Cloud-init interfaces
	IPConfigs map[string]string `json:"-"`
	IPConfig0 string            `json:"ipconfig0,omitempty"`
	IPConfig1 string            `json:"ipconfig1,omitempty"`
	IPConfig2 string            `json:"ipconfig2,omitempty"`
	IPConfig3 string            `json:"ipconfig3,omitempty"`
	IPConfig4 string            `json:"ipconfig4,omitempty"`
	IPConfig5 string            `json:"ipconfig5,omitempty"`
	IPConfig6 string            `json:"ipconfig6,omitempty"`
	IPConfig7 string            `json:"ipconfig7,omitempty"`
	IPConfig8 string            `json:"ipconfig8,omitempty"`
	IPConfig9 string            `json:"ipconfig9,omitempty"`
}

func (*VirtualMachineConfig) MergeHostPCIs

func (vmc *VirtualMachineConfig) MergeHostPCIs() map[string]string

func (*VirtualMachineConfig) MergeIDEs

func (vmc *VirtualMachineConfig) MergeIDEs() map[string]string

func (*VirtualMachineConfig) MergeIPConfigs

func (vmc *VirtualMachineConfig) MergeIPConfigs() map[string]string

func (*VirtualMachineConfig) MergeNets

func (vmc *VirtualMachineConfig) MergeNets() map[string]string

func (*VirtualMachineConfig) MergeNumas

func (vmc *VirtualMachineConfig) MergeNumas() map[string]string

func (*VirtualMachineConfig) MergeParallels

func (vmc *VirtualMachineConfig) MergeParallels() 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) MergeSerials

func (vmc *VirtualMachineConfig) MergeSerials() map[string]string

func (*VirtualMachineConfig) MergeUSBs

func (vmc *VirtualMachineConfig) MergeUSBs() map[string]string

func (*VirtualMachineConfig) MergeUnuseds

func (vmc *VirtualMachineConfig) MergeUnuseds() map[string]string

func (*VirtualMachineConfig) MergeVirtIOs

func (vmc *VirtualMachineConfig) MergeVirtIOs() map[string]string

type VirtualMachineMigrateOptions

type VirtualMachineMigrateOptions struct {
	Target           string    `json:"target"`
	BWLimit          uint64    `json:"bwlimit,omitempty"`
	Force            IntOrBool `json:"force,omitempty"`
	MigrationNetwork string    `json:"migration_network,omitempty"`
	MigrationType    string    `json:"migration_type,omitempty"`
	Online           IntOrBool `json:"online,omitempty"`
	TargetStorage    string    `json:"targetstorage,omitempty"`
	WithLocalDisks   IntOrBool `json:"with-local-disks,omitempty"`
}

type VirtualMachineMoveDiskOptions

type VirtualMachineMoveDiskOptions struct {
	Disk         string `json:"disk"`
	BWLimit      uint64 `json:"bwlimit,omitempty"`
	Delete       uint8  `json:"delete,omitempty"`
	Digest       string `json:"digest,omitempty"`
	Format       string `json:"format,omitempty"`
	Storage      string `json:"storage,omitempty"`
	TargetDigest string `json:"target-digest,omitempty"`
	TargetDisk   string `json:"target-disk,omitempty"`
	TargetVMID   int    `json:"target-vmid,omitempty"`
}

type VirtualMachineOption

type VirtualMachineOption struct {
	Name  string
	Value interface{}
}

type VirtualMachineOptions

type VirtualMachineOptions []*VirtualMachineOption

VirtualMachineOptions A key/value pair used to modify a virtual machine config Refer to https://pve.proxmox.com/pve-docs/api-viewer/#/nodes/{node}/qemu/{vmid}/config for a list of valid values

type VirtualMachines

type VirtualMachines []*VirtualMachine

type Volume

type Volume interface {
	Delete() error
}

type VzTmpl

type VzTmpl struct{ Content }

func (*VzTmpl) Delete

func (v *VzTmpl) Delete(ctx context.Context) (*Task, error)

type VzTmpls

type VzTmpls []*VzTmpl

Directories

Path Synopsis
mage
tests

Jump to

Keyboard shortcuts

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