Documentation
¶
Overview ¶
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 AllocatePort() (int, error)
- func AtoiEmptyDefault(s string, def int) (int, error)
- func BlockFsDetect(dev string) (string, error)
- func CachePath(path ...string) string
- func CertFingerprint(cert *x509.Certificate) string
- func CertFingerprintStr(c string) (string, error)
- func ConfigKeyChecker(key string) (func(value string) error, error)
- func DebugJson(r *bytes.Buffer)
- func DeepCopy(src, dest interface{}) error
- func ExecReaderToChannel(r io.Reader, bufferSize int, exited <-chan bool, fd int) <-chan []byte
- 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, precision uint) string
- func GetErrno(err error) (errno error, iserrno bool)
- func GetFileStat(p string) (uid int, gid int, major int, minor int, inode uint64, nlink int, err error)
- func GetOwnerMode(fInfo os.FileInfo) (os.FileMode, int, int)
- func GetPollRevents(fd int, timeout int, flags int) (int, int, error)
- func GetTLSConfig(tlsClientCertFile string, tlsClientKeyFile string, tlsClientCAFile string, ...) (*tls.Config, error)
- func GetTLSConfigMem(tlsClientCert string, tlsClientKey string, tlsClientCA string, ...) (*tls.Config, error)
- func GroupId(name string) (int, error)
- func Int64InSlice(key int64, list []int64) bool
- func IntInSlice(key int, list []int) bool
- func IsAny(value string) error
- func IsBlockdev(fm os.FileMode) bool
- func IsBlockdevPath(pathName string) bool
- func IsBool(value string) error
- func IsDir(name string) bool
- func IsInt64(value string) error
- func IsLoopback(iface *net.Interface) bool
- func IsMountPoint(name string) bool
- func IsOneOf(value string, valid []string) error
- func IsPriority(value string) error
- func IsSnapshot(name string) bool
- func IsTrue(value string) bool
- func IsUint32(value string) error
- func IsUnixSocket(path string) bool
- func LogPath(path ...string) string
- func LookupBlockDevByUUID(uuid string) (string, error)
- func LookupUUIDByBlockDevPath(diskDevice string) (string, error)
- func MkdirAllOwner(path string, perm os.FileMode, uid int, gid int) error
- func OpenPty(uid, gid int64) (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 int64, gid int64, mode int, type_ string, write string)
- 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 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 RemoveDuplicatesFromString(s string, sep string) string
- func Round(x float64) int64
- func RunCommand(name string, arg ...string) (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 TextEditor(inPath string, inContent []byte) ([]byte, error)
- func TimeIsSet(ts time.Time) bool
- func TryRunCommand(name string, arg ...string) (string, error)
- func UserId(name string) (int, error)
- func ValidHostname(name string) bool
- func VarPath(path ...string) string
- func WebsocketExecMirror(conn *websocket.Conn, w io.WriteCloser, r io.ReadCloser, exited chan bool, ...) (chan bool, chan bool)
- 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 ByHostid
- type BytesReadCloser
- type ContainerAction
- type IdRange
- 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 (m IdmapSet) Less(i, j int) bool
- func (set *IdmapSet) ShiftFile(p string) error
- func (m IdmapSet) ShiftFromNs(uid int64, gid int64) (int64, int64)
- func (m IdmapSet) ShiftIntoNs(uid int64, gid int64) (int64, int64)
- func (set *IdmapSet) ShiftRootfs(p string) error
- func (m IdmapSet) Swap(i, j int)
- 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
- func (m IdmapSet) Usable() error
- func (m IdmapSet) ValidRanges() ([]*IdRange, error)
- type Jmap
- type StringSet
- type WebSocketMirrorReader
- type WebSocketMirrorWriter
Constants ¶
const ABSTRACT_UNIX_SOCK_LEN int = C.ABSTRACT_UNIX_SOCK_LEN
const DefaultPort = "8443"
const POLLERR int = C.POLLERR
const POLLHUP int = C.POLLHUP
const POLLIN int = C.POLLIN
const POLLNVAL int = C.POLLNVAL
const POLLPRI int = C.POLLPRI
const POLLRDHUP int = C.POLLRDHUP
const SnapshotDelimiter = "/"
Variables ¶
var KnownContainerConfigKeys = map[string]func(value string) error{ "boot.autostart": IsBool, "boot.autostart.delay": IsInt64, "boot.autostart.priority": IsInt64, "boot.host_shutdown_timeout": IsInt64, "limits.cpu": IsAny, "limits.cpu.allowance": func(value string) error { if value == "" { return nil } if strings.HasSuffix(value, "%") { _, err := strconv.Atoi(strings.TrimSuffix(value, "%")) if err != nil { return err } return nil } fields := strings.SplitN(value, "/", 2) if len(fields) != 2 { return fmt.Errorf("Invalid allowance: %s", value) } _, err := strconv.Atoi(strings.TrimSuffix(fields[0], "ms")) if err != nil { return err } _, err = strconv.Atoi(strings.TrimSuffix(fields[1], "ms")) if err != nil { return err } return nil }, "limits.cpu.priority": IsPriority, "limits.disk.priority": IsPriority, "limits.memory": func(value string) error { if value == "" { return nil } if strings.HasSuffix(value, "%") { _, err := strconv.ParseInt(strings.TrimSuffix(value, "%"), 10, 64) if err != nil { return err } return nil } _, err := ParseByteSizeString(value) if err != nil { return err } return nil }, "limits.memory.enforce": func(value string) error { return IsOneOf(value, []string{"soft", "hard"}) }, "limits.memory.swap": IsBool, "limits.memory.swap.priority": IsPriority, "limits.network.priority": IsPriority, "limits.processes": IsInt64, "linux.kernel_modules": IsAny, "security.nesting": IsBool, "security.privileged": IsBool, "security.idmap.size": IsUint32, "security.idmap.isolated": IsBool, "security.syscalls.blacklist_default": IsBool, "security.syscalls.blacklist_compat": IsBool, "security.syscalls.blacklist": IsAny, "security.syscalls.whitelist": IsAny, "raw.apparmor": IsAny, "raw.lxc": IsAny, "raw.seccomp": IsAny, "raw.idmap": IsAny, "volatile.apply_template": IsAny, "volatile.base_image": IsAny, "volatile.last_state.idmap": IsAny, "volatile.last_state.power": IsAny, "volatile.idmap.next": IsAny, "volatile.idmap.base": IsAny, "volatile.apply_quota": IsAny, }
KnownContainerConfigKeys maps all fully defined, well-known config keys to an appropriate checker function, which validates whether or not a given value is syntactically legal.
var ObjectFound = fmt.Errorf("Found requested object.")
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 AllocatePort ¶
AllocatePort asks the kernel for a free open port that is ready to use
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 CertFingerprint ¶
func CertFingerprint(cert *x509.Certificate) string
func CertFingerprintStr ¶
func ConfigKeyChecker ¶
ConfigKeyChecker returns a function that will check whether or not a provide value is valid for the associate config key. Returns an error if the key is not known. The checker function only performs syntactic checking of the value, semantic and usage checking must be done by the caller. User defined keys are always considered to be valid, e.g. user.* and environment.* keys.
func DeepCopy ¶
func DeepCopy(src, dest interface{}) error
DeepCopy copies src to dest by using encoding/gob so its not that fast.
func ExecReaderToChannel ¶
Extensively commented directly in the code. Please leave the comments! Looking at this in a couple of months noone will know why and how this works anymore.
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 Int64InSlice ¶
func IntInSlice ¶
func IsBlockdev ¶
func IsBlockdevPath ¶
func IsLoopback ¶
func IsMountPoint ¶
func IsPriority ¶
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 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 LookupBlockDevByUUID ¶
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 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 RemoveDuplicatesFromString ¶
RemoveDuplicatesFromString removes all duplicates of the string 'sep' from the specified string 's'. Leading and trailing occurrences of sep are NOT removed (duplicate leading/trailing are). Performs poorly if there are multiple consecutive redundant separators.
func RunningInUserNS ¶
func RunningInUserNS() bool
func StringInSlice ¶
func TextEditor ¶
Spawn the editor with a temporary YAML file for editing configs
func UserId ¶
UserId is an adaption from https://codereview.appspot.com/4589049.
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 WebsocketExecMirror ¶
func WebsocketExecMirror(conn *websocket.Conn, w io.WriteCloser, r io.ReadCloser, exited chan bool, fd int) (chan bool, chan bool)
func WebsocketMirror ¶
func WebsocketMirror(conn *websocket.Conn, w io.WriteCloser, r io.ReadCloser, Reader WebSocketMirrorReader, Writer WebSocketMirrorWriter) (chan bool, chan bool)
func WebsocketSendStream ¶
Types ¶
type ByHostid ¶
type ByHostid []*IdmapEntry
type BytesReadCloser ¶
func (BytesReadCloser) Close ¶
func (r BytesReadCloser) Close() error
type ContainerAction ¶
type ContainerAction string
const ( Stop ContainerAction = "stop" Start ContainerAction = "start" Restart ContainerAction = "restart" Freeze ContainerAction = "freeze" Unfreeze ContainerAction = "unfreeze" )
type IdmapEntry ¶
type IdmapEntry struct { Isuid bool Isgid bool Hostid int64 // id as seen on the host - i.e. 100000 Nsid int64 // id as seen in the ns - i.e. 0 Maprange int64 }
* 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
func (*IdmapEntry) Usable ¶
func (e *IdmapEntry) Usable() error
type IdmapSet ¶
type IdmapSet struct {
Idmap []IdmapEntry
}
func CurrentIdmapSet ¶
* Create an idmap of the current allocation
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 ¶
func (IdmapSet) ValidRanges ¶
type StringSet ¶
func NewStringSet ¶
type WebSocketMirrorReader ¶
type WebSocketMirrorReader func(conn *websocket.Conn, r io.ReadCloser, readDone 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.
type WebSocketMirrorWriter ¶
type WebSocketMirrorWriter func(conn *websocket.Conn, w io.WriteCloser, writeDone chan<- bool)
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package api contains Go structs for all LXD API objects Overview This package has Go structs for every API object, all the various structs are named after the object they represent and some variations of those structs exist for initial object creation, object update and object retrieval.
|
Package api contains Go structs for all LXD API objects Overview This package has Go structs for every API object, all the various structs are named after the object they represent and some variations of those structs exist for initial object creation, object update and object retrieval. |
Package gnuflag implements command-line flag parsing in the GNU style.
|
Package gnuflag implements command-line flag parsing in the GNU style. |