lxd: github.com/lxc/lxd/lxd/instance Index | Files | Directories

package instance

import "github.com/lxc/lxd/lxd/instance"

Index

Package Files

filter.go instance_errors.go instance_exec_cmd.go instance_interface.go instance_utils.go

Constants

const HookStart = "onstart"

HookStart hook used when instance has started.

const HookStop = "onstop"

HookStop hook used when instance has stopped.

const HookStopNS = "onstopns"

HookStopNS hook used when instance has stopped but before namespaces have been destroyed.

Variables

var Create func(s *state.State, args db.InstanceArgs) (Instance, error)

Create is linked from instance/drivers.create to allow difference instance types to be created.

var ErrNotImplemented = fmt.Errorf("Not implemented")

ErrNotImplemented is the "Not implemented" error

var Load func(s *state.State, args db.InstanceArgs, profiles []api.Profile) (Instance, error)

Load is linked from instance/drivers.load to allow different instance types to be loaded.

var ValidDevices func(state *state.State, cluster *db.Cluster, instanceType instancetype.Type, devices deviceConfig.Devices, expanded bool) error

ValidDevices is linked from instance/drivers.validDevices to validate device config.

func AllowedUnprivilegedOnlyMap Uses

func AllowedUnprivilegedOnlyMap(rawIdmap string) error

AllowedUnprivilegedOnlyMap checks that root user is not mapped into instance.

func BackupLoadByName Uses

func BackupLoadByName(s *state.State, project, name string) (*backup.Backup, error)

BackupLoadByName load an instance backup from the database.

func CompareSnapshots Uses

func CompareSnapshots(source Instance, target Instance) ([]Instance, []Instance, error)

CompareSnapshots returns a list of snapshots to sync to the target and a list of snapshots to remove from the target. A snapshot will be marked as "to sync" if it either doesn't exist in the target or its creation date is different to the source. A snapshot will be marked as "to delete" if it doesn't exist in the source or creation date is different to the source.

func DeleteSnapshots Uses

func DeleteSnapshots(s *state.State, projectName, instanceName string) error

DeleteSnapshots calls the Delete() function on each of the supplied instance's snapshots.

func DeviceNextInterfaceHWAddr Uses

func DeviceNextInterfaceHWAddr() (string, error)

DeviceNextInterfaceHWAddr generates a random MAC address.

func Filter Uses

func Filter(instances []*api.Instance, clauses []filter.Clause) []*api.Instance

Filter returns a filtered list of instances that match the given clauses.

func FilterFull Uses

func FilterFull(instances []*api.InstanceFull, clauses []filter.Clause) []*api.InstanceFull

FilterFull returns a filtered list of full instances that match the given clauses.

func LoadInstanceDatabaseObject Uses

func LoadInstanceDatabaseObject(tx *db.ClusterTx, project, name string) (*db.Instance, error)

LoadInstanceDatabaseObject loads a db.Instance object, accounting for snapshots.

func ParseCpuset Uses

func ParseCpuset(cpu string) ([]int, error)

ParseCpuset parses a limits.cpu range into a list of CPU ids.

func ParseRawIdmap Uses

func ParseRawIdmap(value string) ([]idmap.IdmapEntry, error)

ParseRawIdmap parses an IDMAP string.

func ResolveImage Uses

func ResolveImage(s *state.State, project string, source api.InstanceSource) (string, error)

ResolveImage takes an instance source and returns a hash suitable for instance creation or download.

func SuitableArchitectures Uses

func SuitableArchitectures(s *state.State, project string, req api.InstancesPost) ([]int, error)

SuitableArchitectures returns a slice of architecture ids based on an instance create request.

An empty list indicates that the request may be handled by any architecture. A nil list indicates that we can't tell at this stage, typically for private images.

func ValidConfig Uses

func ValidConfig(sysOS *sys.OS, config map[string]string, profile bool, expanded bool) error

ValidConfig validates an instance's config.

func ValidName Uses

func ValidName(instanceName string, isSnapshot bool) error

ValidName validates an instance name. There are different validation rules for instance snapshot names so it takes an argument indicating whether the name is to be used for a snapshot or not.

type Cmd Uses

type Cmd interface {
    Wait() (int, error)
    PID() int
    Signal(s unix.Signal) error
    WindowResize(fd, winchWidth, winchHeight int) error
}

Cmd represents a local or remote command being run.

type ConfigReader Uses

type ConfigReader interface {
    Type() instancetype.Type
    ExpandedConfig() map[string]string
    ExpandedDevices() deviceConfig.Devices
    LocalConfig() map[string]string
    LocalDevices() deviceConfig.Devices
}

ConfigReader is used to read instance config.

type Container Uses

