Documentation ¶
Index ¶
- func AddDevice(lxdServer lxd.InstanceServer, unitName string, devname string, ...) error
- func AddRemote(remote Remote, password string) error
- func AttachNetwork(lxdServer lxd.InstanceServer, name string, bridge string, nic1 string, ...) error
- func CheckHostPorts(hostURL string, forwardedPorts []string) (err error)
- func CheckMemory(lxdServer lxd.InstanceServer, ramString string) error
- func CheckStoragePoolSpace(lxdServer lxd.InstanceServer, storagePool string, requestedSpace int64) (err error)
- func ConfigDevice(lxdServer lxd.InstanceServer, name string, nic string, ip string) error
- func ConfigureHost(settings HostSettings, remote Remote) error
- func CopyDirectory(lxdServer lxd.InstanceServer, name string, src, dst string) error
- func CopyFiles(lxdServer lxd.InstanceServer, name string, src, dst string) error
- func CopyImage(sourceServer lxd.InstanceServer, destServer lxd.InstanceServer, ...) error
- func CreateStoragePool(lxdServer lxd.InstanceServer, name string, size string) error
- func DeleteDevice(lxdServer lxd.InstanceServer, name string, target string) (string, error)
- func DeleteImageByFingerprint(lxdServer lxd.InstanceServer, fingerprint string) error
- func DeleteNetwork(lxdServer lxd.InstanceServer, name string) error
- func DeleteProfile(lxdServer lxd.InstanceServer, name string) error
- func DeleteStoragePool(lxdServer lxd.InstanceServer, name string) error
- func DeleteUnit(lxdServer lxd.InstanceServer, name string) error
- func DeleteVolume(lxdServer lxd.InstanceServer, pool string, volume api.StorageVolume) error
- func Exec(ctx context.Context, lxdServer lxd.InstanceServer, name string, ...) (returnCode int, err error)
- func ExportBravetoolsImage(image string, outputDir string) error
- func ExportImage(lxdServer lxd.ImageServer, fingerprint string, name string) error
- func FilePush(lxdServer lxd.InstanceServer, name string, sourceFile string, ...) error
- func GetBraveProfile(lxdServer lxd.InstanceServer, profileName string) (braveProfile shared.BraveProfile, err error)
- func GetBravefileFromLXD(name string) (*shared.Bravefile, error)
- func GetBravetoolsBridgeIP(lxdServer lxd.InstanceServer, bridgeName string) (string, error)
- func GetFingerprintByAlias(lxdServer lxd.ImageServer, alias string, architecture string) (fingerprint string, err error)
- func GetImageByAlias(lxdImageServer lxd.ImageServer, alias string, architecture string) (image *api.Image, err error)
- func GetImages(lxdServer lxd.ImageServer) ([]api.Image, error)
- func GetLXDImageSever(remote Remote) (lxd.ImageServer, error)
- func GetLXDInstanceServer(remote Remote) (lxd.InstanceServer, error)
- func GetLXDServerArch(lxdServer lxd.InstanceServer) (string, error)
- func GetLXDServerVersion(lxdServer lxd.InstanceServer) (int, error)
- func GetSimplestreamsLXDSever(url string, args *lxd.ConnectionArgs) (lxd.ImageServer, error)
- func GetUnits(lxdServer lxd.InstanceServer, profileName string) (units []shared.BraveUnit, err error)
- func GetVolume(lxdServer lxd.InstanceServer, pool string) (volume api.StorageVolume, err error)
- func ImportImage(lxdServer lxd.InstanceServer, imageTar string, nameAndVersion string) (fingerprint string, err error)
- func LaunchFromImage(destServer lxd.InstanceServer, sourceServer lxd.ImageServer, imageName string, ...) (fingerprint string, err error)
- func ListRemotes() (names []string, err error)
- func MountDirectory(lxdServer lxd.InstanceServer, sourcePath string, destUnit string, ...) error
- func ParseRemoteName(image string) (remote string, imageName string)
- func Publish(lxdServer lxd.InstanceServer, name string, image string) (fingerprint string, err error)
- func Push(lxdServer lxd.InstanceServer, name string, sourcePath string, ...) error
- func RemoveRemote(name string) error
- func SaveRemote(remote Remote) error
- func SetActiveStoragePool(lxdServer lxd.InstanceServer, name string) error
- func SetConfig(lxdServer lxd.InstanceServer, name string, config map[string]string) error
- func Start(lxdServer lxd.InstanceServer, name string) error
- func Stop(lxdServer lxd.InstanceServer, name string) error
- func SymlinkPush(lxdServer lxd.InstanceServer, name string, sourceFile string, ...) error
- func TransferImage(sourceRemote Remote, bravefile shared.Bravefile) error
- func UpdateBraveSettings(settings HostSettings) error
- func UpdateDevice(lxdServer lxd.InstanceServer, unitName string, deviceName string, ...) error
- type Backend
- type BackendResources
- type BackendSettings
- type BraveHost
- func (bh *BraveHost) AddRemote() error
- func (bh *BraveHost) BuildImage(bravefile shared.Bravefile) error
- func (bh *BraveHost) Compose(backend Backend, composeFile *shared.ComposeFile) (err error)
- func (bh *BraveHost) DeleteLocalImage(name string, legacy bool) error
- func (bh *BraveHost) DeleteUnit(name string) error
- func (bh *BraveHost) GetUnitNames() []string
- func (bh *BraveHost) HostInfo(short bool) error
- func (bh *BraveHost) ImportLocalImage(sourcePath string) error
- func (bh *BraveHost) InitUnit(backend Backend, unitParams shared.Service) (err error)
- func (bh *BraveHost) ListAllMounts() error
- func (bh *BraveHost) ListMounts(unitName string) error
- func (bh *BraveHost) MountShare(source string, destUnit string, destPath string) error
- func (bh *BraveHost) PrintLocalImages() error
- func (bh *BraveHost) PrintUnits(backend Backend, remoteName string) error
- func (bh *BraveHost) PublishUnit(unitName string, imageName string) error
- func (bh *BraveHost) StartUnit(name string) error
- func (bh *BraveHost) StopUnit(name string) error
- func (bh *BraveHost) UmountShare(unit string, target string) error
- type BravetoolsImage
- func GetLocalImages() (images []BravetoolsImage, err error)
- func ImageFromFilename(filename string) (BravetoolsImage, error)
- func ImageFromLegacyFilename(filename string) (BravetoolsImage, error)
- func ParseImageString(imageString string) (imageStruct BravetoolsImage, err error)
- func ParseLegacyImageString(imageString string) (imageStruct BravetoolsImage, err error)
- type DummyBackend
- type ExecArgs
- type HostConfig
- type HostSettings
- type ImageExistsError
- type Info
- type Lxd
- type LxdStatus
- type Multipass
- type Network
- type Remote
- type Storage
- type StorageUsage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddDevice ¶
func AddDevice(lxdServer lxd.InstanceServer, unitName string, devname string, devSettings map[string]string) error
AddDevice adds an external device to a unit with the given devSettings
func AttachNetwork ¶
func AttachNetwork(lxdServer lxd.InstanceServer, name string, bridge string, nic1 string, nic2 string) error
AttachNetwork attaches unit to internal network bridge
func CheckHostPorts ¶
CheckHostPorts ensures required forwarded ports are free by attempting to connect. If a connection is established the port is already taken
func CheckMemory ¶
func CheckMemory(lxdServer lxd.InstanceServer, ramString string) error
CheckMemory checks if the LXD server host has sufficient RAM to deploy requested unit
func CheckStoragePoolSpace ¶
func CheckStoragePoolSpace(lxdServer lxd.InstanceServer, storagePool string, requestedSpace int64) (err error)
func ConfigDevice ¶
ConfigDevice sets IP address lxc config device set [remote]:name eth0 ipv4.address
func ConfigureHost ¶
func ConfigureHost(settings HostSettings, remote Remote) error
ConfigureHost configures local bravetools host and updates resources
func CopyDirectory ¶
func CopyDirectory(lxdServer lxd.InstanceServer, name string, src, dst string) error
CopyDirectory recursively copies a src directory to a destination.
func CopyFiles ¶
func CopyFiles(lxdServer lxd.InstanceServer, name string, src, dst string) error
CopyFiles copies a src file to a dst file where src and dst are regular files.
func CopyImage ¶
func CopyImage(sourceServer lxd.InstanceServer, destServer lxd.InstanceServer, fingerprint string, alias string) error
func CreateStoragePool ¶
func CreateStoragePool(lxdServer lxd.InstanceServer, name string, size string) error
CreateStoragePool creates a new storage pool
func DeleteDevice ¶
DeleteDevice unmounts a disk
func DeleteImageByFingerprint ¶
func DeleteImageByFingerprint(lxdServer lxd.InstanceServer, fingerprint string) error
DeleteImageFingerprint delete unit image lxc image delete [remote]:[name]
func DeleteNetwork ¶
func DeleteNetwork(lxdServer lxd.InstanceServer, name string) error
DeleteNetwork ..
func DeleteProfile ¶
func DeleteProfile(lxdServer lxd.InstanceServer, name string) error
DeleteProfile ..
func DeleteStoragePool ¶
func DeleteStoragePool(lxdServer lxd.InstanceServer, name string) error
DeleteStoragePool ..
func DeleteUnit ¶
func DeleteUnit(lxdServer lxd.InstanceServer, name string) error
Delete deletes a unit on a LXD remote
func DeleteVolume ¶
func DeleteVolume(lxdServer lxd.InstanceServer, pool string, volume api.StorageVolume) error
DeleteVolume ..
func Exec ¶
func Exec(ctx context.Context, lxdServer lxd.InstanceServer, name string, command []string, arg ExecArgs) (returnCode int, err error)
Exec runs command inside unit
func ExportBravetoolsImage ¶
func ExportImage ¶
func ExportImage(lxdServer lxd.ImageServer, fingerprint string, name string) error
ExportImage downloads unit image into current directory
func FilePush ¶
func FilePush(lxdServer lxd.InstanceServer, name string, sourceFile string, targetPath string) error
FilePush copies local file into unit
func GetBraveProfile ¶
func GetBraveProfile(lxdServer lxd.InstanceServer, profileName string) (braveProfile shared.BraveProfile, err error)
GetBraveProfile ..
func GetBravefileFromLXD ¶
GetBravefileFromLXD generates a Bravefile for import of images from an LXD server
func GetBravetoolsBridgeIP ¶
func GetBravetoolsBridgeIP(lxdServer lxd.InstanceServer, bridgeName string) (string, error)
func GetFingerprintByAlias ¶
func GetFingerprintByAlias(lxdServer lxd.ImageServer, alias string, architecture string) (fingerprint string, err error)
GetFingerprintByAlias retrieves image fingerprint corresponding to provided alias
func GetImageByAlias ¶
func GetImageByAlias(lxdImageServer lxd.ImageServer, alias string, architecture string) (image *api.Image, err error)
GetImageByAlias retrieves image by name
func GetImages ¶
func GetImages(lxdServer lxd.ImageServer) ([]api.Image, error)
GetImages returns all images from host
func GetLXDImageSever ¶
func GetLXDImageSever(remote Remote) (lxd.ImageServer, error)
func GetLXDInstanceServer ¶
func GetLXDInstanceServer(remote Remote) (lxd.InstanceServer, error)
GetLXDInstanceServer ..
func GetLXDServerArch ¶
func GetLXDServerArch(lxdServer lxd.InstanceServer) (string, error)
func GetLXDServerVersion ¶
func GetLXDServerVersion(lxdServer lxd.InstanceServer) (int, error)
GetLXDServerVersion retrieves server semantic version and converts to integer
func GetSimplestreamsLXDSever ¶
func GetSimplestreamsLXDSever(url string, args *lxd.ConnectionArgs) (lxd.ImageServer, error)
func GetUnits ¶
func GetUnits(lxdServer lxd.InstanceServer, profileName string) (units []shared.BraveUnit, err error)
GetUnits returns all running units
func GetVolume ¶
func GetVolume(lxdServer lxd.InstanceServer, pool string) (volume api.StorageVolume, err error)
GetVolume ..
func ImportImage ¶
func ImportImage(lxdServer lxd.InstanceServer, imageTar string, nameAndVersion string) (fingerprint string, err error)
ImportImage imports image from current directory
func LaunchFromImage ¶
func LaunchFromImage(destServer lxd.InstanceServer, sourceServer lxd.ImageServer, imageName string, containerName string, profileName string, storagePool string) (fingerprint string, err error)
LaunchFromImage creates new unit based on image
func ListRemotes ¶
func MountDirectory ¶
func MountDirectory(lxdServer lxd.InstanceServer, sourcePath string, destUnit string, destPath string) error
MountDirectory mounts local directory to unit
func ParseRemoteName ¶
ParseRemoteName unpacks remote and rest of image/service name and returns both
func Publish ¶
func Publish(lxdServer lxd.InstanceServer, name string, image string) (fingerprint string, err error)
Publish unit lxc publish -f [remote]:[name] [remote]: --alias image
func SaveRemote ¶
func SetActiveStoragePool ¶
func SetActiveStoragePool(lxdServer lxd.InstanceServer, name string) error
SetActiveStoragePool pool assigns a profile with default storage
func SymlinkPush ¶
func SymlinkPush(lxdServer lxd.InstanceServer, name string, sourceFile string, targetPath string) error
SymlinkPush copies a symlink into unit
func UpdateBraveSettings ¶
func UpdateBraveSettings(settings HostSettings) error
UpdateBraveSettings configuration in place and write to config.yaml
func UpdateDevice ¶
func UpdateDevice(lxdServer lxd.InstanceServer, unitName string, deviceName string, deviceSettings map[string]string) error
UpdateDevice updates the deviceSettings of an existing device - existing config remains unchanged unless overwritten by a matching key in the provided deviceSettings
Types ¶
type Backend ¶
type Backend interface { BraveBackendInit() error Info() (Info, error) Running() (bool, error) Start() error }
Backend ..
func NewHostBackend ¶
func NewHostBackend(hostSettings HostSettings) (backend Backend, err error)
NewHostBackend returns a new Backend from provided host Settings
type BackendResources ¶
type BackendResources struct { Name string `yaml:"name"` OS string `yaml:"os"` CPU string `yaml:"cpu"` RAM string `yaml:"ram"` HD string `yaml:"hd"` IP string `yaml:"ip"` }
BackendResources ..
type BackendSettings ¶
type BackendSettings struct { Type string `yaml:"type"` Resources BackendResources `yaml:"resources"` }
BackendSettings ..
type BraveHost ¶
type BraveHost struct { Settings HostSettings `yaml:"settings"` Remote Remote Backend Backend }
BraveHost ..
func (*BraveHost) BuildImage ¶
BuildImage creates an image based on Bravefile
func (*BraveHost) Compose ¶
func (bh *BraveHost) Compose(backend Backend, composeFile *shared.ComposeFile) (err error)
func (*BraveHost) DeleteLocalImage ¶
DeleteLocalImage deletes a local image
func (*BraveHost) GetUnitNames ¶
GetUnitNames returns a list of all unit names, including remote units. Errors encountered will result in skipping the faulty remote's units.
func (*BraveHost) ImportLocalImage ¶
ImportLocalImage import tarball into local images folder
func (*BraveHost) ListAllMounts ¶
func (*BraveHost) ListMounts ¶
func (*BraveHost) MountShare ¶
MountShare ..
func (*BraveHost) PrintLocalImages ¶
PrintLocalImages prints the images in image store
func (*BraveHost) PrintUnits ¶
PrintUnits prints all LXD containers on remote host
func (*BraveHost) PublishUnit ¶
PublishUnit publishes unit to image
type BravetoolsImage ¶
type BravetoolsImage struct { Name string Version string Architecture string // contains filtered or unexported fields }
func GetLocalImages ¶
func GetLocalImages() (images []BravetoolsImage, err error)
func ImageFromFilename ¶
func ImageFromFilename(filename string) (BravetoolsImage, error)
func ImageFromLegacyFilename ¶
func ImageFromLegacyFilename(filename string) (BravetoolsImage, error)
func ParseImageString ¶
func ParseImageString(imageString string) (imageStruct BravetoolsImage, err error)
func ParseLegacyImageString ¶
func ParseLegacyImageString(imageString string) (imageStruct BravetoolsImage, err error)
func (BravetoolsImage) String ¶
func (imageStruct BravetoolsImage) String() string
func (BravetoolsImage) ToBasename ¶
func (imageStruct BravetoolsImage) ToBasename() string
type DummyBackend ¶
type DummyBackend struct {
Settings HostSettings
}
DummyBackend is a non-functional backend
func (*DummyBackend) BraveBackendInit ¶
func (d *DummyBackend) BraveBackendInit() error
func (*DummyBackend) Info ¶
func (d *DummyBackend) Info() (Info, error)
func (*DummyBackend) Running ¶
func (d *DummyBackend) Running() (bool, error)
func (*DummyBackend) Start ¶
func (d *DummyBackend) Start() error
type HostConfig ¶
type HostSettings ¶
type HostSettings struct { Name string `yaml:"name"` Trust string `yaml:"trust"` Profile string `yaml:"profile"` StoragePool Storage `yaml:"storage"` Network Network `yaml:"network"` BackendSettings BackendSettings `yaml:"backendsettings"` Status string `yaml:"status"` PublicImageRemote string `yaml:"public_image_remote,omitempty"` }
HostSettings configuration data loaded from config.yaml
func SetupHostConfiguration ¶
func SetupHostConfiguration(params HostConfig, userHome string, publicImageServer string) (settings HostSettings)
SetupHostConfiguration creates configuration file and saves it in bravetools directory
type ImageExistsError ¶
type ImageExistsError struct {
Name string
}
func (*ImageExistsError) Error ¶
func (e *ImageExistsError) Error() string
type Info ¶
type Info struct { ImageStorage string VolumeStorage string Name string State string IPv4 string Release string ImageHash string Load string Disk StorageUsage Memory StorageUsage CPU string }
Info describes Brave Platform
type Lxd ¶
type Lxd struct {
Settings *HostSettings
}
Lxd ..
type Multipass ¶
type Multipass struct {
Settings HostSettings
}
Multipass type defines local dev VM
func (Multipass) BraveBackendInit ¶
BraveBackendInit creates a new instance of BraveAI host
func (Multipass) BraveHostDelete ¶
BraveHostDelete removes BraveAI host
type Remote ¶
type Remote struct { Name string `json:"name"` URL string `json:"url"` Protocol string `json:"protocol"` Public bool `json:"public"` Profile string `json:"profile"` Network string `json:"network"` Storage string `json:"storage"` // contains filtered or unexported fields }
Remote represents a configuration of the remote
func LoadRemoteSettings ¶
LoadRemoteSettings loads a saved bravetools remote with TLS auth certs/keys if present
func NewBravehostRemote ¶
func NewBravehostRemote(settings HostSettings) Remote
type Storage ¶
type Storage struct { Type string `yaml:"type"` Name string `yaml:"name"` Size string `yaml:"size"` }
Storage ..