Documentation
¶
Overview ¶
Package api exposes VirtoMir's HTTP/JSON API (versioned under /api/v1) and serves the web UI.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface {
HostInfo() (virt.HostInfo, error)
ListDomains() ([]virt.Domain, error)
DomainDetail(uuid string) (virt.DomainDetail, error)
DomainXML(uuid string, inactive bool) (string, error)
DomainAction(uuid string, action virt.Action) error
CreateDomain(spec virt.CreateSpec) (virt.CreateResult, error)
DefineXML(uuid, xml string) (virt.DefineResult, error)
SetAutostart(uuid string, on bool) error
Rename(uuid, name string) error
Delete(uuid string, removeStorage bool) (virt.DeleteResult, error)
Clone(ctx context.Context, uuid, name string, report func(string)) (string, error)
ChangeMedia(uuid, target, source string) error
AttachDisk(uuid string, spec virt.DiskSpec) (string, error)
AttachInterface(uuid string, spec virt.NICSpec) error
DetachDevice(uuid string, ref virt.DeviceRef) (virt.DeviceResult, error)
ListSnapshots(uuid string) ([]virt.Snapshot, error)
CreateSnapshot(uuid string, spec virt.SnapshotSpec) (string, error)
RevertSnapshot(uuid, name string) error
DeleteSnapshot(uuid, name string) error
ListPools() ([]virt.Pool, error)
CreatePool(spec virt.PoolSpec) error
DeletePool(name string) error
PoolAction(name, action string) error
SetPoolAutostart(name string, on bool) error
ListVolumes(pool string) ([]virt.Volume, error)
CreateVolume(pool string, spec virt.VolumeSpec) (virt.Volume, error)
DeleteVolume(pool, name string) error
UploadVolume(ctx context.Context, pool, name string, size int64, r io.Reader) (virt.Volume, error)
ListNetworks() ([]virt.VNetwork, error)
CreateNetwork(spec virt.NetworkSpec) error
DeleteNetwork(name string) error
NetworkAction(name, action string) error
SetNetworkAutostart(name string, on bool) error
NetworkLeases(name string) ([]virt.Lease, error)
GetSettings(uuid string) (virt.SettingsView, error)
PreviewSettings(uuid string, s virt.Settings) (virt.Preview, error)
SaveSettings(uuid string, s virt.Settings) (virt.SaveResult, error)
ResizeDisk(uuid, target string, sizeGiB uint64) error
ResizeVolume(pool, name string, sizeGiB uint64) error
AddDHCPHost(network string, h virt.DHCPHost) error
DeleteDHCPHost(network, mac string) error
}
Backend is what the API needs from the virtualization layer (implemented by *virt.Client).
type Backupper ¶
type Backupper interface {
ListBackups(dir virt.BackupDir, uuid string) ([]virt.Backup, error)
BackupDomain(ctx context.Context, dir virt.BackupDir, uuid string, automatic bool, report func(string)) (virt.Backup, error)
DeleteBackup(dir virt.BackupDir, id string) error
RestoreBackup(ctx context.Context, dir virt.BackupDir, id, name, pool string, report func(string)) (string, error)
}
Backupper is the backup part of the backend (implemented by *virt.Client).
type ChassisView ¶
ChassisView is the chassis plus how to reach the host's management controller (BMC), if one is configured for fencing (HA): that is the only BMC address VirtoMir knows for sure.
type Consoler ¶
type Consoler interface {
ConsoleInfo(uuid string) (virt.ConsoleInfo, error)
DialVNC(ctx context.Context, uuid string) (net.Conn, error)
SerialConsole(ctx context.Context, uuid, device string, in io.Reader, out io.Writer) error
}
Consoler is the console part of the backend (implemented by *virt.Client).
type ExtraDevicer ¶
type ExtraDevicer interface {
AddDevice(uuid string, spec virt.DeviceSpec) (virt.DeviceResult, error)
GetQEMUArgs(uuid string) (virt.QEMUArgs, error)
SetQEMUArgs(uuid string, q virt.QEMUArgs) (virt.DefineResult, error)
CreateMDev(spec virt.MDevSpec) (string, error)
DeleteMDev(uuid string) error
}
ExtraDevicer adds watchdogs, TPMs, shared folders, vGPU slices and the like, edits the QEMU command line and manages the host's mediated devices (implemented by *virt.Client). All writes are admin-only (requiredRole's default) and stay out of operator self-service: shared folders, mdevs and QEMU arguments reach past the host's safety checks.
type Firewaller ¶
type Firewaller interface {
Firewall(uuid string) (virt.Firewall, error)
SetFirewall(uuid string, fw virt.Firewall) (virt.FirewallResult, error)
RemoveFirewall(uuid string) error
}
Firewaller manages a machine's firewall (implemented by *virt.Client, ADR-0033).
type HistoryQuerier ¶
type HistoryQuerier interface {
Query(names []string, rng time.Duration, now time.Time) (history.Result, error)
}
HistoryQuerier answers history queries (implemented by *history.Store).
type HostDevicer ¶
type HostDevicer interface {
HostHardware() (virt.HostHardware, error)
AttachHostdev(uuid string, spec virt.HostdevSpec) (string, error)
}
HostDevicer lists host hardware and passes devices to machines (implemented by *virt.Client).
type HostResult ¶
type HostResult struct {
Host string `json:"host"`
OK bool `json:"ok"`
Error string `json:"error,omitempty"`
}
HostResult is the outcome of one step of a cluster-wide action on one member.
type Live ¶
type Live interface {
Subscribe() (backlog [][]byte, updates <-chan []byte, unsubscribe func())
Refresh()
}
Live is the snapshot stream (implemented by *live.Hub).
type MemberStatus ¶
type MemberStatus struct {
ID string `json:"id"`
Name string `json:"name"`
Address string `json:"address"`
Fingerprint string `json:"fingerprint"`
Self bool `json:"self"`
Reachable bool `json:"reachable"`
Version string `json:"version,omitempty"`
Error string `json:"error,omitempty"`
}
MemberStatus is a member as the UI sees it: reachable now, which version it runs.
type Migrator ¶
type Migrator interface {
PlanMigration(uuid string) (virt.MigrationSource, error)
CheckPaths(paths []string) ([]virt.PathCheck, error)
MigrateBegin(uuid string, flags libvirt.DomainMigrateFlags, disks []string) ([]byte, string, error)
MigratePrepare(name, xml, uri string, cookie []byte, flags libvirt.DomainMigrateFlags, disks []string) ([]byte, string, error)
MigratePerform(ctx context.Context, uuid, uri string, cookie []byte, flags libvirt.DomainMigrateFlags, disks []string, progress func(string)) ([]byte, error)
MigrateFinish(name, uri string, cookie []byte, flags libvirt.DomainMigrateFlags, disks []string, cancelled bool) ([]byte, error)
MigrateConfirm(uuid string, cookie []byte, flags libvirt.DomainMigrateFlags, disks []string, cancelled bool) error
RemoveImage(path string) error
HostCPU() (virt.HostCPU, error)
}
Migrator is the live-migration part of the backend (implemented by *virt.Client).
type Mover ¶
type Mover interface {
PlanMove(uuid string) (virt.MovePlan, error)
AdoptDomain(xml string) (string, error)
}
Mover is the part of the backend that moves machines between hosts (ADR-0020).
type OVAImporter ¶
type OVAImporter interface {
ImportOVA(ctx context.Context, pool, name string, r io.Reader, report func(string)) (virt.CreateResult, error)
}
OVAImporter turns an OVA appliance into a machine (implemented by *virt.Client).
type Options ¶
type Options struct {
Backend Backend
Live Live
Jobs *jobs.Manager
// Auth nil means no sign-in (development only; virtomird warns loudly).
Auth *auth.Manager
UI fs.FS // nil: no UI bundled
Version string
Log *slog.Logger
// History nil: no metric history (GET /api/v1/history answers 404).
History HistoryQuerier
// Tokens nil: no API tokens. Activity nil: changes are only logged, not kept.
Tokens *auth.Tokens
Activity *activity.Log
// Alerts nil: no alert engine. Schedules nil: no schedules and no backups.
Alerts *alerts.Engine
Schedules *schedule.Scheduler
// Cluster nil: this host cannot join others (no TLS). Fingerprint is this host's TLS
// certificate, HostName how members call it, ListenPort where it listens (ADR-0020).
// Quotas nil: only admins create machines. GroupsOf names a user's groups for group
// rules (default: the Linux groups).
Quotas *quota.Store
GroupsOf func(user string) []string
// ConfigHistory nil: machine definitions are not versioned.
ConfigHistory *confighist.Store
Cluster *cluster.Store
Fingerprint string
HostName string
ListenPort string
// HA nil: no high availability (the manager is connected later with SetHA).
HA *ha.Store
Reports *reports.Store
Respools *respool.Store
// HostInfo nil: no chassis, sensors, GPU load, interfaces or packet capture.
HostInfo *hostinfo.Reader
// Updater nil: no update check. StateDir is where downloads go.
Updater *update.Checker
StateDir string
}
type PoolView ¶
type PoolView struct {
respool.ResourcePool
Usage respool.Usage `json:"usage"`
}
PoolView is a pool with what its machines use.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) HATransport ¶
HATransport is how the HA manager reaches the other members: over the pinned peer links.
func (*Server) RunReportSchedules ¶
RunReportSchedules makes this host's scheduled reports until ctx ends. Schedules are kept per host, but every report covers the whole cluster, so one host's schedules are enough.
func (*Server) SetHA ¶
SetHA connects the HA manager (it needs the server as its transport, so it comes later).
func (*Server) SyncMembers ¶
SyncMembers pulls the member list from every peer and keeps the newest; run it now and then so a host that was down during a change catches up. A host that every other member refuses was removed while it was away: it becomes standalone.