lxdbackend

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: GPL-3.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// NetworkBridgeName is the name of the LXD bridge network used by
	// workshops, exported for use by other packages (e.g. firewall checks).
	NetworkBridgeName = networkName
)

Variables

View Source
var (
	ConnectSimpleStreams = lxd.ConnectSimpleStreams
)

Functions

func CheckBridgeFirewall

func CheckBridgeFirewall(bridgeName string) string

CheckBridgeFirewall detects whether firewall rules block forwarding on the workshop bridge. It returns a non-empty warning message with a proposed resolution if an issue is detected, or an empty string if everything looks fine.

Detection is cause-agnostic: it checks whether the FORWARD chain policy is DROP/REJECT and whether any rules ACCEPT traffic for the bridge. The remediation advice is cause-aware: it suggests Docker-specific, UFW-specific, or generic commands depending on what is found.

Uses `nft -j` (JSON output) for structured, robust parsing.

See: https://documentation.ubuntu.com/lxd/latest/howto/network_bridge_firewalld/

func ConnectLxd

func ConnectLxd(ctx context.Context) (lxd.InstanceServer, error)

func DeviceConfigKey

func DeviceConfigKey(name string) string

func DeviceName

func DeviceName(parts ...string) string

func DeviceTypeConfigKey

func DeviceTypeConfigKey(name string) string

func ErrorLxdBackend

func ErrorLxdBackend(err error) error

func FakeImageServer

func FakeImageServer(server string) func()

func FakeStartCommand

func FakeStartCommand(script string) func()

func InstanceName

func InstanceName(name string, project_id string) string

func IsImportSdkConflict

func IsImportSdkConflict(err error) bool

Export this so the LXD candidate tests pick up error message changes.

func IsImportSdkOperation

func IsImportSdkOperation(op api.Operation, name string) (bool, error)

Export this so the LXD candidate tests pick up format changes.

func IsInstanceConflict

func IsInstanceConflict(err error, name string) bool

func IsInstanceOperation

func IsInstanceOperation(op api.Operation, lxdProject, name string) (bool, error)

func LxdProfile

func LxdProfile(conn lxd.InstanceServer, pid, wp, profile string) (*api.Profile, string, error)

func LxdToSdkProfile

func LxdToSdkProfile(profile string, devs map[string]map[string]string, config map[string]string) (workshop.SdkProfile, error)

func NewNetworkManager added in v0.9.2

func NewNetworkManager() workshop.NetworkManager

func Profile

func Profile(conn lxd.InstanceServer, pid, wp, profile string) (workshop.SdkProfile, error)

func ProfileName

func ProfileName(pid, workshop, sdk string) string

Types

type Backend

type Backend struct {
}

func New

func New() (*Backend, error)

New constructs the LXD backend and attempts to prepare the required LXD storage pool and network. It always returns a usable backend; if LXD is not yet ready the error is reported by the system check (see init), which puts the daemon into degraded mode and retries until LXD becomes available.

func (*Backend) AddWorkshopMount

func (s *Backend) AddWorkshopMount(ctx context.Context, name string, mount workshop.Mount) error

func (*Backend) CreateOrLoadProject

func (s *Backend) CreateOrLoadProject(ctx context.Context, path string) (*workshop.Project, bool, error)

func (*Backend) DeleteSdk

func (s *Backend) DeleteSdk(ctx context.Context, setup sdk.Setup) error

func (*Backend) DownloadBase

func (b *Backend) DownloadBase(ctx context.Context, image workshop.BaseImage, report *progress.Reporter) error

func (*Backend) Exec

func (s *Backend) Exec(ctx context.Context, name string, args *workshop.Execution) (workshop.ExecContext, error)

func (*Backend) FormatRevision

func (s *Backend) FormatRevision() sdk.Revision

