Documentation ¶
Overview ¶
Package lxd is our wrapper to the official lxd client
Index ¶
- Variables
- func CreateContainer(host string, name string, image string, storagepool string, ...) error
- func CreateFile(host string, name string, path string, mode int, contents string) error
- func DeleteContainer(host string, name string) error
- func ExecCommand(host string, name string, command []string) (float64, error)
- func GetContainerState(host string, name string) (*api.ContainerState, error)
- func GetHostResources(host string) (map[string]HostResourceInfo, error)
- func GetStoragePools(host string) (map[string][]string, error)
- func IsManageable(c ContainerInfo) bool
- func MoveContainer(srcHost string, dstHost string, name string) error
- func StartContainer(host string, name string) error
- func StopContainer(host string, name string) error
- type ContainerInfo
- type DiscardCloser
- type HostResourceInfo
- type ImageInfo
Constants ¶
This section is empty.
Variables ¶
var Conf *config.Config
Conf is our main config
Functions ¶
func CreateContainer ¶
func CreateContainer(host string, name string, image string, storagepool string, options map[string]string) error
CreateContainer creates a container from the given image, with the provided name on the LXD host
func CreateFile ¶
CreateFile creates a file or directory on the container. If the provided path ends in / we assume that we are creating a directory
func DeleteContainer ¶
DeleteContainer removes a container from a host
func ExecCommand ¶
ExecCommand runs a command on the container and discards the output. As further comments state, there doesn't seem to be an accurate return of success or not, need to look for a status code return. If a way is found, likely will stop discarding output and return that to the UI. -1 is our return if something outside the command went wrong
func GetContainerState ¶
func GetContainerState(host string, name string) (*api.ContainerState, error)
GetContainerState calls out to our LXD host to get the state of the container. State has data like network info, memory usage, cpu seconds in use, running processes etc
func GetHostResources ¶
func GetHostResources(host string) (map[string]HostResourceInfo, error)
GetHostResources grabs (the kind of limited) info about a host, available CPU cores, Memory, ...
func GetStoragePools ¶
GetStoragePools gets a list of all the storage pools available for each host
func IsManageable ¶
func IsManageable(c ContainerInfo) bool
IsManageable just checks our lock flag, user.lxdepot_lock to see if it is "true" or not
func MoveContainer ¶
MoveContainer will move (copy in lxd speak) a container from one server to another.
func StartContainer ¶
StartContainer starts a stopped container
func StopContainer ¶
StopContainer stops a running container
Types ¶
type ContainerInfo ¶
type ContainerInfo struct { Host *config.LXDhost // Host details Container api.Container // Container details returned from lxd.GetContainers State *api.ContainerState // Container state from lxd.GetContainerState Usage map[string]float64 // place to store usge conversions, like CPU usage }
ContainerInfo is a conversion / grouping of useful container information as returned from the lxd client
func GetContainers ¶
func GetContainers(host string, name string, getState bool) ([]ContainerInfo, error)
GetContainers asks for a list of containers from each LXD host, then optionally calls GetContainerState on each container to populate state information (IP, CPU / Memory / Disk usage, etc)
type DiscardCloser ¶
type DiscardCloser struct{}
DiscardCloser is a WriteCloser that just discards data. When we exec commands on a container stdout, etc need some place to go, but at the moment we don't care about the data.
func (DiscardCloser) Close ¶
func (DiscardCloser) Close() error
Close does nothing and is there just to satisfy the WriteCloser interface
type HostResourceInfo ¶
HostResourceInfo is a group of Host and Resources as returned by lxd
type ImageInfo ¶
type ImageInfo struct { Host *config.LXDhost // Host details Aliases []api.ImageAlias // list of aliases this image goes by Architecture string // x86_64, etc Fingerprint string // fingerprint hash of the image for comparison }
ImageInfo like above is a grouping of useful image information for the frontend