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 ArchitectureGetLocal() (string, error)
- 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 GenerateMemCert() ([]byte, []byte, 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 GetRemoteCertificate(address string) (*x509.Certificate, error)
- func GetTLSConfig(tlsClientCertFile string, tlsClientKeyFile string, ...) (*tls.Config, error)
- func GetTLSConfigMem(tlsClientCert string, tlsClientKey string, tlsRemoteCertPEM string) (*tls.Config, error)
- func GroupId(name string) (int, error)
- func GroupName(gid int) (string, error)
- func IntInSlice(key int, list []int) 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 ParseBitSizeString(input string) (int64, error)
- func ParseByteSizeString(input string) (int64, 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 BriefContainerInfo
- type BriefImageInfo
- type BriefServerState
- type BytesReadCloser
- type CertInfo
- type ContainerAction
- type ContainerExecControl
- type ContainerInfo
- type ContainerState
- type ContainerStateDisk
- type ContainerStateMemory
- type ContainerStateNetwork
- type ContainerStateNetworkAddress
- type ContainerStateNetworkCounters
- 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 ImageAliasesEntry
- type ImageInfo
- type ImageProperties
- type ImageSource
- type Jmap
- type Logger
- type Operation
- type ProfileConfig
- type ServerState
- type ServerStateEnvironment
- type SimpleStreams
- func (s *SimpleStreams) Download(image string, file string, target string, progress func(int)) error
- func (s *SimpleStreams) ExportImage(image string, target string) (string, error)
- func (s *SimpleStreams) GetAlias(name string) string
- func (s *SimpleStreams) GetImageInfo(fingerprint string) (*ImageInfo, error)
- func (s *SimpleStreams) ListAliases() (ImageAliases, error)
- func (s *SimpleStreams) ListImages() ([]ImageInfo, error)
- type SimpleStreamsIndex
- type SimpleStreamsIndexStream
- type SimpleStreamsManifest
- type SimpleStreamsManifestProduct
- type SimpleStreamsManifestProductVersion
- type SimpleStreamsManifestProductVersionItem
- type SnapshotInfo
- type StatusCode
- type StringSet
- type TransferProgress
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 ArchitectureDefault = "x86_64"
const DefaultPort = "8443"
const SnapshotDelimiter = "/"
Variables ¶
var APIVersion = "1.0"
* Please increment the api compat number every time you change the API. * * Version 1.0: ping
var UserAgent = "LXD " + Version
var Version = "2.0.0.rc2"
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 ArchitectureGetLocal ¶
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 GenerateMemCert ¶
GenerateMemCert creates a certificate and key pair, returning them as byte arrays in memory.
func GetFileStat ¶
func GetRemoteCertificate ¶
func GetRemoteCertificate(address string) (*x509.Certificate, error)
func GetTLSConfig ¶
func GetTLSConfigMem ¶
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 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 ParseBitSizeString ¶
Parse a size string in bits (e.g. 200kbit or 5Gbit) into the number of bits it represents. Supports suffixes up to Ebit. "" == 0.
func ParseByteSizeString ¶
Parse a size string in bytes (e.g. 200kB or 5GB) into the number of bytes it represents. Supports suffixes up to EB. "" == 0.
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 BriefContainerInfo ¶
type BriefContainerInfo 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 { AutoUpdate bool `json:"auto_update"` 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 { Architecture string `json:"architecture"` Config map[string]string `json:"config"` CreationDate time.Time `json:"created_at"` 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"` Stateful bool `json:"stateful"` Status string `json:"status"` StatusCode StatusCode `json:"status_code"` }
func (*ContainerInfo) Brief ¶
func (c *ContainerInfo) Brief() BriefContainerInfo
func (*ContainerInfo) BriefExpanded ¶
func (c *ContainerInfo) BriefExpanded() BriefContainerInfo
type ContainerState ¶
type ContainerState struct { Status string `json:"status"` StatusCode StatusCode `json:"status_code"` Disk map[string]ContainerStateDisk `json:"disk"` Memory ContainerStateMemory `json:"memory"` Network map[string]ContainerStateNetwork `json:"network"` Pid int64 `json:"pid"` Processes int64 `json:"processes"` }
type ContainerStateDisk ¶
type ContainerStateDisk struct {
Usage int64 `json:"usage"`
}
type ContainerStateMemory ¶
type ContainerStateNetwork ¶
type ContainerStateNetwork struct { Addresses []ContainerStateNetworkAddress `json:"addresses"` Counters ContainerStateNetworkCounters `json:"counters"` Hwaddr string `json:"hwaddr"` HostName string `json:"host_name"` Mtu int `json:"mtu"` State string `json:"state"` Type string `json:"type"` }
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 []ImageAliasesEntry
type ImageAliasesEntry ¶
type ImageInfo ¶
type ImageInfo struct { Aliases []ImageAlias `json:"aliases"` Architecture string `json:"architecture"` Cached bool `json:"cached"` Filename string `json:"filename"` Fingerprint string `json:"fingerprint"` Properties map[string]string `json:"properties"` Public bool `json:"public"` Size int64 `json:"size"` AutoUpdate bool `json:"auto_update"` Source *ImageSource `json:"update_source,omitempty"` CreationDate time.Time `json:"created_at"` ExpiryDate time.Time `json:"expires_at"` LastUsedDate time.Time `json:"last_used_at"` UploadDate time.Time `json:"uploaded_at"` }
func (*ImageInfo) Brief ¶
func (i *ImageInfo) Brief() BriefImageInfo
type ImageProperties ¶
type ImageSource ¶
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) Brief ¶
func (c *ServerState) Brief() BriefServerState
type ServerStateEnvironment ¶
type ServerStateEnvironment struct { Addresses []string `json:"addresses"` Architectures []string `json:"architectures"` Certificate string `json:"certificate"` 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 SimpleStreams ¶
type SimpleStreams struct {
// contains filtered or unexported fields
}
func SimpleStreamsClient ¶
func SimpleStreamsClient(url string) (*SimpleStreams, error)
func (*SimpleStreams) ExportImage ¶
func (s *SimpleStreams) ExportImage(image string, target string) (string, error)
func (*SimpleStreams) GetAlias ¶
func (s *SimpleStreams) GetAlias(name string) string
func (*SimpleStreams) GetImageInfo ¶
func (s *SimpleStreams) GetImageInfo(fingerprint string) (*ImageInfo, error)
func (*SimpleStreams) ListAliases ¶
func (s *SimpleStreams) ListAliases() (ImageAliases, error)
func (*SimpleStreams) ListImages ¶
func (s *SimpleStreams) ListImages() ([]ImageInfo, error)
type SimpleStreamsIndex ¶
type SimpleStreamsIndex struct { Format string `json:"format"` Index map[string]SimpleStreamsIndexStream `json:"index"` Updated string `json:"updated"` }
type SimpleStreamsManifest ¶
type SimpleStreamsManifestProduct ¶
type SimpleStreamsManifestProduct struct { Aliases string `json:"aliases"` Architecture string `json:"arch"` OperatingSystem string `json:"os"` Release string `json:"release"` ReleaseCodename string `json:"release_codename"` ReleaseTitle string `json:"release_title"` Supported bool `json:"supported"` SupportedEOL string `json:"support_eol"` Version string `json:"version"` Versions map[string]SimpleStreamsManifestProductVersion `json:"versions"` }
type SimpleStreamsManifestProductVersion ¶
type SimpleStreamsManifestProductVersion struct { PublicName string `json:"pubname"` Label string `json:"label"` Items map[string]SimpleStreamsManifestProductVersionItem `json:"items"` }
type SnapshotInfo ¶
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