Hard coded number which represents the current "snapshot format," i.e. the contents of the rootfs after installing a certain sequence of SDKs. This can be influenced by a number of factors, including: - Default workshop config (e.g. cloud-config) - Default workshop devices (e.g. apt cache) - SDK config and devices (e.g. volume mounts) - Direct modifications (e.g. mkdir /var/lib/workshop/run) If something like this changes, bump the revision number so that workshops constructed using the next release of Workshop are updated on refresh.

Some care needs to be taken with workshops using the old format. If a launch or refresh is in progress, it should either continue in a manner consistent with the old format, or fail if that isn't possible for some reason. For example, after changing the format of installed SDKs, the install-sdk task should either use a format consistent with the target workshop, or fail for workshops stuck on the old format.

Another issue is the restore command. In most cases this simply rebuilds from the last snapshot, but if that snapshot doesn't exist then it will replay some of the install-sdk and setup-base tasks. These can be handled in the same way as in-progress launches and refreshes.

func (*Backend) GetBase

func (b *Backend) GetBase(ctx context.Context, base string) (workshop.BaseImage, error)

func (*Backend) HashSnapshot

func (s *Backend) HashSnapshot(snapshot workshop.Snapshot) (string, error)

func (*Backend) ImportSdk

func (s *Backend) ImportSdk(ctx context.Context, meta sdk.Meta, tarball *os.File) error

func (*Backend) InstallSdk

func (s *Backend) InstallSdk(ctx context.Context, name string, setup sdk.Setup) error

func (*Backend) LaunchOrRebuildWorkshop

func (s *Backend) LaunchOrRebuildWorkshop(ctx context.Context, file *workshop.File, snapshot workshop.Snapshot) error

func (*Backend) LxdClient

func (s *Backend) LxdClient(ctx context.Context) (lxd.InstanceServer, error)

func (*Backend) ProjectWorkshops

func (s *Backend) ProjectWorkshops(ctx context.Context) ([]*workshop.Workshop, error)

func (*Backend) Projects

func (s *Backend) Projects(ctx context.Context) (map[string][]workshop.Project, error)

func (*Backend) RemoveSnapshot

func (s *Backend) RemoveSnapshot(ctx context.Context, snapshot workshop.Snapshot) error

func (*Backend) RemoveWorkshop

func (s *Backend) RemoveWorkshop(ctx context.Context, name string) (err error)

func (*Backend) RemoveWorkshopMount

func (s *Backend) RemoveWorkshopMount(ctx context.Context, name, mount string) error

func (*Backend) RemoveWorkshopStash

func (s *Backend) RemoveWorkshopStash(ctx context.Context, name string) error

func (*Backend) Sdk

func (s *Backend) Sdk(ctx context.Context, setup sdk.Setup) (workshop.SdkVolume, error)

func (*Backend) Sdks

func (s *Backend) Sdks(ctx context.Context) ([]workshop.SdkVolume, error)

func (*Backend) Snapshot

func (s *Backend) Snapshot(ctx context.Context, snapshot workshop.Snapshot) (*workshop.SnapshotInfo, error)

func (*Backend) StartWorkshop

func (s *Backend) StartWorkshop(ctx context.Context, name string) error

func (*Backend) StashWorkshop

func (s *Backend) StashWorkshop(ctx context.Context, name string) error

func (*Backend) StopWorkshop

func (s *Backend) StopWorkshop(ctx context.Context, name string, force bool) error

func (*Backend) TakeSnapshot

func (s *Backend) TakeSnapshot(ctx context.Context, name string, snapshot workshop.Snapshot) error

func (*Backend) UninstallSdk

func (s *Backend) UninstallSdk(ctx context.Context, name, sk string) error

func (*Backend) UnstashWorkshop

func (s *Backend) UnstashWorkshop(ctx context.Context, name string) error

func (*Backend) Workshop

func (s *Backend) Workshop(ctx context.Context, name string) (*workshop.Workshop, error)

func (*Backend) WorkshopFs

func (s *Backend) WorkshopFs(ctx context.Context, name string) (fsutil.Fs, error)

Jump to

Keyboard shortcuts

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