Documentation
¶
Overview ¶
Package local drives a Proxmox VE hypervisor from the node itself: it reads /etc/pve directly and shells out to qm/pvesh/pvecm, as the on-node counterpart to github.com/sergelogvinov/go-proxmox-rest (the REST client).
See docs/design.md for the full design.
Index ¶
- Variables
- func IsLocked(err error) bool
- func IsNoQuorum(err error) bool
- func IsNotFound(err error) bool
- type Client
- func (c *Client) Cluster() *cluster.Client
- func (c *Client) ConfigDir() string
- func (c *Client) LXC() *lxc.Client
- func (c *Client) Qemu() *qemu.Client
- func (c *Client) Run(ctx context.Context, name string, args ...string) ([]byte, error)
- func (c *Client) RunDir() string
- func (c *Client) Storage() *storage.Client
- type CommandError
- type ConfigError
- type Logger
- type Option
- type Runner
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is returned when no guest config exists for the // requested id. ErrNotFound = errdefs.ErrNotFound // ErrNoQuorum is returned when the local cluster has no quorum. ErrNoQuorum = errdefs.ErrNoQuorum // ErrNotInstalled is returned when pvecm/pvesh/qm cannot be found on // this node. ErrNotInstalled = errdefs.ErrNotInstalled // ErrLocked is returned when qm reports the guest config is locked by // another operation; retryable. ErrLocked = errdefs.ErrLocked )
These are re-exports (the same values, not copies) of the sentinels internal/errdefs defines, so that an error returned by the cluster or qemu subpackages — which wrap errdefs' values directly, to avoid importing this package and cycling back — still satisfies errors.Is(err, local.ErrNotFound) etc. here.
Functions ¶
func IsLocked ¶
IsLocked reports whether err indicates a guest's config is locked by another operation; callers should retry with backoff.
func IsNoQuorum ¶
IsNoQuorum reports whether err indicates the local cluster has no quorum.
func IsNotFound ¶
IsNotFound reports whether err indicates that the requested guest was not found.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the entry point for driving a Proxmox VE hypervisor from the node itself. Obtain resource-scoped handles from its Qemu()/Cluster() methods; Client itself carries only the shared configuration and the command-execution seam (see Run, ConfigDir, RunDir), which the cluster and qemu subpackages consume through their own Env interfaces, so that neither needs to import this package (which would cycle back to them).
func New ¶
New returns a new Client. The default root is "/", i.e. this node's own filesystem; WithRoot points every path below it at an alternate root (a temp directory in tests).
func (*Client) ConfigDir ¶
ConfigDir returns the pmxcfs mount root (default "/etc/pve", or "<root>/etc/pve" under WithRoot).
func (*Client) Run ¶
Run executes a PVE CLI tool (pct, pvecm, pvesh, pvesm, or qm) through the configured Runner. It is exported so the cluster, qemu, lxc and storage subpackages can invoke it via their own Env interfaces without importing this package — see the package doc comment on Client.
type CommandError ¶
CommandError carries what a PVE CLI invocation actually did, for a command that exited non-zero.
func (*CommandError) Error ¶
func (e *CommandError) Error() string
Error implements the error interface.
type ConfigError ¶
ConfigError carries the file and line a config parse failed on.
func (*ConfigError) Error ¶
func (e *ConfigError) Error() string
Error implements the error interface.
func (*ConfigError) Unwrap ¶
func (e *ConfigError) Unwrap() error
Unwrap allows errors.Is/errors.As to see through a ConfigError to its underlying cause.
type Logger ¶
Logger is the minimal logging interface WithDryRun uses to report the argv it would have executed. *log.Logger satisfies it.
type Option ¶
type Option func(*config)
Option mutates a Client's construction-time configuration.
func WithConfigDir ¶
WithConfigDir overrides the pmxcfs mount root (default: "<root>/etc/pve").
func WithDryRun ¶
WithDryRun makes the default Runner log the argv it would have executed (via WithLogger) and return success without running anything, when dryRun is true — a root daemon's safety valve.
func WithLogger ¶
WithLogger sets the logger WithDryRun uses to report the argv it would have executed.
func WithRoot ¶
WithRoot points every default path (config dir, run dir) at root instead of "/" — e.g. WithRoot(t.TempDir()) in a test. It can be combined, in either order, with WithConfigDir/WithRunDir: an explicit directory always wins over the root-derived default.
func WithRunDir ¶
WithRunDir overrides the directory holding running guests' pid/vnc/qmp sockets (default: "<root>/run/qemu-server").
func WithRunner ¶
WithRunner overrides the default exec.CommandContext-based Runner — the seam a test's own double drives this library through, without a hypervisor.
func WithTimeout ¶
WithTimeout sets the default deadline applied to a call whose context carries none. Unset (the default), calls have no enforced timeout beyond whatever the caller's own context already carries.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cluster provides pmxcfs and cluster-scope operations: quorum state and the next available VM/CT id.
|
Package cluster provides pmxcfs and cluster-scope operations: quorum state and the next available VM/CT id. |
|
Package conf parses and formats the PVE section-config file format used by /etc/pve/qemu-server/<vmid>.conf (and its LXC/other counterparts): '#' description comment lines, "key: value" lines, a "[PENDING]" section, and "[<snapshot>]" sections.
|
Package conf parses and formats the PVE section-config file format used by /etc/pve/qemu-server/<vmid>.conf (and its LXC/other counterparts): '#' description comment lines, "key: value" lines, a "[PENDING]" section, and "[<snapshot>]" sections. |
|
Package fakelocal is the local counterpart to go-proxmox-rest's fakeapi: a public test double so a consumer of go-proxmox-local (cmd/proxmox-scheduler above all) can drive a full create-then-update reconcile against a *local.Client without a hypervisor.
|
Package fakelocal is the local counterpart to go-proxmox-rest's fakeapi: a public test double so a consumer of go-proxmox-local (cmd/proxmox-scheduler above all) can drive a full create-then-update reconcile against a *local.Client without a hypervisor. |
|
internal
|
|
|
errdefs
Package errdefs holds the sentinel errors shared by the local package and its cluster/qemu subpackages.
|
Package errdefs holds the sentinel errors shared by the local package and its cluster/qemu subpackages. |
|
params
Package params provides a reflection-based encoder/decoder that converts between option structs and the flat form parameters / JSON responses used by the Proxmox API.
|
Package params provides a reflection-based encoder/decoder that converts between option structs and the flat form parameters / JSON responses used by the Proxmox API. |
|
property
Package property converts Proxmox comma-separated property strings to and from tagged Go structs.
|
Package property converts Proxmox comma-separated property strings to and from tagged Go structs. |
|
Package lxc provides LXC container configuration read access and lifecycle operations (create/update/delete via `pct`) on the local hypervisor.
|
Package lxc provides LXC container configuration read access and lifecycle operations (create/update/delete via `pct`) on the local hypervisor. |
|
Package qemu provides QEMU guest configuration read access and lifecycle operations (create/update/delete via `qm`) on the local hypervisor.
|
Package qemu provides QEMU guest configuration read access and lifecycle operations (create/update/delete via `qm`) on the local hypervisor. |
|
Package storage provides local storage inspection via `pvesm`.
|
Package storage provides local storage inspection via `pvesm`. |