Documentation
¶
Index ¶
- Constants
- Variables
- func AllowedUnprivilegedOnlyMap(rawIdmap string) error
- func BackupLoadByName(s *state.State, project, name string) (*backup.Backup, error)
- func CompareSnapshots(source Instance, target Instance) ([]Instance, []Instance, error)
- func DeleteSnapshots(s *state.State, projectName, instanceName string) error
- func DeviceNextInterfaceHWAddr() (string, error)
- func Filter(instances []*api.Instance, clauses []filter.Clause) []*api.Instance
- func FilterFull(instances []*api.InstanceFull, clauses []filter.Clause) []*api.InstanceFull
- func LoadInstanceDatabaseObject(tx *db.ClusterTx, project, name string) (*db.Instance, error)
- func ParseCpuset(cpu string) ([]int, error)
- func ParseRawIdmap(value string) ([]idmap.IdmapEntry, error)
- func ResolveImage(s *state.State, project string, source api.InstanceSource) (string, error)
- func SuitableArchitectures(s *state.State, project string, req api.InstancesPost) ([]int, error)
- func ValidConfig(sysOS *sys.OS, config map[string]string, profile bool, expanded bool) error
- func ValidName(instanceName string, isSnapshot bool) error
- type Cmd
- type ConfigReader
- type Container
- type CriuMigrationArgs
- type Instance
- func LoadAllInternal(s *state.State, dbInstances []db.Instance) ([]Instance, error)
- func LoadByID(s *state.State, id int) (Instance, error)
- func LoadByProject(s *state.State, project string) ([]Instance, error)
- func LoadByProjectAndName(s *state.State, project, name string) (Instance, error)
- func LoadFromAllProjects(s *state.State) ([]Instance, error)
- func LoadNodeAll(s *state.State, instanceType instancetype.Type) ([]Instance, error)
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.
Functions ¶
func AllowedUnprivilegedOnlyMap ¶
AllowedUnprivilegedOnlyMap checks that root user is not mapped into instance.
func BackupLoadByName ¶
BackupLoadByName load an instance backup from the database.
func CompareSnapshots ¶
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 ¶
DeleteSnapshots calls the Delete() function on each of the supplied instance's snapshots.
func DeviceNextInterfaceHWAddr ¶
DeviceNextInterfaceHWAddr generates a random MAC address.
func FilterFull ¶
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 ¶
LoadInstanceDatabaseObject loads a db.Instance object, accounting for snapshots.
func ParseCpuset ¶
ParseCpuset parses a limits.cpu range into a list of CPU ids.
func ParseRawIdmap ¶
func ParseRawIdmap(value string) ([]idmap.IdmapEntry, error)
ParseRawIdmap parses an IDMAP string.
func ResolveImage ¶
ResolveImage takes an instance source and returns a hash suitable for instance creation or download.
func SuitableArchitectures ¶
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 ¶
ValidConfig validates an instance's config.
Types ¶
type Cmd ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
LoadAllInternal loads a list of db instances into a list of instances.
func LoadByProject ¶
LoadByProject loads all instances in a project.
func LoadByProjectAndName ¶
LoadByProjectAndName loads an instance by project and name.
func LoadFromAllProjects ¶
LoadFromAllProjects loads all instances across all projects.
func LoadNodeAll ¶
LoadNodeAll loads all instances of this nodes.