Documentation ¶
Index ¶
- Constants
- Variables
- func AnnotateLXDError(name string, err error) error
- func BaseName(file string) string
- func FileExists(server lxd.InstanceServer, container string, file string) bool
- func NopCloser(r io.Writer) io.WriteCloser
- func PrintConfigYaml(config *Config) error
- func RandomDeviceName() string
- func RootCommand() *command.SimpleCommand
- func RootPaths(paths []string) []string
- func SplitSnapshotName(name string) (container, snapshot string)
- func WaitForNetwork(server lxd.InstanceServer, container string) error
- type Config
- type ConfigInherit
- type ConfigOps
- type ConfigOptions
- func (t *ConfigOptions) Configured() error
- func (t *ConfigOptions) CurrentProject() string
- func (t *ConfigOptions) Init() error
- func (t *ConfigOptions) Instance(file string) (*Instance, error)
- func (t *ConfigOptions) InstanceFunc(f func(*Instance) error, multiple bool) func(configs []string) error
- func (t *ConfigOptions) ReadConfig(file string) (*Config, error)
- func (t *ConfigOptions) RunInstances(f func(*Instance) error, args ...string) error
- func (t *ConfigOptions) UpdateConfig(config *Config)
- type ConfigReader
- type ConfigTop
- type Configurer
- func (t *Configurer) ConfigureContainer(instance *Instance) error
- func (t *Configurer) Configured() error
- func (t *Configurer) CurrentProject() string
- func (t *Configurer) Init() error
- func (t *Configurer) NewExec(project string, name string) *execRunner
- func (t *Configurer) NewScript() *script.Script
- type ContainerDevicesOp
- type ContainerOps
- func (t *ContainerOps) Config(container string) error
- func (t *ContainerOps) Configured() error
- func (t *ContainerOps) Network(container string) error
- func (t *ContainerOps) Profiles(container string) error
- func (t *ContainerOps) State(container string, action ...string) error
- func (t *ContainerOps) Wait(args []string) error
- type ContainerSource
- type Device
- type DeviceConfigurer
- func (t *DeviceConfigurer) ConfigureDevices(instance *Instance) error
- func (t *DeviceConfigurer) CreateDir(dir string, chown bool) error
- func (t *DeviceConfigurer) CreateFilesystem(fs *InstanceFS, originDataset string) error
- func (t *DeviceConfigurer) CreateFilesystems(instance, origin *Instance, snapshot string) error
- func (t *DeviceConfigurer) CreateProfile(instance *Instance) error
- func (t *DeviceConfigurer) NewScript() *script.Script
- func (t *DeviceConfigurer) RenameFilesystems(oldInstance, newInstance *Instance) error
- type DeviceSource
- type Doas
- type DryRun
- type File
- type Filesystem
- type HostPath
- type Ids
- type Instance
- func (t *Instance) Container() string
- func (t *Instance) ContainerSource() *ContainerSource
- func (t *Instance) DeviceDir(deviceId string, device *Device) (string, error)
- func (t *Instance) DeviceList() ([]InstanceDevice, error)
- func (t *Instance) DeviceSource() *DeviceSource
- func (t *Instance) FilesystemList() ([]*InstanceFS, error)
- func (t *Instance) Filesystems() (map[string]*InstanceFS, error)
- func (t *Instance) GetSourceConfig() (*Config, error)
- func (t *Instance) NewDeviceMap() (map[string]map[string]string, error)
- func (t *Instance) NewInstance(name string) (*Instance, error)
- func (instance *Instance) PrintDevices() error
- func (t *Instance) ProfileName() string
- func (instance *Instance) Snapshot(name string) error
- type InstanceDevice
- type InstanceDeviceList
- type InstanceFS
- type InstanceFSList
- type InstanceOps
- func (t *InstanceOps) Configured() error
- func (t *InstanceOps) CurrentProject() string
- func (t *InstanceOps) Description(instance *Instance) error
- func (t *InstanceOps) Devices(instance *Instance) error
- func (t *InstanceOps) Filesystems(instance *Instance) error
- func (t *InstanceOps) Init() error
- func (t *InstanceOps) Packages(instance *Instance) error
- func (t *InstanceOps) Project(instance *Instance) error
- func (t *InstanceOps) Properties(instance *Instance) error
- func (t *InstanceOps) Verify(instance *Instance) error
- type InstanceServer
- type Launcher
- func (t *Launcher) Configured() error
- func (t *Launcher) CreateDevices(instance *Instance) error
- func (t *Launcher) CreateProfile(instance *Instance) error
- func (t *Launcher) CurrentProject() string
- func (t *Launcher) DeleteContainer(instance *Instance) error
- func (t *Launcher) Init() error
- func (t *Launcher) LaunchContainer(instance *Instance) error
- func (t *Launcher) NewConfigurer() *Configurer
- func (t *Launcher) NewScript() *script.Script
- func (t *Launcher) Rebuild(instance *Instance) error
- func (t *Launcher) Rename(configFile string, newname string) error
- type LxdClient
- type LxdOps
- type OS
- type OSType
- type ParseOp
- type Path
- type Pattern
- type ProfileConfigurer
- func (t *ProfileConfigurer) Apply(instance *Instance) error
- func (t *ProfileConfigurer) Configured() error
- func (t *ProfileConfigurer) CurrentProject() string
- func (t *ProfileConfigurer) Diff(instance *Instance) error
- func (t *ProfileConfigurer) Init() error
- func (t *ProfileConfigurer) List(instance *Instance) error
- func (t *ProfileConfigurer) NewScript() *script.Script
- func (t *ProfileConfigurer) Profiles(instance *Instance) ([]string, error)
- func (t *ProfileConfigurer) Reorder(instance *Instance) error
- type ProjectCopyProfiles
- type ProjectCreate
- type PropertyOptions
- type RebuildOptions
- type Script
- type Snapshot
- type SnapshotParams
- type Source
- type Sudo
- type Trace
- type User
Constants ¶
const DefaultProject = "default"
Variables ¶
var OSTypes map[string]OSType
Functions ¶
func AnnotateLXDError ¶
func FileExists ¶
func FileExists(server lxd.InstanceServer, container string, file string) bool
func NopCloser ¶
func NopCloser(r io.Writer) io.WriteCloser
NopCloser returns a ReadCloser with a no-op Close method wrapping the provided Reader r.
func PrintConfigYaml ¶
func RandomDeviceName ¶
func RandomDeviceName() string
func RootCommand ¶
func RootCommand() *command.SimpleCommand
func RootPaths ¶
RootPaths returns a copy of paths , removing any path that is a descendant of another one
func SplitSnapshotName ¶
func WaitForNetwork ¶
func WaitForNetwork(server lxd.InstanceServer, container string) error
Types ¶
type Config ¶
type Config struct { // ConfigTop fields are not merged with included files ConfigTop `yaml:",inline"` // ConfigInherit fields are merged with all included files, depth first ConfigInherit `yaml:",inline"` }
Config - Instance configuration An instance is a name that is used to launch a container or create LXD disk devices, typically both. The instance name, is the same as the base name of the config file, without the extension. It can be overridden by the -name flag Configuration sections are applied in the order that they are mentioned in the Config: - PreScripts - Packages - Users - Files - Scripts - Passwords
func ReadConfig ¶
func ReadRawConfig ¶
* Read config without includes
func (*Config) Filesystem ¶
func (t *Config) Filesystem(id string) *Filesystem
Return the filesystem for the given id, or nil if it doesn't exist.
func (*Config) ResolvePaths ¶
func (*Config) VerifyFileExists ¶
* Check that the requirements are met
type ConfigInherit ¶
type ConfigInherit struct { // Properties provide key-value pairs used for pattern substitution. // They override built-in properties // Properties from all included files are merged before they are applied. Properties cannot override non-empty properties, // in order to avoid unexpected behavior that depends on the order of included files. Properties map[string]string `yaml:"properties"` OS *OS // Project is the LXD project where the container is Project string `yaml:"project"` // Experimental: The name of the container. Defaults to (instance) Container Pattern `yaml:"container,omitempty"` // ProfilePattern specifies how the instance profile should be named. // It defaults to "(instance).lxdops" Profile Pattern `yaml:"profile-pattern"` // ProfileConfig specifies Config entries to be added to the instance profile. // This was meant for creating templates with boot.autostart: "false", // without needing to use profiles external to lxdops. ProfileConfig map[string]string `yaml:"profile-config"` // Source specifies where to copy or clone the instance from Source `yaml:",inline"` // Extra options passed to lxc launch. LxcOptions []string `yaml:"lxc-options,omitempty,flow"` // Include is a list of other configs that are to be included. // Include paths are either absolute or relative to the path of the including config. Include []HostPath `yaml:"include,omitempty"` // Filesystems are zfs filesystems or plain directories that are created // when an instance is created. Devices are created inside filesystems. Filesystems map[string]*Filesystem `yaml:"filesystems"` // Devices are disk devices that are directories within the instance filesystems // They are created and attached to the container via the instance profile Devices map[string]*Device `yaml:"devices"` Profiles []string `yaml:"profiles"` // PreScripts are scripts that are executed early, before packages, users, files, or Scripts PreScripts []*Script `yaml:"pre-scripts"` // Packages are OS packages that are installed when the instance is launched Packages []string `yaml:"packages"` // Users are OS users that are created when the instance is launched Users []*User `yaml:"users"` // Files are files that are copied from the host to the container when the instance is launched (as with lxc file push). Files []*File `yaml:"files"` // Scripts are scripts that are executed in the container (as with lxc exec) Scripts []*Script `yaml:"scripts"` // Passwords are a list of OS accounts, whose password is set to a random password Passwords []string `yaml:"passwords"` }
type ConfigOptions ¶
type ConfigOptions struct { Project string `name:"project" usage:"the LXD project to use. Overrides Config.Project"` Name string `` /* 154-byte string literal not displayed */ Properties []string `` /* 132-byte string literal not displayed */ PropertyOptions // contains filtered or unexported fields }
func (*ConfigOptions) Configured ¶
func (t *ConfigOptions) Configured() error
func (*ConfigOptions) CurrentProject ¶
func (t *ConfigOptions) CurrentProject() string
func (*ConfigOptions) Init ¶
func (t *ConfigOptions) Init() error
func (*ConfigOptions) InstanceFunc ¶
func (*ConfigOptions) ReadConfig ¶
func (t *ConfigOptions) ReadConfig(file string) (*Config, error)
func (*ConfigOptions) RunInstances ¶
func (t *ConfigOptions) RunInstances(f func(*Instance) error, args ...string) error
func (*ConfigOptions) UpdateConfig ¶
func (t *ConfigOptions) UpdateConfig(config *Config)
type ConfigReader ¶
type ConfigTop ¶
type ConfigTop struct { // Description is provided for documentation Description string `yaml:"description"` // Stop specifies that the container should be stopped at the end of the configuration Stop bool `yaml:"stop"` // Snapshot specifies that that the container should be snapshoted with this name at the end of the configuration process. Snapshot string `yaml:"snapshot"` }
type Configurer ¶
type Configurer struct { Client *LxdClient `name:"-"` ConfigOptions Trace bool `name:"trace,t" usage:"print exec arguments"` DryRun bool `name:"dry-run" usage:"show the commands to run, but do not change anything"` Components []string `name:"components" usage:"which components to configure: packages, scripts, users"` All bool `` /* 142-byte string literal not displayed */ Packages bool `name:"packages" usage:"whether to install packages"` Scripts bool `name:"scripts" usage:"whether to run scripts"` Files bool `name:"files" usage:"whether to copy files"` Users bool `name:"users" usage:"whether to create users and change passwords"` }
func (*Configurer) ConfigureContainer ¶
func (t *Configurer) ConfigureContainer(instance *Instance) error
* run things inside the container: install packages, create users, run scripts
func (*Configurer) Configured ¶
func (t *Configurer) Configured() error
func (*Configurer) CurrentProject ¶
func (t *Configurer) CurrentProject() string
func (*Configurer) Init ¶
func (t *Configurer) Init() error
func (*Configurer) NewExec ¶
func (t *Configurer) NewExec(project string, name string) *execRunner
func (*Configurer) NewScript ¶
func (t *Configurer) NewScript() *script.Script
type ContainerDevicesOp ¶
type ContainerDevicesOp struct { ContainerOps *ContainerOps `name:""` Yaml bool }
func (*ContainerDevicesOp) Devices ¶
func (t *ContainerDevicesOp) Devices(container string) error
type ContainerOps ¶
type ContainerOps struct { Client *LxdClient `name:"-"` // contains filtered or unexported fields }
func (*ContainerOps) Config ¶
func (t *ContainerOps) Config(container string) error
func (*ContainerOps) Configured ¶
func (t *ContainerOps) Configured() error
func (*ContainerOps) Network ¶
func (t *ContainerOps) Network(container string) error
func (*ContainerOps) Profiles ¶
func (t *ContainerOps) Profiles(container string) error
func (*ContainerOps) Wait ¶
func (t *ContainerOps) Wait(args []string) error
type ContainerSource ¶
func (*ContainerSource) IsDefined ¶
func (t *ContainerSource) IsDefined() bool
func (*ContainerSource) String ¶
func (t *ContainerSource) String() string
type Device ¶
type Device struct { // Path is the device "path" in the LXD disk device Path string // Filesystem is the Filesystem Id that this device belongs to Filesystem string `yaml:"filesystem"` // Dir is the subdirectory of the Device, relative to its Filesystem // If empty, it default to the device Name // If Dir == ".", the device source is the same as the Filesystem directory // Rarely used: // Dir goes through pattern substitution, using parenthesized tokens, for example (instance) // Dir may be absolute, but this is no longer necessary now that filesystems are specified, since one can define the "/" filesystem. Dir Pattern `yaml:""` }
A Device is an LXD disk device that is attached to the instance profile, which in turn is attached to a container
type DeviceConfigurer ¶
type DeviceConfigurer struct { Client *LxdClient Config *Config Trace bool DryRun bool FuncMap map[string]func() (string, error) }
func NewDeviceConfigurer ¶
func NewDeviceConfigurer(client *LxdClient, config *Config) *DeviceConfigurer
func (*DeviceConfigurer) ConfigureDevices ¶
func (t *DeviceConfigurer) ConfigureDevices(instance *Instance) error
func (*DeviceConfigurer) CreateDir ¶
func (t *DeviceConfigurer) CreateDir(dir string, chown bool) error
func (*DeviceConfigurer) CreateFilesystem ¶
func (t *DeviceConfigurer) CreateFilesystem(fs *InstanceFS, originDataset string) error
func (*DeviceConfigurer) CreateFilesystems ¶
func (t *DeviceConfigurer) CreateFilesystems(instance, origin *Instance, snapshot string) error
func (*DeviceConfigurer) CreateProfile ¶
func (t *DeviceConfigurer) CreateProfile(instance *Instance) error
func (*DeviceConfigurer) NewScript ¶
func (t *DeviceConfigurer) NewScript() *script.Script
func (*DeviceConfigurer) RenameFilesystems ¶
func (t *DeviceConfigurer) RenameFilesystems(oldInstance, newInstance *Instance) error
type DeviceSource ¶
func (*DeviceSource) IsDefined ¶
func (t *DeviceSource) IsDefined() bool
func (*DeviceSource) String ¶
func (t *DeviceSource) String() string
type DryRun ¶
type DryRun struct {
DryRun bool `name:"dry-run" usage:"show the commands to run, but do not change anything"`
}
type File ¶
type File struct { // Path is the file path in the container Path string // Source is the file path on the host Source HostPath // The file's mode as a string, e.g. 0775 Mode string // Uid is the file's numeric uid in the container Uid int // Gid is the file's numeric gid in the container Gid int // User is the file's owner name in the container. It is an error if both uid and user are set. User string // Group is the file's group owner name in the container. It is an error if both gid and group are set. Group string }
File specifies a file that is copied from the host to the container
type Filesystem ¶
type Filesystem struct { // Pattern is a pattern that is used to produce the directory or zfs filesystem // If the pattern begins with '/', it is a directory // If it does not begin with '/', it is a zfs filesystem name Pattern Pattern // Zfsproperties is a list of properties that are set when a zfs filesystem is created or cloned Zfsproperties map[string]string `yaml:""` }
Filesystem is a ZFS filesystem or a plain directory that is created when an instance is created The disk devices of an instance are created as subdirectories of a Filesystem
type HostPath ¶
type HostPath string
HostPath is a file path on the host, which is either absolute or relative to a base directory When a config file includes another config file, the base directory is the directory of the including file
type Instance ¶
type Instance struct { GlobalProperties map[string]string Config *Config Name string Properties *util.PatternProperties // contains filtered or unexported fields }
func NewInstance ¶
func (*Instance) ContainerSource ¶
func (t *Instance) ContainerSource() *ContainerSource
func (*Instance) DeviceList ¶
func (t *Instance) DeviceList() ([]InstanceDevice, error)
func (*Instance) DeviceSource ¶
func (t *Instance) DeviceSource() *DeviceSource
func (*Instance) FilesystemList ¶
func (t *Instance) FilesystemList() ([]*InstanceFS, error)
func (*Instance) Filesystems ¶
func (t *Instance) Filesystems() (map[string]*InstanceFS, error)
func (*Instance) GetSourceConfig ¶
GetSourceConfig returns the parsed configuration specified by Config.SourceConfig If there is no Config.SourceConfig, it returns this instance's config It returns a non nil *Config or an error.
func (*Instance) NewDeviceMap ¶
func (*Instance) PrintDevices ¶
func (*Instance) ProfileName ¶
type InstanceDevice ¶
type InstanceDeviceList ¶
type InstanceDeviceList []InstanceDevice
func (InstanceDeviceList) Len ¶
func (t InstanceDeviceList) Len() int
func (InstanceDeviceList) Less ¶
func (t InstanceDeviceList) Less(i, j int) bool
func (InstanceDeviceList) Sort ¶
func (t InstanceDeviceList) Sort()
func (InstanceDeviceList) Swap ¶
func (t InstanceDeviceList) Swap(i, j int)
type InstanceFS ¶
type InstanceFS struct { Id string Path string IsNew bool Filesystem *Filesystem }
func (*InstanceFS) Dir ¶
func (t *InstanceFS) Dir() string
func (*InstanceFS) IsDir ¶
func (t *InstanceFS) IsDir() bool
func (*InstanceFS) IsZfs ¶
func (t *InstanceFS) IsZfs() bool
type InstanceFSList ¶
type InstanceFSList []*InstanceFS
func (InstanceFSList) Len ¶
func (t InstanceFSList) Len() int
func (InstanceFSList) Less ¶
func (t InstanceFSList) Less(i, j int) bool
func (InstanceFSList) Roots ¶
func (t InstanceFSList) Roots() []*InstanceFS
Roots returns the FSPaths that are not children of other FSPaths, within this set.
func (InstanceFSList) Sort ¶
func (t InstanceFSList) Sort()
func (InstanceFSList) Swap ¶
func (t InstanceFSList) Swap(i, j int)
type InstanceOps ¶
type InstanceOps struct { ConfigOptions Trace bool DryRun bool `name:"dry-run" usage:"show the commands to run, but do not change anything"` }
func (*InstanceOps) Configured ¶
func (t *InstanceOps) Configured() error
func (*InstanceOps) CurrentProject ¶
func (t *InstanceOps) CurrentProject() string
func (*InstanceOps) Description ¶
func (t *InstanceOps) Description(instance *Instance) error
Description prints the description of the instance
func (*InstanceOps) Devices ¶
func (t *InstanceOps) Devices(instance *Instance) error
func (*InstanceOps) Filesystems ¶
func (t *InstanceOps) Filesystems(instance *Instance) error
func (*InstanceOps) Init ¶
func (t *InstanceOps) Init() error
func (*InstanceOps) Packages ¶
func (t *InstanceOps) Packages(instance *Instance) error
Packages prints the packages installed by the instance
func (*InstanceOps) Project ¶
func (t *InstanceOps) Project(instance *Instance) error
func (*InstanceOps) Properties ¶
func (t *InstanceOps) Properties(instance *Instance) error
Properties prints the instance properties
func (*InstanceOps) Verify ¶
func (t *InstanceOps) Verify(instance *Instance) error
type InstanceServer ¶
type InstanceServer struct {
Server lxd.InstanceServer
}
func (InstanceServer) ProfileExists ¶
func (t InstanceServer) ProfileExists(profile string) bool
func (InstanceServer) StartContainer ¶
func (t InstanceServer) StartContainer(container string) error
func (InstanceServer) StopContainer ¶
func (t InstanceServer) StopContainer(container string) error
type Launcher ¶
type Launcher struct { Client *LxdClient `name:"-"` ConfigOptions Trace bool `name:"t" usage:"trace print what is happening"` DryRun bool `name:"dry-run" usage:"show the commands to run, but do not change anything"` }
func (*Launcher) Configured ¶
func (*Launcher) CreateDevices ¶
func (*Launcher) CreateProfile ¶
func (*Launcher) CurrentProject ¶
func (t *Launcher) CurrentProject() string
func (*Launcher) DeleteContainer ¶
func (*Launcher) LaunchContainer ¶
func (*Launcher) NewConfigurer ¶
func (t *Launcher) NewConfigurer() *Configurer
type LxdClient ¶
type LxdClient struct { Socket string // contains filtered or unexported fields }
func (*LxdClient) CurrentProject ¶
func (t *LxdClient) CurrentProject() string
func (*LxdClient) ProjectServer ¶
func (t *LxdClient) ProjectServer(project string) (lxd.InstanceServer, error)
func (*LxdClient) RootServer ¶
func (t *LxdClient) RootServer() (lxd.InstanceServer, error)
type LxdOps ¶
type LxdOps struct { Client *LxdClient `name:"-"` Trace bool `name:"trace,t" usage:"print exec arguments"` }
func (*LxdOps) AddDiskDevice ¶
func (*LxdOps) ProfileExists ¶
type OS ¶
type OS struct { // Name if the name of the container image, without the version number. // All included configuration files should have the same OS Name. // Supported OS names are "alpine", "debian", "ubuntu". // Support for an OS is the ability to determine the LXD image, install packages, create users, set passwords Name string `yaml:"name"` // Version is the image version, e.g. 3.13, 10.04. The image name is composed of Name/Version // Version is optional in configuration files, but the final assembled configuration file should have a OS Version. // It should typically be specified in one configuration file that is included by all other configuration files that use use this OS Version string `yaml:"version"` // contains filtered or unexported fields }
OS specifies the container OS
type ParseOp ¶
type Path ¶
type Path string
func (Path) IsDescendantOf ¶
IsDescendantOf returns true if c is under p's filesystem hierarchy
type Pattern ¶
type Pattern string
Pattern is a string that is converted via property substitution, before it is used Properties are denoted in the pattern via (<key>), where <key> is the property key There are built-in properties like instance, project. Custom properties are defined in Config.Properties, and override built-in properties
func (Pattern) Substitute ¶
func (pattern Pattern) Substitute(properties *util.PatternProperties) (string, error)
type ProfileConfigurer ¶
type ProfileConfigurer struct { Client *LxdClient ConfigOptions Trace bool DryRun bool `name:"dry-run" usage:"show the commands to run, but do not change anything"` }
func (*ProfileConfigurer) Apply ¶
func (t *ProfileConfigurer) Apply(instance *Instance) error
func (*ProfileConfigurer) Configured ¶
func (t *ProfileConfigurer) Configured() error
func (*ProfileConfigurer) CurrentProject ¶
func (t *ProfileConfigurer) CurrentProject() string
func (*ProfileConfigurer) Diff ¶
func (t *ProfileConfigurer) Diff(instance *Instance) error
func (*ProfileConfigurer) Init ¶
func (t *ProfileConfigurer) Init() error
func (*ProfileConfigurer) List ¶
func (t *ProfileConfigurer) List(instance *Instance) error
func (*ProfileConfigurer) NewScript ¶
func (t *ProfileConfigurer) NewScript() *script.Script
func (*ProfileConfigurer) Profiles ¶
func (t *ProfileConfigurer) Profiles(instance *Instance) ([]string, error)
func (*ProfileConfigurer) Reorder ¶
func (t *ProfileConfigurer) Reorder(instance *Instance) error
type ProjectCopyProfiles ¶
type ProjectCopyProfiles struct { Client *LxdClient `name:"-"` SourceProject string `name:"source-project" usage:"project to copy profiles from"` TargetProject string `name:"target-project" usage:"project to copy profiles to"` }
func (*ProjectCopyProfiles) CopyProfiles ¶
func (t *ProjectCopyProfiles) CopyProfiles(profiles []string) error
type ProjectCreate ¶
type ProjectCreate struct {
Client *LxdClient `name:"-"`
}
func (*ProjectCreate) Create ¶
func (t *ProjectCreate) Create(projects ...string) error
type PropertyOptions ¶
type PropertyOptions struct { PropertiesFile string `name:"properties" usage:"a file containing global config properties. Instance properties override global properties"` GlobalProperties map[string]string `name:"-"` }
func (*PropertyOptions) Configured ¶
func (t *PropertyOptions) Configured() error
func (*PropertyOptions) File ¶
func (t *PropertyOptions) File()
func (*PropertyOptions) Init ¶
func (t *PropertyOptions) Init() error
func (*PropertyOptions) List ¶
func (t *PropertyOptions) List()
func (*PropertyOptions) Set ¶
func (t *PropertyOptions) Set(key, value string) error
type RebuildOptions ¶
type Script ¶
type Script struct { // An optional name that identifies the script, useful for debugging/testing Name string `yaml:"name"` // File is an optional host file that contains the script content. // It should be an executable. It is copied to the container in /root/ and run there. File HostPath `yaml:"file"` // Reboot specifies that the container should be rebooted after running this script // This may be needed when replacing /etc files // Reboot may be slow, so avoid it, if possible Reboot bool `yaml:"reboot"` // Body is the content of the script // It is passed as the stdin to sh Body string `yaml:"body"` // Dir is the directory in the container to set as the working directory when running the script Dir string `yaml:"dir"` // Uid is the container uid to run the script as Uid uint32 `yaml:"uid"` // Gid is the container gid to run the script as Gid uint32 `yaml:"gid"` }
Script specifies a sh script that is run in the container
type Snapshot ¶
type Snapshot struct { ConfigOptions SnapshotParams }
func (*Snapshot) Configured ¶
func (*Snapshot) CurrentProject ¶
func (t *Snapshot) CurrentProject() string
func (*Snapshot) DestroySnapshot ¶
type SnapshotParams ¶
type SnapshotParams struct { DryRun bool `name:"dry-run" usage:"show the commands to run, but do not change anything"` Snapshot string `name:"s" usage:"short snapshot name"` Destroy bool `name:"d" usage:"destroy snapshots"` Recursive bool `name:"R" usage:"zfs destroy -R: Recursively destroy all dependents, including cloned datasets"` }
type Source ¶
type Source struct { // origin is the name of a container and a snapshot to clone from. // It has the form [<project>_]<container>[/<snapshot>] // It overrides SourceConfig Origin Pattern `yaml:"origin"` // device-template is the name of an instance, whose devices are copied (using rsync) // to a new instance with launch. // The devices are copied from the filesystems specified in SourceConfig, or this config. DeviceTemplate Pattern `yaml:"device-template"` // device-origin is the name an instance and s short snapshot name. // It has the form <instance>@<snapshot> where <instance> is an instance name, // and @<snapshot> is a the short snapshot name of the instance filesystems. // Each device zfs filesystem is cloned from @<snapshot> // The filesytems are those specified in SourceConfig, if any, otherwise this config. DeviceOrigin Pattern `yaml:"device-origin"` // Experimental: source-config specifies a config file that is used to determine: // - The LXD project, container, and snapshot to clone when launching the instance. // - The source filesystems used for cloning filesystems or copying device directories. // The name of the instance used for the source filesystems // is the base name of the filename, without the extension. // Various parts of these items can be overriden by other source properties above SourceConfig HostPath `yaml:"source-config,omitempty"` }
Source specifies how to copy or clone the instance container, filesystem, and device directories. When DeviceTemplate is specified, the filesystems are copied with rsync. When DeviceOrigin is specified, the filesystems are cloned with zfs-clone The filesystems that are copied are determined by applying the source instance name to the filesystems of this config, or to the filesystems of a source config.
When basing an instance on a template with few skeleton files, it is preferable to copy with a DeviceTemplate, so the container's disk devices are not tied to the template.
Example: suppose test-a.yaml has:
origin: a/copy filesystems: "default": "z/test/(instance)" device-origin: a@copy source-filesystems "default": "z/prod/(instance)" devices: home, path=/home, filesystem=default
This would do something like:
zfs clone z/prod/a@copy z/test/test-a lxc copy --container-only a/copy test-a lxc profile create test-a.lxdops lxc profile device add test-a.lxdops home disk path=/home source=/z/test/test-a/home lxc profile add test-a test-a.lxdops
type User ¶
type User struct { // Name is the user name. If missing, the user takes the name of current host user Name string `yaml:"name"` // Uid is an optional uid for the user Uid string `yaml:"uid"` // Sudo gives full passwordless sudo privileges to the user Sudo bool `yaml:"sudo"` // Ssh specifies that the current user's ~.ssh/authorized_keys should be copied from the host to this user Ssh bool `yaml:"ssh"` // Shell is the user shell Shell string `yaml:"shell"` // Home is the user home directory, optional Home string `yaml:"home"` // Groups is a list of groups that the user is added to Groups []string `yaml:"groups"` }
An OS user
func (*User) EffectiveUser ¶
func (*User) IsValidName ¶
Source Files ¶
- Config.go
- ConfigOptions.go
- ConfigYaml.go
- Configurer.go
- DeviceConfigurer.go
- Launcher.go
- LxdOps.go
- OS.go
- ProfileConfigurer.go
- commands.go
- config_methods.go
- config_read.go
- container.go
- device.go
- exec.go
- fs.go
- ids.go
- instance-ops.go
- instance.go
- lxc_config.go
- lxd.go
- lxdclient.go
- parse-ops.go
- path.go
- project.go
- property.go
- random.go
- snapshot.go
- source.go