type Container interface {
    Instance

    CurrentIdmap() (*idmap.IdmapSet, error)
    DiskIdmap() (*idmap.IdmapSet, error)
    NextIdmap() (*idmap.IdmapSet, error)
    ConsoleLog(opts liblxc.ConsoleLogOptions) (string, error)
    InsertSeccompUnixDevice(prefix string, m deviceConfig.Device, pid int) error
}

Container interface is for container specific functions.

type CriuMigrationArgs Uses

type CriuMigrationArgs struct {
    Cmd          uint
    StateDir     string
    Function     string
    Stop         bool
    ActionScript bool
    DumpDir      string
    PreDumpDir   string
    Features     liblxc.CriuFeatures
}

CriuMigrationArgs arguments for CRIU migration.

type Instance Uses

type Instance interface {
    ConfigReader

    // Instance actions.
    Freeze() error
    Shutdown(timeout time.Duration) error
    Start(stateful bool) error
    Stop(stateful bool) error
    Unfreeze() error
    RegisterDevices()
    SaveConfigFile() error

    IsPrivileged() bool

    // Snapshots & migration & backups.
    Restore(source Instance, stateful bool) error
    Snapshots() ([]Instance, error)
    Backups() ([]backup.Backup, error)
    UpdateBackupFile() error

    // Config handling.
    Rename(newName string) error
    Update(newConfig db.InstanceArgs, userRequested bool) error

    Delete() error
    Export(w io.Writer, properties map[string]string) error

    // Live configuration.
    CGroupSet(key string, value string) error
    VolatileSet(changes map[string]string) error

    // File handling.
    FileExists(path string) error
    FilePull(srcpath string, dstpath string) (int64, int64, os.FileMode, string, []string, error)
    FilePush(fileType string, srcpath string, dstpath string, uid int64, gid int64, mode int, write string) error
    FileRemove(path string) error

    // Console - Allocate and run a console tty.
    Console() (*os.File, chan error, error)
    Exec(req api.InstanceExecPost, stdin *os.File, stdout *os.File, stderr *os.File) (Cmd, error)

    // Status
    Render(options ...func(response interface{}) error) (interface{}, interface{}, error)
    RenderFull() (*api.InstanceFull, interface{}, error)
    RenderState() (*api.InstanceState, error)
    IsRunning() bool
    IsFrozen() bool
    IsEphemeral() bool
    IsSnapshot() bool
    IsStateful() bool

    // Hooks.
    DeviceEventHandler(*deviceConfig.RunConfig) error
    OnHook(hookName string, args map[string]string) error

    // Properties.
    ID() int
    Location() string
    Project() string
    Name() string
    Description() string
    Architecture() int
    CreationDate() time.Time
    LastUsedDate() time.Time

    Profiles() []string
    InitPID() int
    State() string
    ExpiryDate() time.Time
    FillNetworkDevice(name string, m deviceConfig.Device) (deviceConfig.Device, error)

    // Paths.
    Path() string
    RootfsPath() string
    TemplatesPath() string
    StatePath() string
    LogFilePath() string
    ConsoleBufferLogPath() string
    LogPath() string
    DevicesPath() string

    // Storage.
    StoragePool() (string, error)

    // Migration.
    Migrate(args *CriuMigrationArgs) error

    // Progress reporting.
    SetOperation(op *operations.Operation)

    // FIXME: Those should be internal functions.
    // Needed for migration for now.
    StorageStart() (bool, error)
    StorageStop() (bool, error)
    DeferTemplateApply(trigger string) error
}

Instance interface.

func LoadAllInternal Uses

func LoadAllInternal(s *state.State, dbInstances []db.Instance) ([]Instance, error)

LoadAllInternal loads a list of db insances into a list of instances.

func LoadByID Uses

func LoadByID(s *state.State, id int) (Instance, error)

LoadByID loads an instance by ID.

func LoadByProject Uses

func LoadByProject(s *state.State, project string) ([]Instance, error)

LoadByProject loads all instances in a project.

func LoadByProjectAndName Uses

func LoadByProjectAndName(s *state.State, project, name string) (Instance, error)

LoadByProjectAndName loads an instance by project and name.

func LoadFromAllProjects Uses

func LoadFromAllProjects(s *state.State) ([]Instance, error)

LoadFromAllProjects loads all instances across all projects.

func LoadNodeAll Uses

func LoadNodeAll(s *state.State, instanceType instancetype.Type) ([]Instance, error)

LoadNodeAll loads all instances of this nodes.

Directories

PathSynopsis
drivers
drivers/qmp
instancetype
operationlock

Package instance imports 30 packages (graph) and is imported by 14 packages. Updated 2020-04-03. Refresh now. Tools for package owners.