host

package
v0.0.0-...-626fa6c Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package host provides utilities and data structures in relation to a libvirt host. This includes getting a list of virtual machines running on a host, launching a new virtual machine on a host, triggering a virtual machine migration to another host, getting hardware and resource usage from a host, and eventually more. Most of this is data at the moment, ensuring data can be gathered efficiently without slowing down the host from it's main job of running virtual machines.

Index

Constants

This section is empty.

Variables

View Source
var (
	// XML errors
	ErrGetXML   = errors.New("error getting XML")
	ErrParseXML = errors.New("error parsing XML")

	// Hostinfo errors
	ErrHostInfo = errors.New("error processing HostInfo")
)
View Source
var (
	URI_QEMU_LOCAL = Define("qemu", "local", "system")
	URI_QEMU_SSH   = Define("qemu", "ssh", "system")
)

Functions

This section is empty.

Types

type Host

type Host struct {
	// HostName used to make the connection
	HostName string
	// SystemHostName is the hostname as reported by the system itself
	SystemHostName string
	// LibVersion is the version of Libvirt on the host
	LibVersion uint32
	// SysInfo is the XML representation of the host system information
	SysInfo string
	// Alive indicates if the connection is alive
	Alive bool
	// Encrypted indicates if the connection is encrypted
	Encrypted bool
	// Secure indicates if the connection is secure
	Secure bool
	// HostInfo provides basic HW information about a host
	HostInfo *libvirtxml.CapsHost
	// NodeMemory provides basic memory information about the Host
	NodeMemory *NodeMemoryInfo
	// VMList is the list of virtual machines available to the host
	VMList []*libvirtxml.Domain
	// NetIfList is the list of network interfaces on the host
	NetIfFList []*libvirtxml.Interface
	// NetworkList is the list of defined networks on the host
	NetworkList []*libvirtxml.Network
	// DeviceList is the list of devices on the host
	DeviceList []*libvirtxml.NodeDevice
	// SecretList provides a list of secrets available to the host
	SecretList []*libvirtxml.Secret
	// StoragePoolList provides the list of stoarge ppols available to the host
	StoragePoolList []*libvirtxml.StoragePool
	// VolumeList is the list of volumes available on the host
	VolumeList []*libvirtxml.StorageVolume
	// contains filtered or unexported fields
}

Host holds information and acts as a connection handle for a Host If a connection is closed prematurely, will re-open the connection and try the attempted method again

func ConnectHost

func ConnectHost(uri *URI, host string) (*Host, error)

ConnectHost creates a host connection wrapper that can be used regularly

func (*Host) Close

func (h *Host) Close() error

Close triggers closing the host connection

func (*Host) GetGuestByName

func (h *Host) GetGuestByName(name string) (*guest.VM, error)

GetGuestByName returns a GuestVM instance that exists on the given host

type HostStats

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

HostStats works as a handler that can be subscribed to. It runs a go routine that sends Stats via a channel when subscribed to

func (*HostStats) Subscribe

func (hs *HostStats) Subscribe(parent context.Context, pubto <-chan Stats) error

type NodeMemoryInfo

type NodeMemoryInfo struct {
	Total   uint64
	Free    uint64
	Buffers uint64
	Cached  uint64
}

NodeMemoryInfo provides statistis about node memory usage from libvirt.NodeMemoryStats

type Stats

type Stats struct {
	Memory       NodeMemoryInfo
	VMs          []*libvirtxml.Domain
	StoragePools []*libvirtxml.StoragePool
}

type URI

type URI struct {
	Driver    string
	Transport string
	Path      string
	Host      string
	Options   []string
}

URI is a string type, accessed via the pre-defined variables, and represent the URI pattern used to connect to a host. Example: Driver[+Transport]://<host or empty for local>[:PORT]/<path>[?Options&in=uri&format]

func Define

func Define(driver, transport, path string, options ...string) *URI

Define create and return a custom URI method, following RFC2396, keeping in mind that the hostname will be inserted between the transport and path

func (*URI) AddOpt

func (u *URI) AddOpt(opt string)

AddOpt adds more options to the option list

func (*URI) ConnectionString

func (u *URI) ConnectionString() string

ConnectionString takes a host name to interpolate into a URI and returns the string

func (*URI) IsRemote

func (u *URI) IsRemote() bool

IsRemote returns true if the URI references a remote trasnport (ssh, tcp or tls)

func (*URI) WithHost

func (u *URI) WithHost(host string) *URI

WithHost sets the hostname as part of a URI. It copies the original URI and returns a new one

Jump to

Keyboard shortcuts

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