util

package
v0.0.0-...-f3737aa Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	VmFilter      = "vm"
	StorageFilter = "storage"
	NodeFilter    = "node"
	SdnFilter     = "sdn"
)
View Source
const (
	NodeResource    = "node"
	StorageResource = "storage"
	PoolResource    = "pool"
	QemuResource    = "qemu"
	LxcResource     = "lxc"
	OpenVzResource  = "openvz" // deprecated
	SdnResource     = "sdn"
)
View Source
const (
	RunningState = RequestableState(proxmox.StatusVirtualMachineRunning)
	StoppedState = RequestableState(proxmox.StatusVirtualMachineStopped)
	PausedState  = RequestableState(proxmox.StatusVirtualMachinePaused)
)
View Source
const (
	MaxVmid = 999999999
	MinVmid = 100
)
View Source
const ApiUrlSuffix = "/api2/json"

Variables

This section is empty.

Functions

func CheckVmidRange

func CheckVmidRange(vmid uint64) error

func DestroyVm

func DestroyVm(ctx context.Context, vm *proxmox.VirtualMachine) (proxmox.Task, error)

func DestroyVmWithForce

func DestroyVmWithForce(ctx context.Context, vm *proxmox.VirtualMachine) (proxmox.Task, error)

func GetPveUrl

func GetPveUrl(c *cli.Context) string

GetPveUrl returns either the URL as specified by the `pveurl` arg, or builds a URL from the `scheme`, `pvehost`, and `pveport` args.

func GetResourceList

func GetResourceList(
	ctx context.Context,
	client proxmox.Client,
	opts ...GetResourceListOption,
) (
	rsList []*proxmox.ClusterResource,
	err error,
)

func GetVirtualMachineByVMID

func GetVirtualMachineByVMID(ctx context.Context, vmid uint64, client proxmox.Client) (
	vm *proxmox.VirtualMachine,
	err error,
)

func GetVirtualMachineList

func GetVirtualMachineList(
	ctx context.Context,
	client proxmox.Client,
	furtherFilterList ...string,
) (vmList []proxmox.VirtualMachine, err error)

func GetVmidArg

func GetVmidArg(args []string) (uint64, error)

func InstantiateClient

func InstantiateClient(pveUrl string, credentials proxmox.Credentials) proxmox.Client

func RequestState

func RequestState(ctx context.Context, params StateRequestParams) (*proxmox.Task, error)

RequestState requests Proxmox change the state of a virtual machine.

func VmidOutOfRangeError

func VmidOutOfRangeError() error

Types

type GetResourceListOption

type GetResourceListOption func(c *getResourceListConfig)

GetResourceListOption specifies the type of Resources for GetResource to get.

func WithAll

func WithAll() GetResourceListOption

WithAll makes GetResourceList return VMs, Storage, Nodes, and SDNs.

func WithLxc

func WithLxc() GetResourceListOption

WithLxc further filters GetResourceList for Qemu VMs.

func WithNode

func WithNode() GetResourceListOption

WithNode makes GetResourceList return Nodes.

func WithPool

func WithPool() GetResourceListOption

WithPool further filters GetResourceList for Pools.

func WithQemu

func WithQemu() GetResourceListOption

WithQemu further filters GetResourceList for Qemu VMs.

func WithSdn

func WithSdn() GetResourceListOption

WithSdn makes GetResourceList return SDNs.

func WithStorage

func WithStorage() GetResourceListOption

WithStorage makes GetResourceList return Storages.

func WithVm

func WithVm() GetResourceListOption

WithVm makes GetResourceList return VMs.

type RequestableState

type RequestableState string

type ResourceList

type ResourceList struct {
	NodeResources    []*proxmox.Node
	StorageResources []*proxmox.Storage
	PoolResources    []*proxmox.Pool
	QemuResources    []*proxmox.VirtualMachine
	LxcResources     []*proxmox.Container
	OpenVzResources  []*proxmox.Container
}

type StateRequestParams

type StateRequestParams struct {
	RequestedState RequestableState
	Vm             *proxmox.VirtualMachine
}

Jump to

Keyboard shortcuts

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