Documentation ¶
Overview ¶
This is a FLEXible file which can be used by both client and daemon. * Teehee.
That this code needs to exist is kind of dumb, but I'm not sure how else to do it.
Index ¶
- Constants
- Variables
- func AddSlash(path string) string
- func ArchitectureId(arch string) (int, error)
- func ArchitectureName(arch int) (string, error)
- func ArchitecturePersonalities(arch int) ([]int, error)
- func ArchitecturePersonality(arch int) (string, error)
- func AtoiEmptyDefault(s string, def int) (int, error)
- func BlockFsDetect(dev string) (string, error)
- func DebugJson(r *bytes.Buffer)
- func Debugf(format string, args ...interface{})
- func DeepCopy(src, dest interface{}) error
- func ExtractSnapshotName(name string) string
- func FileCopy(source string, dest string) error
- func FileMove(oldPath string, newPath string) error
- func FindOrGenCert(certf string, keyf string) error
- func GenCert(certf string, keyf string) error
- func GetFileStat(p string) (uid int, gid int, major int, minor int, inode uint64, nlink int, err error)
- func GetOwner(path string) (int, int, error)
- func GetTLSConfig(certf string, keyf string) (*tls.Config, error)
- func GroupId(name string) (int, error)
- func GroupName(gid int) (string, error)
- func IntInSlice(key int, list []int) bool
- func InterfaceToBool(value interface{}) bool
- func IsBlockdev(fm os.FileMode) bool
- func IsBlockdevPath(pathName string) bool
- func IsDir(name string) bool
- func IsLoopback(iface *net.Interface) bool
- func IsMountPoint(name string) bool
- func IsOnSharedMount(pathName string) (bool, error)
- func IsSnapshot(name string) bool
- func LogPath(path ...string) string
- func Logf(format string, args ...interface{})
- func MkdirAllOwner(path string, perm os.FileMode, uid int, gid int) error
- func OpenPty(uid, gid int) (master *os.File, slave *os.File, err error)
- func ParseLXDFileHeaders(headers http.Header) (uid int, gid int, mode os.FileMode)
- func ParseMetadata(metadata interface{}) (map[string]interface{}, error)
- func PathExists(name string) bool
- func PathIsEmpty(path string) (bool, error)
- func Pipe() (master *os.File, slave *os.File, err error)
- func PrintStack()
- func RFC3493Dialer(network, address string) (net.Conn, error)
- func RandomCryptoString() (string, error)
- func ReadCert(fpath string) (*x509.Certificate, error)
- func ReadDir(p string) ([]string, error)
- func ReadLastNLines(f *os.File, lines int) (string, error)
- func ReadStdin() ([]byte, error)
- func ReadToJSON(r io.Reader, req interface{}) error
- func ReaderToChannel(r io.Reader) <-chan []byte
- func RunningInUserNS() bool
- func SetSize(fd int, width int, height int) (err error)
- func ShiftOwner(basepath string, path string, uid int, gid int) error
- func SplitExt(fpath string) (string, string)
- func StringInSlice(key string, list []string) bool
- func TextEditor(inPath string, inContent []byte) ([]byte, error)
- func ValidHostname(name string) bool
- func VarPath(path ...string) string
- func WebsocketMirror(conn *websocket.Conn, w io.WriteCloser, r io.ReadCloser) (chan bool, chan bool)
- func WebsocketRecvStream(w io.WriteCloser, conn *websocket.Conn) chan bool
- func WebsocketSendStream(conn *websocket.Conn, r io.Reader) chan bool
- func WriteAll(w io.Writer, buf []byte) error
- func WriteAllBuf(w io.Writer, buf *bytes.Buffer) error
- type BriefContainerState
- type BriefImageInfo
- type BriefServerState
- type BytesReadCloser
- type CertInfo
- type ContainerAction
- type ContainerExecControl
- type ContainerInfo
- type ContainerInfoList
- type ContainerState
- type ContainerStatus
- type Device
- type Devices
- func (list Devices) Contains(k string, d Device) bool
- func (list Devices) ContainsName(k string) bool
- func (newBaseDevices Devices) ExtendFromProfile(currentFullDevices Devices, newDevicesFromProfile Devices) error
- func (old Devices) Update(newlist Devices) (map[string]Device, map[string]Device, map[string]Device)
- type IdmapEntry
- type IdmapSet
- func (m IdmapSet) Append(s string) (IdmapSet, error)
- func (m IdmapSet) Intersects(i IdmapEntry) bool
- func (m IdmapSet) Len() int
- func (set *IdmapSet) ShiftFile(p string) error
- func (m IdmapSet) ShiftFromNs(uid int, gid int) (int, int)
- func (m IdmapSet) ShiftIntoNs(uid int, gid int) (int, int)
- func (set *IdmapSet) ShiftRootfs(p string) error
- func (m IdmapSet) ToLxcString() []string
- func (set *IdmapSet) UidshiftFromContainer(dir string, testmode bool) error
- func (set *IdmapSet) UidshiftIntoContainer(dir string, testmode bool) error
- func (set *IdmapSet) UnshiftRootfs(p string) error
- type ImageAlias
- type ImageAliases
- type ImageBaseInfo
- type ImageInfo
- type ImageProperties
- type Ip
- type Jmap
- type Logger
- type Operation
- type ProfileConfig
- type ServerState
- type ServerStateEnvironment
- type StatusCode
- type StringSet
Constants ¶
const ( ARCH_UNKNOWN = 0 ARCH_32BIT_INTEL_X86 = 1 ARCH_64BIT_INTEL_X86 = 2 ARCH_32BIT_ARMV7_LITTLE_ENDIAN = 3 ARCH_64BIT_ARMV8_LITTLE_ENDIAN = 4 ARCH_32BIT_POWERPC_BIG_ENDIAN = 5 ARCH_64BIT_POWERPC_BIG_ENDIAN = 6 ARCH_64BIT_POWERPC_LITTLE_ENDIAN = 7 ARCH_64BIT_S390_BIG_ENDIAN = 8 )
const DefaultPort = "8443"
const SnapshotDelimiter = "/"
Variables ¶
var APICompat = 1
* Please increment the api compat number every time you change the API. * * Version 1.0: ping
var APIVersion = "1.0"
var UserAgent = "LXD " + Version
var Version = "2.0.0.beta1"
Functions ¶
func AddSlash ¶
AddSlash adds a slash to the end of paths if they don't already have one. This can be useful for rsyncing things, since rsync has behavior present on the presence or absence of a trailing slash.
func ArchitectureId ¶
func ArchitectureName ¶
func ArchitecturePersonality ¶
func BlockFsDetect ¶
func Debugf ¶
func Debugf(format string, args ...interface{})
Debugf sends to the logger registered via SetLogger the string resulting from running format and args through Sprintf, but only if debugging was enabled via SetDebug.
func DeepCopy ¶
func DeepCopy(src, dest interface{}) error
DeepCopy copies src to dest by using encoding/gob so its not that fast.
func ExtractSnapshotName ¶
func FileMove ¶
FileMove tries to move a file by using os.Rename, if that fails it tries to copy the file and remove the source.
func FindOrGenCert ¶
func GetFileStat ¶
func GroupId ¶
GroupId is an adaption from https://codereview.appspot.com/4589049.
func GroupName ¶
GroupName is an adaption from https://codereview.appspot.com/4589049.
func IntInSlice ¶
func InterfaceToBool ¶
func InterfaceToBool(value interface{}) bool
FIXME: InterfaceToBool is there for backward compatibility
func IsBlockdev ¶
func IsBlockdevPath ¶
func IsLoopback ¶
func IsMountPoint ¶
func IsOnSharedMount ¶
func IsSnapshot ¶
func LogPath ¶
LogPath returns the directory that LXD should put logs under. If LXD_DIR is set, this path is $LXD_DIR/logs, otherwise it is /var/log/lxd.
func Logf ¶
func Logf(format string, args ...interface{})
Logf sends to the logger registered via SetLogger the string resulting from running format and args through Sprintf.
func ParseLXDFileHeaders ¶
func ParseMetadata ¶
func PathExists ¶
func PathIsEmpty ¶
PathIsEmpty checks if the given path is empty.
func PrintStack ¶
func PrintStack()
func RandomCryptoString ¶
Returns a random base64 encoded string from crypto/rand.
func ReadToJSON ¶
func ReaderToChannel ¶
func RunningInUserNS ¶
func RunningInUserNS() bool
func StringInSlice ¶
func ValidHostname ¶
func VarPath ¶
VarPath returns the provided path elements joined by a slash and appended to the end of $LXD_DIR, which defaults to /var/lib/lxd.
func WebsocketMirror ¶
func WebsocketMirror(conn *websocket.Conn, w io.WriteCloser, r io.ReadCloser) (chan bool, chan bool)
WebsocketMirror allows mirroring a reader to a websocket and taking the result and writing it to a writer. This function allows for multiple mirrorings and correctly negotiates stream endings. However, it means any websocket.Conns passed to it are live when it returns, and must be closed explicitly.
func WebsocketRecvStream ¶
func WebsocketRecvStream(w io.WriteCloser, conn *websocket.Conn) chan bool
Types ¶
type BriefContainerState ¶
type BriefContainerState struct { Name string `json:"name"` Profiles []string `json:"profiles"` Config map[string]string `json:"config"` Devices Devices `json:"devices"` Ephemeral bool `json:"ephemeral"` }
* BriefContainerState contains a subset of the fields in * ContainerState, namely those which a user may update
type BriefImageInfo ¶
type BriefImageInfo struct { Properties map[string]string `json:"properties"` Public bool `json:"public"` }
* BriefImageInfo contains a subset of the fields in * ImageInfo, namely those which a user may update
type BriefServerState ¶
type BriefServerState struct {
Config map[string]interface{} `json:"config"`
}
type BytesReadCloser ¶
func (BytesReadCloser) Close ¶
func (r BytesReadCloser) Close() error
type CertInfo ¶
type CertInfo struct { Certificate string `json:"certificate"` Fingerprint string `json:"fingerprint"` Type string `json:"type"` }
CertInfo is the representation of a Certificate in the API.
type ContainerAction ¶
type ContainerAction string
const ( Stop ContainerAction = "stop" Start ContainerAction = "start" Restart ContainerAction = "restart" Freeze ContainerAction = "freeze" Unfreeze ContainerAction = "unfreeze" )
type ContainerExecControl ¶
type ContainerInfo ¶
type ContainerInfo struct { State ContainerState `json:"state"` Snaps []string `json:"snaps"` }
type ContainerInfoList ¶
type ContainerInfoList []ContainerInfo
func (ContainerInfoList) Len ¶
func (slice ContainerInfoList) Len() int
func (ContainerInfoList) Less ¶
func (slice ContainerInfoList) Less(i, j int) bool
func (ContainerInfoList) Swap ¶
func (slice ContainerInfoList) Swap(i, j int)
type ContainerState ¶
type ContainerState struct { Architecture int `json:"architecture"` Config map[string]string `json:"config"` Devices Devices `json:"devices"` Ephemeral bool `json:"ephemeral"` ExpandedConfig map[string]string `json:"expanded_config"` ExpandedDevices Devices `json:"expanded_devices"` Name string `json:"name"` Profiles []string `json:"profiles"` Status ContainerStatus `json:"status"` }
func (*ContainerState) BriefState ¶
func (c *ContainerState) BriefState() BriefContainerState
func (*ContainerState) BriefStateExpanded ¶
func (c *ContainerState) BriefStateExpanded() BriefContainerState
type ContainerStatus ¶
type ContainerStatus struct { Status string `json:"status"` StatusCode StatusCode `json:"status_code"` Init int `json:"init"` Processcount int `json:"processcount"` Ips []Ip `json:"ips"` }
type IdmapEntry ¶
type IdmapEntry struct { Isuid bool Isgid bool Hostid int // id as seen on the host - i.e. 100000 Nsid int // id as seen in the ns - i.e. 0 Maprange int }
* One entry in id mapping set - a single range of either * uid or gid mappings.
func Extend ¶
func Extend(slice []IdmapEntry, element IdmapEntry) []IdmapEntry
taken from http://blog.golang.org/slices (which is under BSD licence)
func (*IdmapEntry) Intersects ¶
func (e *IdmapEntry) Intersects(i IdmapEntry) bool
func (*IdmapEntry) ToLxcString ¶
func (e *IdmapEntry) ToLxcString() string
type IdmapSet ¶
type IdmapSet struct {
Idmap []IdmapEntry
}
func (IdmapSet) Intersects ¶
func (m IdmapSet) Intersects(i IdmapEntry) bool
func (*IdmapSet) ShiftRootfs ¶
func (IdmapSet) ToLxcString ¶
func (*IdmapSet) UidshiftFromContainer ¶
func (*IdmapSet) UidshiftIntoContainer ¶
func (*IdmapSet) UnshiftRootfs ¶
type ImageAlias ¶
type ImageAliases ¶
type ImageAliases []ImageAlias
type ImageBaseInfo ¶
type ImageInfo ¶
type ImageInfo struct { Aliases ImageAliases `json:"aliases"` Architecture int `json:"architecture"` Fingerprint string `json:"fingerprint"` Filename string `json:"filename"` Properties map[string]string `json:"properties"` // FIXME: This is an interface{] instead of a bool for backward compatibility Public interface{} `json:"public"` Size int64 `json:"size"` CreationDate int64 `json:"created_at"` ExpiryDate int64 `json:"expires_at"` UploadDate int64 `json:"uploaded_at"` }
func (*ImageInfo) BriefInfo ¶
func (i *ImageInfo) BriefInfo() BriefImageInfo
type ImageProperties ¶
type Logger ¶
type Logger interface { Debug(msg string, ctx ...interface{}) Info(msg string, ctx ...interface{}) Warn(msg string, ctx ...interface{}) Error(msg string, ctx ...interface{}) Crit(msg string, ctx ...interface{}) }
var Log Logger
type Operation ¶
type Operation struct { Id string `json:"id"` Class string `json:"class"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` Status string `json:"status"` StatusCode StatusCode `json:"status_code"` Resources map[string][]string `json:"resources"` Metadata *Jmap `json:"metadata"` MayCancel bool `json:"may_cancel"` Err string `json:"err"` }
type ProfileConfig ¶
type ServerState ¶
type ServerState struct { APICompat int `json:"api_compat"` Auth string `json:"auth"` Environment ServerStateEnvironment `json:"environment"` Config map[string]interface{} `json:"config"` Public bool `json:"public"` }
func (*ServerState) BriefState ¶
func (c *ServerState) BriefState() BriefServerState
type ServerStateEnvironment ¶
type ServerStateEnvironment struct { Addresses []string `json:"addresses"` Architectures []int `json:"architectures"` Driver string `json:"driver"` DriverVersion string `json:"driver_version"` Kernel string `json:"kernel"` KernelArchitecture string `json:"kernel_architecture"` KernelVersion string `json:"kernel_version"` Server string `json:"server"` ServerPid int `json:"server_pid"` ServerVersion string `json:"server_version"` Storage string `json:"storage"` StorageVersion string `json:"storage_version"` }
type StatusCode ¶
type StatusCode int
const ( OperationCreated StatusCode = 100 Started StatusCode = 101 Stopped StatusCode = 102 Running StatusCode = 103 Cancelling StatusCode = 104 Pending StatusCode = 105 Starting StatusCode = 106 Stopping StatusCode = 107 Aborting StatusCode = 108 Freezing StatusCode = 109 Frozen StatusCode = 110 Thawed StatusCode = 111 Success StatusCode = 200 Failure StatusCode = 400 Cancelled StatusCode = 401 )
func FromLXCState ¶
func FromLXCState(state int) StatusCode
* Create a StatusCode from an lxc.State code. N.B.: we accept an int instead * of a lxc.State so that the shared code doesn't depend on lxc, which depends * on liblxc, etc.
func (StatusCode) IsFinal ¶
func (o StatusCode) IsFinal() bool
func (StatusCode) String ¶
func (o StatusCode) String() string