clustvirt/cluster/cluster.go
Matthew Stobbs 8e62f7e271 merge migrate_to_libvirtxml
completed migration to libvirtxml
2024-03-23 22:05:06 -06:00

35 lines
1.1 KiB
Go

// 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.
package cluster
import (
"fmt"
"time"
"git.staur.ca/stobbsm/clustvirt/lib/host"
)
// 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.
type Cluster struct {
interval time.Duration
hosts map[string]*host.Host
defaultURI *host.URI
}
func (c *Cluster) GetHost(h string) (*host.Host, error) {
if hh, ok := c.hosts[h]; ok {
return hh, nil
}
return nil, fmt.Errorf("%s: %w", h, ErrHostNotFound)
}