host

package
v0.0.0-...-760d706 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 7 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 for connecting to a remote QEMU system over SSH
	URI_QEMU_SSH_SYSTEM = &URI{Driver: "qemu", Transport: "ssh", Path: "system"}
	// URI for connecting to a remote	QEMU system over TLS
	// Builds the URI qemu://<host:port>/system
	URI_QEMU_TLS_SYSTEM = &URI{Driver: "qemu", Transport: "", Path: "system"}
	// URI for connecting to a remote QEMU session over SSH
	URI_QEMU_SSH_SESSION = &URI{Driver: "qemu", Transport: "ssh", Path: "session"}
	// URI for connecting to a local QEMU system over a UNIX socket
	URI_QEMU_UNIX_SYSTEM = &URI{Driver: "qemu", Transport: "unix", Path: "system"}
	// URI for connecting to a remote QEMU system over unsecured TCP
	URI_QEMU_TCP_SYSTEM = &URI{Driver: "qemu", Transport: "tcp", Path: "system"}

	// URI for connecting to a remote XEN system with SSH
	URI_XEN_SSH_SYSTEM = &URI{Driver: "xen", Transport: "ssh", Path: "system"}
	// URI for connecting to a remote XEN system over TLS
	URI_XEN_TLS_SYSTEM = &URI{Driver: "xen", Transport: "", Path: "system"}
)

URIs available to build connections to a libvirt host

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 NodeMemoryInfo

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

NodeMemoryInfo provides statistis about node memory usage from libvirt.NodeMemoryStats

type URI

type URI struct {
	Driver    string
	Transport string
	Path      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 CustomURI

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

CustomURI 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(h string) string

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

Jump to

Keyboard shortcuts

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