cluster

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: 6 Imported by: 0

Documentation

Overview

Package cluster is the unique portion of this application that implements basic cluster controls overtop of Libvirtd hosts. The controller is agnostic about where it is running, and doesn't need to be running on a host that has Libvirtd installed on it.

The cluster can be configured through the use of TOML configuration file, or with CLI flags. This is done via the itegration of the greate go libraries spf13/viper and spf13/cobra.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrHostNotFound = errors.New("host not found")
)

Errors that can happen in the cluster

Functions

This section is empty.

Types

type CPUDiff

type CPUDiff struct {
	Sockets   int
	Cores     int
	Threads   int
	Allocated int
	MHz       int
}

type CPUStats

type CPUStats struct {
	Sockets   uint32
	Cores     uint32
	Threads   uint32
	Allocated uint32
	MHz       uint64
}

CPUStats provides information about the number of CPUs, Cores, Threads, and Speed available to the cluster.

type Cluster

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

Cluster is the data structure and controller for cluster access. Using it's methods, you can access hosts, virtual machines, health data, and more. Cluster implements a time.Ticker that will be used to check the connection status of hosts, and reconnect if a connection was blocked or interrupted.

func (*Cluster) GetHost

func (c *Cluster) GetHost(h string) (*host.Host, error)

type ClusterBuilder

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

ClusterBuilder is used to build a Cluster object, which can then be used

func New

func New() *ClusterBuilder

New starts the builder pattern for the Cluster. Sets the default interval time to 30 seconds.

func (*ClusterBuilder) AddHost

func (c *ClusterBuilder) AddHost(h string) *ClusterBuilder

func (*ClusterBuilder) AddHostWithURI

func (c *ClusterBuilder) AddHostWithURI(h string, uri *host.URI) *ClusterBuilder

func (*ClusterBuilder) Build

func (c *ClusterBuilder) Build() *Cluster

Build retuns the built cluster

func (*ClusterBuilder) DefaultHostURI

func (c *ClusterBuilder) DefaultHostURI(uri *host.URI) *ClusterBuilder

func (*ClusterBuilder) SetInterval

func (c *ClusterBuilder) SetInterval(i time.Duration) *ClusterBuilder

SetInterval sets the check interval of the Cluster being built.

type ClusterStats

type ClusterStats struct {
	// CPU Statistics including number of CPUs
	CPU CPUStats
	// Memory provides information about the amount of memory, including free and
	// allocated memory
	Memory MemoryStats
	// Storage provides information about storage pools, Only get's stats for active
	// pools, and will not activate pools that are not already active.
	// Trys to sort out shared file systems from local filesystems using the Type parameter
	// of Host.StoragePoolInfo
	Storage StorageStats
	// Volume provides information on allocated volumes used in the cluster
	Volume VolumeStats
	// VM provides VM specific counters for the cluster
	VM VMStats
	// Host provides Host information for the cluster
	Host HostStats
	// Network provices available networks, and how many are shared between hosts
	Network NetworkStats
	// NetIF provides information about Libvirt allocated networks, usable by the
	// libvirt cluster
	NetIF NetIFStats
	// contains filtered or unexported fields
}

ClusterStats is used to gather stats for the entire cluster Combined with StatsDiff, we can get some basic cluster wide stats tracking

func InitStats

func InitStats(c *Cluster) *ClusterStats

InitStats is given a cluster, which it then uses to load the initial statistics Does not close connections, but uses the host connections available to the cluster to add statistics together.

func (*ClusterStats) Diff

func (cs *ClusterStats) Diff() StatDiff

Diff returns a map of all the field and how they changed

func (*ClusterStats) Update

func (cs *ClusterStats) Update()

Update triggers the stats collector to refresh it's statistics

type DeviceStats

type DeviceStats struct {
	Count uint32
}

DeviceStats provides information about the number of allocatable devices in the cluster. These are PCI and USB devices.

type HostDiff

type HostDiff struct {
	Count     int
	Available int
}

type HostStats

type HostStats struct {
	Available uint32
	Nodes     uint32
}

HostStats provides informatoin about the number of hosts defined, and how many are currently available. An unavailable host will not have it's statistics counted

type MemoryDiff

type MemoryDiff struct {
	Total     int64
	Free      int64
	Buffers   int64
	Cached    int64
	Allocated int64
}

type MemoryStats

type MemoryStats struct {
	Total     uint64
	Free      uint64
	Buffers   uint64
	Cached    uint64
	Allocated uint64
}

MemoryStats provies information about the amount of memory, including free and allocated memory. Allocated is the total allocated to Guests

type NetIFStats

type NetIFStats struct {
	Count    uint32
	Common   uint32
	Active   uint32
	Inactive uint32
}

NetIFStats provides information about Libvirt defined networks

type NetworkDiff

type NetworkDiff struct {
	Count    int
	Active   int
	Inactive int
}

type NetworkStats

type NetworkStats struct {
	Count    uint32
	Active   uint32
	Inactive uint32
}

NetworkStats provides informatoin about the available Host network connections, including bridges and ethernet devices.

type SecretStats

type SecretStats struct {
	Count  uint32
	Shared uint32
}

SecretStats provides the number of secrets defined throughout the cluster. Shared secrets are only counted once, and are recognized by their UUID

type StatDiff

type StatDiff struct {
	CPU     CPUDiff
	Memory  MemoryDiff
	Storage StorageDiff
	Volume  VolumeDiff
	VM      VMDiff
	Host    HostDiff
	Network NetworkDiff
}

ClusterStats is used to gather stats for the entire cluster

type StorageDiff

type StorageDiff struct {
	Total    int64
	Used     int64
	Free     int64
	Active   int64
	Inactive int64
	Pools    int
}

type StorageStats

type StorageStats struct {
	Total    uint64
	Used     uint64
	Free     uint64
	Active   uint32
	Inactive uint32
	Pools    uint32
}

StorageStats provides information about the available storage pools in the cluster, including the amount of space available, allocated, and how many pools are shared between hosts All sizes are in Bytes

type VMDiff

type VMDiff struct {
	Count   int
	Started int
	Stopped int
}

type VMStats

type VMStats struct {
	Count   uint32
	Started uint32
	Stopped uint32
}

VMStats provides information about the defined Virtual Machines on the cluster

type VolumeDiff

type VolumeDiff struct {
	Total    int
	Active   int
	Inactive int
}

type VolumeStats

type VolumeStats struct {
	Total    uint32
	Active   uint32
	Inactive uint32
}

VolumeStats provides information about the number of volumes on the cluster. Counts volumes in shared storage (as detmermined by StorageStats) only once

Directories

Path Synopsis
Package lock implements a locking mechanism on shared resources to ensure they don't get used at the same time.
Package lock implements a locking mechanism on shared resources to ensure they don't get used at the same time.

Jump to

Keyboard shortcuts

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