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 CachePath(path ...string) string
- func DebugJson(r *bytes.Buffer)
- 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, certtype bool) error
- func GenCert(certf string, keyf string, certtype bool) error
- func GenerateMemCert(client bool) ([]byte, []byte, error)
- func GetAllXattr(path string) (xattrs map[string]string, err error)
- func GetByteSizeString(input int64) string
- 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 GetOwnerMode(fInfo os.FileInfo) (os.FileMode, int, int)
- 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 IsTrue(value string) bool
- func IsUnixSocket(path string) bool
- func LogCrit(msg string, ctx interface{})
- func LogCritf(format string, args ...interface{})
- func LogDebug(msg string, ctx interface{})
- func LogDebugf(format string, args ...interface{})
- func LogError(msg string, ctx interface{})
- func LogErrorf(format string, args ...interface{})
- func LogInfo(msg string, ctx interface{})
- func LogInfof(format string, args ...interface{})
- func LogPath(path ...string) string
- func LogWarn(msg string, ctx interface{})
- func LogWarnf(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 int)
- 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 ProxyFromConfig(httpsProxy string, httpProxy string, noProxy string) func(req *http.Request) (*url.URL, error)
- func ProxyFromEnvironment(req *http.Request) (*url.URL, error)
- 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, bufferSize int) <-chan []byte
- func RunCommand(name string, arg ...string) error
- 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 TestIdmapSetAddSafe_lower(t *testing.T)
- func TestIdmapSetAddSafe_split(t *testing.T)
- func TestIdmapSetAddSafe_upper(t *testing.T)
- func TestIdmapSetIntersects(t *testing.T)
- 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.Writer, conn *websocket.Conn) chan bool
- func WebsocketSendStream(conn *websocket.Conn, r io.Reader, bufferSize int) 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 ByHostid
- 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 (devices Devices) DeviceNames() []string
- 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) AddSafe(i IdmapEntry) error
- func (m IdmapSet) Append(s string) (IdmapSet, error)
- func (m IdmapSet) HostidsIntersect(i IdmapEntry) bool
- 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.8"
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 CachePath ¶
CachePath returns the directory that LXD should its cache under. If LXD_DIR is set, this path is $LXD_DIR/cache, otherwise it is /var/cache/lxd.
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 GenerateMemCert ¶
GenerateMemCert creates client or server certificate and key pair, returning them as byte arrays in memory.
func GetAllXattr ¶
GetAllXattr retrieves all extended attributes associated with a file, directory or symbolic link.
func GetByteSizeString ¶
func GetFileStat ¶
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 IsUnixSocket ¶
IsUnixSocket returns true if the given path is either a Unix socket or a symbolic link pointing at a Unix socket.
func LogDebug ¶
func LogDebug(msg string, ctx interface{})
General wrappers around Logger interface functions.
func LogInfof ¶
func LogInfof(format string, args ...interface{})
Wrappers around Logger interface functions that send a string to the Logger by running it through fmt.Sprintf().
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 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 ProxyFromConfig ¶
func ProxyFromEnvironment ¶
This is basically the same as golang's ProxyFromEnvironment, except it doesn't fall back to http_proxy when https_proxy isn't around, which is incorrect behavior. It still respects HTTP_PROXY, HTTPS_PROXY, and NO_PROXY.
func RandomCryptoString ¶
Returns a random base64 encoded string from crypto/rand.
func ReadToJSON ¶
func RunCommand ¶
func RunningInUserNS ¶
func RunningInUserNS() bool
func StringInSlice ¶
func TestIdmapSetIntersects ¶
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 WebsocketSendStream ¶
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 ByHostid ¶
type ByHostid []*IdmapEntry
type BytesReadCloser ¶
func (BytesReadCloser) Close ¶
func (r BytesReadCloser) Close() error
type CertInfo ¶
type CertInfo struct { Certificate string `json:"certificate"` Fingerprint string `json:"fingerprint"` Name string `json:"name"` 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
func (ContainerInfo) IsActive ¶
func (c ContainerInfo) IsActive() bool
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 Devices ¶
func (Devices) ContainsName ¶
func (Devices) DeviceNames ¶
DeviceNames returns the device names for this Devices in sorted order
func (Devices) ExtendFromProfile ¶
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) HostidsIntersect ¶
func (e *IdmapEntry) HostidsIntersect(i IdmapEntry) bool
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) AddSafe ¶
func (m *IdmapSet) AddSafe(i IdmapEntry) error
AddSafe adds an entry to the idmap set, breaking apart any ranges that the * new idmap intersects with in the process.
func (IdmapSet) HostidsIntersect ¶
func (m IdmapSet) HostidsIntersect(i IdmapEntry) bool
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 { APIExtensions []string `json:"api_extensions"` APIStatus string `json:"api_status"` APIVersion string `json:"api_version"` 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"` CertificateFingerprint string `json:"certificate_fingerprint"` 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 (*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 SimpleStreamsManifestProductVersionItem ¶
type SimpleStreamsManifestProductVersionItem struct { Path string `json:"path"` FileType string `json:"ftype"` HashMd5 string `json:"md5"` HashSha256 string `json:"sha256"` LXDHashSha256 string `json:"combined_sha256"` LXDHashSha256RootXz string `json:"combined_rootxz_sha256"` LXDHashSha256SquashFs string `json:"combined_squashfs_sha256"` Size int64 `json:"size"` }
type SnapshotInfo ¶
type SnapshotInfo 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"` }
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 Error StatusCode = 112 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