repo
stringlengths
5
67
path
stringlengths
4
218
func_name
stringlengths
0
151
original_string
stringlengths
52
373k
language
stringclasses
6 values
code
stringlengths
52
373k
code_tokens
listlengths
10
512
docstring
stringlengths
3
47.2k
docstring_tokens
listlengths
3
234
sha
stringlengths
40
40
url
stringlengths
85
339
partition
stringclasses
3 values
lxc/lxd
lxd/api_internal.go
internalSQLPost
func internalSQLPost(d *Daemon, r *http.Request) Response { req := &internalSQLQuery{} // Parse the request. err := json.NewDecoder(r.Body).Decode(&req) if err != nil { return BadRequest(err) } if !shared.StringInSlice(req.Database, []string{"local", "global"}) { return BadRequest(fmt.Errorf("Invalid databas...
go
func internalSQLPost(d *Daemon, r *http.Request) Response { req := &internalSQLQuery{} // Parse the request. err := json.NewDecoder(r.Body).Decode(&req) if err != nil { return BadRequest(err) } if !shared.StringInSlice(req.Database, []string{"local", "global"}) { return BadRequest(fmt.Errorf("Invalid databas...
[ "func", "internalSQLPost", "(", "d", "*", "Daemon", ",", "r", "*", "http", ".", "Request", ")", "Response", "{", "req", ":=", "&", "internalSQLQuery", "{", "}", "\n", "err", ":=", "json", ".", "NewDecoder", "(", "r", ".", "Body", ")", ".", "Decode", ...
// Execute queries.
[ "Execute", "queries", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/api_internal.go#L241-L304
test
lxc/lxd
shared/cert.go
PublicKey
func (c *CertInfo) PublicKey() []byte { data := c.KeyPair().Certificate[0] return pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: data}) }
go
func (c *CertInfo) PublicKey() []byte { data := c.KeyPair().Certificate[0] return pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: data}) }
[ "func", "(", "c", "*", "CertInfo", ")", "PublicKey", "(", ")", "[", "]", "byte", "{", "data", ":=", "c", ".", "KeyPair", "(", ")", ".", "Certificate", "[", "0", "]", "\n", "return", "pem", ".", "EncodeToMemory", "(", "&", "pem", ".", "Block", "{"...
// PublicKey is a convenience to encode the underlying public key to ASCII.
[ "PublicKey", "is", "a", "convenience", "to", "encode", "the", "underlying", "public", "key", "to", "ASCII", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/cert.go#L101-L104
test
lxc/lxd
shared/cert.go
PrivateKey
func (c *CertInfo) PrivateKey() []byte { ecKey, ok := c.KeyPair().PrivateKey.(*ecdsa.PrivateKey) if ok { data, err := x509.MarshalECPrivateKey(ecKey) if err != nil { return nil } return pem.EncodeToMemory(&pem.Block{Type: "EC PRIVATE KEY", Bytes: data}) } rsaKey, ok := c.KeyPair().PrivateKey.(*rsa.Priv...
go
func (c *CertInfo) PrivateKey() []byte { ecKey, ok := c.KeyPair().PrivateKey.(*ecdsa.PrivateKey) if ok { data, err := x509.MarshalECPrivateKey(ecKey) if err != nil { return nil } return pem.EncodeToMemory(&pem.Block{Type: "EC PRIVATE KEY", Bytes: data}) } rsaKey, ok := c.KeyPair().PrivateKey.(*rsa.Priv...
[ "func", "(", "c", "*", "CertInfo", ")", "PrivateKey", "(", ")", "[", "]", "byte", "{", "ecKey", ",", "ok", ":=", "c", ".", "KeyPair", "(", ")", ".", "PrivateKey", ".", "(", "*", "ecdsa", ".", "PrivateKey", ")", "\n", "if", "ok", "{", "data", ",...
// PrivateKey is a convenience to encode the underlying private key.
[ "PrivateKey", "is", "a", "convenience", "to", "encode", "the", "underlying", "private", "key", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/cert.go#L107-L125
test
lxc/lxd
shared/cert.go
Fingerprint
func (c *CertInfo) Fingerprint() string { fingerprint, err := CertFingerprintStr(string(c.PublicKey())) // Parsing should never fail, since we generated the cert ourselves, // but let's check the error for good measure. if err != nil { panic("invalid public key material") } return fingerprint }
go
func (c *CertInfo) Fingerprint() string { fingerprint, err := CertFingerprintStr(string(c.PublicKey())) // Parsing should never fail, since we generated the cert ourselves, // but let's check the error for good measure. if err != nil { panic("invalid public key material") } return fingerprint }
[ "func", "(", "c", "*", "CertInfo", ")", "Fingerprint", "(", ")", "string", "{", "fingerprint", ",", "err", ":=", "CertFingerprintStr", "(", "string", "(", "c", ".", "PublicKey", "(", ")", ")", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", ...
// Fingerprint returns the fingerprint of the public key.
[ "Fingerprint", "returns", "the", "fingerprint", "of", "the", "public", "key", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/cert.go#L128-L136
test
lxc/lxd
shared/cert.go
GenCert
func GenCert(certf string, keyf string, certtype bool) error { /* Create the basenames if needed */ dir := path.Dir(certf) err := os.MkdirAll(dir, 0750) if err != nil { return err } dir = path.Dir(keyf) err = os.MkdirAll(dir, 0750) if err != nil { return err } certBytes, keyBytes, err := GenerateMemCert(...
go
func GenCert(certf string, keyf string, certtype bool) error { /* Create the basenames if needed */ dir := path.Dir(certf) err := os.MkdirAll(dir, 0750) if err != nil { return err } dir = path.Dir(keyf) err = os.MkdirAll(dir, 0750) if err != nil { return err } certBytes, keyBytes, err := GenerateMemCert(...
[ "func", "GenCert", "(", "certf", "string", ",", "keyf", "string", ",", "certtype", "bool", ")", "error", "{", "dir", ":=", "path", ".", "Dir", "(", "certf", ")", "\n", "err", ":=", "os", ".", "MkdirAll", "(", "dir", ",", "0750", ")", "\n", "if", ...
// GenCert will create and populate a certificate file and a key file
[ "GenCert", "will", "create", "and", "populate", "a", "certificate", "file", "and", "a", "key", "file" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/cert.go#L229-L261
test
lxc/lxd
lxd-benchmark/benchmark/benchmark.go
PrintServerInfo
func PrintServerInfo(c lxd.ContainerServer) error { server, _, err := c.GetServer() if err != nil { return err } env := server.Environment fmt.Printf("Test environment:\n") fmt.Printf(" Server backend: %s\n", env.Server) fmt.Printf(" Server version: %s\n", env.ServerVersion) fmt.Printf(" Kernel: %s\n", env...
go
func PrintServerInfo(c lxd.ContainerServer) error { server, _, err := c.GetServer() if err != nil { return err } env := server.Environment fmt.Printf("Test environment:\n") fmt.Printf(" Server backend: %s\n", env.Server) fmt.Printf(" Server version: %s\n", env.ServerVersion) fmt.Printf(" Kernel: %s\n", env...
[ "func", "PrintServerInfo", "(", "c", "lxd", ".", "ContainerServer", ")", "error", "{", "server", ",", "_", ",", "err", ":=", "c", ".", "GetServer", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "env", ":=", "serve...
// PrintServerInfo prints out information about the server.
[ "PrintServerInfo", "prints", "out", "information", "about", "the", "server", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd-benchmark/benchmark/benchmark.go#L18-L36
test
lxc/lxd
lxd-benchmark/benchmark/benchmark.go
LaunchContainers
func LaunchContainers(c lxd.ContainerServer, count int, parallel int, image string, privileged bool, start bool, freeze bool) (time.Duration, error) { var duration time.Duration batchSize, err := getBatchSize(parallel) if err != nil { return duration, err } printTestConfig(count, batchSize, image, privileged, ...
go
func LaunchContainers(c lxd.ContainerServer, count int, parallel int, image string, privileged bool, start bool, freeze bool) (time.Duration, error) { var duration time.Duration batchSize, err := getBatchSize(parallel) if err != nil { return duration, err } printTestConfig(count, batchSize, image, privileged, ...
[ "func", "LaunchContainers", "(", "c", "lxd", ".", "ContainerServer", ",", "count", "int", ",", "parallel", "int", ",", "image", "string", ",", "privileged", "bool", ",", "start", "bool", ",", "freeze", "bool", ")", "(", "time", ".", "Duration", ",", "err...
// LaunchContainers launches a set of containers.
[ "LaunchContainers", "launches", "a", "set", "of", "containers", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd-benchmark/benchmark/benchmark.go#L39-L84
test
lxc/lxd
lxd-benchmark/benchmark/benchmark.go
CreateContainers
func CreateContainers(c lxd.ContainerServer, count int, parallel int, fingerprint string, privileged bool) (time.Duration, error) { var duration time.Duration batchSize, err := getBatchSize(parallel) if err != nil { return duration, err } batchCreate := func(index int, wg *sync.WaitGroup) { defer wg.Done() ...
go
func CreateContainers(c lxd.ContainerServer, count int, parallel int, fingerprint string, privileged bool) (time.Duration, error) { var duration time.Duration batchSize, err := getBatchSize(parallel) if err != nil { return duration, err } batchCreate := func(index int, wg *sync.WaitGroup) { defer wg.Done() ...
[ "func", "CreateContainers", "(", "c", "lxd", ".", "ContainerServer", ",", "count", "int", ",", "parallel", "int", ",", "fingerprint", "string", ",", "privileged", "bool", ")", "(", "time", ".", "Duration", ",", "error", ")", "{", "var", "duration", "time",...
// CreateContainers create the specified number of containers.
[ "CreateContainers", "create", "the", "specified", "number", "of", "containers", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd-benchmark/benchmark/benchmark.go#L87-L110
test
lxc/lxd
lxd-benchmark/benchmark/benchmark.go
GetContainers
func GetContainers(c lxd.ContainerServer) ([]api.Container, error) { containers := []api.Container{} allContainers, err := c.GetContainers() if err != nil { return containers, err } for _, container := range allContainers { if container.Config[userConfigKey] == "true" { containers = append(containers, con...
go
func GetContainers(c lxd.ContainerServer) ([]api.Container, error) { containers := []api.Container{} allContainers, err := c.GetContainers() if err != nil { return containers, err } for _, container := range allContainers { if container.Config[userConfigKey] == "true" { containers = append(containers, con...
[ "func", "GetContainers", "(", "c", "lxd", ".", "ContainerServer", ")", "(", "[", "]", "api", ".", "Container", ",", "error", ")", "{", "containers", ":=", "[", "]", "api", ".", "Container", "{", "}", "\n", "allContainers", ",", "err", ":=", "c", ".",...
// GetContainers returns containers created by the benchmark.
[ "GetContainers", "returns", "containers", "created", "by", "the", "benchmark", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd-benchmark/benchmark/benchmark.go#L113-L128
test
lxc/lxd
lxd-benchmark/benchmark/benchmark.go
StartContainers
func StartContainers(c lxd.ContainerServer, containers []api.Container, parallel int) (time.Duration, error) { var duration time.Duration batchSize, err := getBatchSize(parallel) if err != nil { return duration, err } count := len(containers) logf("Starting %d containers", count) batchStart := func(index in...
go
func StartContainers(c lxd.ContainerServer, containers []api.Container, parallel int) (time.Duration, error) { var duration time.Duration batchSize, err := getBatchSize(parallel) if err != nil { return duration, err } count := len(containers) logf("Starting %d containers", count) batchStart := func(index in...
[ "func", "StartContainers", "(", "c", "lxd", ".", "ContainerServer", ",", "containers", "[", "]", "api", ".", "Container", ",", "parallel", "int", ")", "(", "time", ".", "Duration", ",", "error", ")", "{", "var", "duration", "time", ".", "Duration", "\n",...
// StartContainers starts containers created by the benchmark.
[ "StartContainers", "starts", "containers", "created", "by", "the", "benchmark", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd-benchmark/benchmark/benchmark.go#L131-L157
test
lxc/lxd
client/util.go
setQueryParam
func setQueryParam(uri, param, value string) (string, error) { fields, err := url.Parse(uri) if err != nil { return "", err } values := fields.Query() values.Set(param, url.QueryEscape(value)) fields.RawQuery = values.Encode() return fields.String(), nil }
go
func setQueryParam(uri, param, value string) (string, error) { fields, err := url.Parse(uri) if err != nil { return "", err } values := fields.Query() values.Set(param, url.QueryEscape(value)) fields.RawQuery = values.Encode() return fields.String(), nil }
[ "func", "setQueryParam", "(", "uri", ",", "param", ",", "value", "string", ")", "(", "string", ",", "error", ")", "{", "fields", ",", "err", ":=", "url", ".", "Parse", "(", "uri", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"\"", ",", "...
// Set the value of a query parameter in the given URI.
[ "Set", "the", "value", "of", "a", "query", "parameter", "in", "the", "given", "URI", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/util.go#L176-L188
test
lxc/lxd
client/lxd_images.go
GetImages
func (r *ProtocolLXD) GetImages() ([]api.Image, error) { images := []api.Image{} _, err := r.queryStruct("GET", "/images?recursion=1", nil, "", &images) if err != nil { return nil, err } return images, nil }
go
func (r *ProtocolLXD) GetImages() ([]api.Image, error) { images := []api.Image{} _, err := r.queryStruct("GET", "/images?recursion=1", nil, "", &images) if err != nil { return nil, err } return images, nil }
[ "func", "(", "r", "*", "ProtocolLXD", ")", "GetImages", "(", ")", "(", "[", "]", "api", ".", "Image", ",", "error", ")", "{", "images", ":=", "[", "]", "api", ".", "Image", "{", "}", "\n", "_", ",", "err", ":=", "r", ".", "queryStruct", "(", ...
// Image handling functions // GetImages returns a list of available images as Image structs
[ "Image", "handling", "functions", "GetImages", "returns", "a", "list", "of", "available", "images", "as", "Image", "structs" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_images.go#L24-L33
test
lxc/lxd
client/lxd_images.go
GetImageFile
func (r *ProtocolLXD) GetImageFile(fingerprint string, req ImageFileRequest) (*ImageFileResponse, error) { return r.GetPrivateImageFile(fingerprint, "", req) }
go
func (r *ProtocolLXD) GetImageFile(fingerprint string, req ImageFileRequest) (*ImageFileResponse, error) { return r.GetPrivateImageFile(fingerprint, "", req) }
[ "func", "(", "r", "*", "ProtocolLXD", ")", "GetImageFile", "(", "fingerprint", "string", ",", "req", "ImageFileRequest", ")", "(", "*", "ImageFileResponse", ",", "error", ")", "{", "return", "r", ".", "GetPrivateImageFile", "(", "fingerprint", ",", "\"\"", "...
// GetImageFile downloads an image from the server, returning an ImageFileRequest struct
[ "GetImageFile", "downloads", "an", "image", "from", "the", "server", "returning", "an", "ImageFileRequest", "struct" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_images.go#L61-L63
test
lxc/lxd
client/lxd_images.go
GetImageSecret
func (r *ProtocolLXD) GetImageSecret(fingerprint string) (string, error) { op, err := r.CreateImageSecret(fingerprint) if err != nil { return "", err } opAPI := op.Get() return opAPI.Metadata["secret"].(string), nil }
go
func (r *ProtocolLXD) GetImageSecret(fingerprint string) (string, error) { op, err := r.CreateImageSecret(fingerprint) if err != nil { return "", err } opAPI := op.Get() return opAPI.Metadata["secret"].(string), nil }
[ "func", "(", "r", "*", "ProtocolLXD", ")", "GetImageSecret", "(", "fingerprint", "string", ")", "(", "string", ",", "error", ")", "{", "op", ",", "err", ":=", "r", ".", "CreateImageSecret", "(", "fingerprint", ")", "\n", "if", "err", "!=", "nil", "{", ...
// GetImageSecret is a helper around CreateImageSecret that returns a secret for the image
[ "GetImageSecret", "is", "a", "helper", "around", "CreateImageSecret", "that", "returns", "a", "secret", "for", "the", "image" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_images.go#L66-L74
test
lxc/lxd
client/lxd_images.go
GetPrivateImage
func (r *ProtocolLXD) GetPrivateImage(fingerprint string, secret string) (*api.Image, string, error) { image := api.Image{} // Build the API path path := fmt.Sprintf("/images/%s", url.QueryEscape(fingerprint)) var err error path, err = r.setQueryAttributes(path) if err != nil { return nil, "", err } if secr...
go
func (r *ProtocolLXD) GetPrivateImage(fingerprint string, secret string) (*api.Image, string, error) { image := api.Image{} // Build the API path path := fmt.Sprintf("/images/%s", url.QueryEscape(fingerprint)) var err error path, err = r.setQueryAttributes(path) if err != nil { return nil, "", err } if secr...
[ "func", "(", "r", "*", "ProtocolLXD", ")", "GetPrivateImage", "(", "fingerprint", "string", ",", "secret", "string", ")", "(", "*", "api", ".", "Image", ",", "string", ",", "error", ")", "{", "image", ":=", "api", ".", "Image", "{", "}", "\n", "path"...
// GetPrivateImage is similar to GetImage but allows passing a secret download token
[ "GetPrivateImage", "is", "similar", "to", "GetImage", "but", "allows", "passing", "a", "secret", "download", "token" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_images.go#L77-L102
test
lxc/lxd
client/lxd_images.go
GetPrivateImageFile
func (r *ProtocolLXD) GetPrivateImageFile(fingerprint string, secret string, req ImageFileRequest) (*ImageFileResponse, error) { // Sanity checks if req.MetaFile == nil && req.RootfsFile == nil { return nil, fmt.Errorf("No file requested") } uri := fmt.Sprintf("/1.0/images/%s/export", url.QueryEscape(fingerprint...
go
func (r *ProtocolLXD) GetPrivateImageFile(fingerprint string, secret string, req ImageFileRequest) (*ImageFileResponse, error) { // Sanity checks if req.MetaFile == nil && req.RootfsFile == nil { return nil, fmt.Errorf("No file requested") } uri := fmt.Sprintf("/1.0/images/%s/export", url.QueryEscape(fingerprint...
[ "func", "(", "r", "*", "ProtocolLXD", ")", "GetPrivateImageFile", "(", "fingerprint", "string", ",", "secret", "string", ",", "req", "ImageFileRequest", ")", "(", "*", "ImageFileResponse", ",", "error", ")", "{", "if", "req", ".", "MetaFile", "==", "nil", ...
// GetPrivateImageFile is similar to GetImageFile but allows passing a secret download token
[ "GetPrivateImageFile", "is", "similar", "to", "GetImageFile", "but", "allows", "passing", "a", "secret", "download", "token" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_images.go#L105-L143
test
lxc/lxd
client/lxd_images.go
GetImageAliases
func (r *ProtocolLXD) GetImageAliases() ([]api.ImageAliasesEntry, error) { aliases := []api.ImageAliasesEntry{} // Fetch the raw value _, err := r.queryStruct("GET", "/images/aliases?recursion=1", nil, "", &aliases) if err != nil { return nil, err } return aliases, nil }
go
func (r *ProtocolLXD) GetImageAliases() ([]api.ImageAliasesEntry, error) { aliases := []api.ImageAliasesEntry{} // Fetch the raw value _, err := r.queryStruct("GET", "/images/aliases?recursion=1", nil, "", &aliases) if err != nil { return nil, err } return aliases, nil }
[ "func", "(", "r", "*", "ProtocolLXD", ")", "GetImageAliases", "(", ")", "(", "[", "]", "api", ".", "ImageAliasesEntry", ",", "error", ")", "{", "aliases", ":=", "[", "]", "api", ".", "ImageAliasesEntry", "{", "}", "\n", "_", ",", "err", ":=", "r", ...
// GetImageAliases returns the list of available aliases as ImageAliasesEntry structs
[ "GetImageAliases", "returns", "the", "list", "of", "available", "aliases", "as", "ImageAliasesEntry", "structs" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_images.go#L276-L286
test
lxc/lxd
client/lxd_images.go
tryCopyImage
func (r *ProtocolLXD) tryCopyImage(req api.ImagesPost, urls []string) (RemoteOperation, error) { if len(urls) == 0 { return nil, fmt.Errorf("The source server isn't listening on the network") } rop := remoteOperation{ chDone: make(chan bool), } // For older servers, apply the aliases after copy if !r.HasExt...
go
func (r *ProtocolLXD) tryCopyImage(req api.ImagesPost, urls []string) (RemoteOperation, error) { if len(urls) == 0 { return nil, fmt.Errorf("The source server isn't listening on the network") } rop := remoteOperation{ chDone: make(chan bool), } // For older servers, apply the aliases after copy if !r.HasExt...
[ "func", "(", "r", "*", "ProtocolLXD", ")", "tryCopyImage", "(", "req", "api", ".", "ImagesPost", ",", "urls", "[", "]", "string", ")", "(", "RemoteOperation", ",", "error", ")", "{", "if", "len", "(", "urls", ")", "==", "0", "{", "return", "nil", "...
// tryCopyImage iterates through the source server URLs until one lets it download the image
[ "tryCopyImage", "iterates", "through", "the", "source", "server", "URLs", "until", "one", "lets", "it", "download", "the", "image" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_images.go#L483-L562
test
lxc/lxd
client/lxd_images.go
CopyImage
func (r *ProtocolLXD) CopyImage(source ImageServer, image api.Image, args *ImageCopyArgs) (RemoteOperation, error) { // Sanity checks if r == source { return nil, fmt.Errorf("The source and target servers must be different") } // Get source server connection information info, err := source.GetConnectionInfo() ...
go
func (r *ProtocolLXD) CopyImage(source ImageServer, image api.Image, args *ImageCopyArgs) (RemoteOperation, error) { // Sanity checks if r == source { return nil, fmt.Errorf("The source and target servers must be different") } // Get source server connection information info, err := source.GetConnectionInfo() ...
[ "func", "(", "r", "*", "ProtocolLXD", ")", "CopyImage", "(", "source", "ImageServer", ",", "image", "api", ".", "Image", ",", "args", "*", "ImageCopyArgs", ")", "(", "RemoteOperation", ",", "error", ")", "{", "if", "r", "==", "source", "{", "return", "...
// CopyImage copies an image from a remote server. Additional options can be passed using ImageCopyArgs
[ "CopyImage", "copies", "an", "image", "from", "a", "remote", "server", ".", "Additional", "options", "can", "be", "passed", "using", "ImageCopyArgs" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_images.go#L565-L615
test
lxc/lxd
client/lxd_images.go
UpdateImage
func (r *ProtocolLXD) UpdateImage(fingerprint string, image api.ImagePut, ETag string) error { // Send the request _, _, err := r.query("PUT", fmt.Sprintf("/images/%s", url.QueryEscape(fingerprint)), image, ETag) if err != nil { return err } return nil }
go
func (r *ProtocolLXD) UpdateImage(fingerprint string, image api.ImagePut, ETag string) error { // Send the request _, _, err := r.query("PUT", fmt.Sprintf("/images/%s", url.QueryEscape(fingerprint)), image, ETag) if err != nil { return err } return nil }
[ "func", "(", "r", "*", "ProtocolLXD", ")", "UpdateImage", "(", "fingerprint", "string", ",", "image", "api", ".", "ImagePut", ",", "ETag", "string", ")", "error", "{", "_", ",", "_", ",", "err", ":=", "r", ".", "query", "(", "\"PUT\"", ",", "fmt", ...
// UpdateImage updates the image definition
[ "UpdateImage", "updates", "the", "image", "definition" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_images.go#L618-L626
test
lxc/lxd
client/lxd_images.go
DeleteImage
func (r *ProtocolLXD) DeleteImage(fingerprint string) (Operation, error) { // Send the request op, _, err := r.queryOperation("DELETE", fmt.Sprintf("/images/%s", url.QueryEscape(fingerprint)), nil, "") if err != nil { return nil, err } return op, nil }
go
func (r *ProtocolLXD) DeleteImage(fingerprint string) (Operation, error) { // Send the request op, _, err := r.queryOperation("DELETE", fmt.Sprintf("/images/%s", url.QueryEscape(fingerprint)), nil, "") if err != nil { return nil, err } return op, nil }
[ "func", "(", "r", "*", "ProtocolLXD", ")", "DeleteImage", "(", "fingerprint", "string", ")", "(", "Operation", ",", "error", ")", "{", "op", ",", "_", ",", "err", ":=", "r", ".", "queryOperation", "(", "\"DELETE\"", ",", "fmt", ".", "Sprintf", "(", "...
// DeleteImage requests that LXD removes an image from the store
[ "DeleteImage", "requests", "that", "LXD", "removes", "an", "image", "from", "the", "store" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_images.go#L629-L637
test
lxc/lxd
client/lxd_images.go
RefreshImage
func (r *ProtocolLXD) RefreshImage(fingerprint string) (Operation, error) { if !r.HasExtension("image_force_refresh") { return nil, fmt.Errorf("The server is missing the required \"image_force_refresh\" API extension") } // Send the request op, _, err := r.queryOperation("POST", fmt.Sprintf("/images/%s/refresh",...
go
func (r *ProtocolLXD) RefreshImage(fingerprint string) (Operation, error) { if !r.HasExtension("image_force_refresh") { return nil, fmt.Errorf("The server is missing the required \"image_force_refresh\" API extension") } // Send the request op, _, err := r.queryOperation("POST", fmt.Sprintf("/images/%s/refresh",...
[ "func", "(", "r", "*", "ProtocolLXD", ")", "RefreshImage", "(", "fingerprint", "string", ")", "(", "Operation", ",", "error", ")", "{", "if", "!", "r", ".", "HasExtension", "(", "\"image_force_refresh\"", ")", "{", "return", "nil", ",", "fmt", ".", "Erro...
// RefreshImage requests that LXD issues an image refresh
[ "RefreshImage", "requests", "that", "LXD", "issues", "an", "image", "refresh" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_images.go#L640-L652
test
lxc/lxd
client/lxd_images.go
CreateImageAlias
func (r *ProtocolLXD) CreateImageAlias(alias api.ImageAliasesPost) error { // Send the request _, _, err := r.query("POST", "/images/aliases", alias, "") if err != nil { return err } return nil }
go
func (r *ProtocolLXD) CreateImageAlias(alias api.ImageAliasesPost) error { // Send the request _, _, err := r.query("POST", "/images/aliases", alias, "") if err != nil { return err } return nil }
[ "func", "(", "r", "*", "ProtocolLXD", ")", "CreateImageAlias", "(", "alias", "api", ".", "ImageAliasesPost", ")", "error", "{", "_", ",", "_", ",", "err", ":=", "r", ".", "query", "(", "\"POST\"", ",", "\"/images/aliases\"", ",", "alias", ",", "\"\"", ...
// CreateImageAlias sets up a new image alias
[ "CreateImageAlias", "sets", "up", "a", "new", "image", "alias" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_images.go#L666-L674
test
lxc/lxd
client/lxd_images.go
UpdateImageAlias
func (r *ProtocolLXD) UpdateImageAlias(name string, alias api.ImageAliasesEntryPut, ETag string) error { // Send the request _, _, err := r.query("PUT", fmt.Sprintf("/images/aliases/%s", url.QueryEscape(name)), alias, ETag) if err != nil { return err } return nil }
go
func (r *ProtocolLXD) UpdateImageAlias(name string, alias api.ImageAliasesEntryPut, ETag string) error { // Send the request _, _, err := r.query("PUT", fmt.Sprintf("/images/aliases/%s", url.QueryEscape(name)), alias, ETag) if err != nil { return err } return nil }
[ "func", "(", "r", "*", "ProtocolLXD", ")", "UpdateImageAlias", "(", "name", "string", ",", "alias", "api", ".", "ImageAliasesEntryPut", ",", "ETag", "string", ")", "error", "{", "_", ",", "_", ",", "err", ":=", "r", ".", "query", "(", "\"PUT\"", ",", ...
// UpdateImageAlias updates the image alias definition
[ "UpdateImageAlias", "updates", "the", "image", "alias", "definition" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_images.go#L677-L685
test
lxc/lxd
client/lxd_images.go
RenameImageAlias
func (r *ProtocolLXD) RenameImageAlias(name string, alias api.ImageAliasesEntryPost) error { // Send the request _, _, err := r.query("POST", fmt.Sprintf("/images/aliases/%s", url.QueryEscape(name)), alias, "") if err != nil { return err } return nil }
go
func (r *ProtocolLXD) RenameImageAlias(name string, alias api.ImageAliasesEntryPost) error { // Send the request _, _, err := r.query("POST", fmt.Sprintf("/images/aliases/%s", url.QueryEscape(name)), alias, "") if err != nil { return err } return nil }
[ "func", "(", "r", "*", "ProtocolLXD", ")", "RenameImageAlias", "(", "name", "string", ",", "alias", "api", ".", "ImageAliasesEntryPost", ")", "error", "{", "_", ",", "_", ",", "err", ":=", "r", ".", "query", "(", "\"POST\"", ",", "fmt", ".", "Sprintf",...
// RenameImageAlias renames an existing image alias
[ "RenameImageAlias", "renames", "an", "existing", "image", "alias" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_images.go#L688-L696
test
lxc/lxd
client/lxd_images.go
DeleteImageAlias
func (r *ProtocolLXD) DeleteImageAlias(name string) error { // Send the request _, _, err := r.query("DELETE", fmt.Sprintf("/images/aliases/%s", url.QueryEscape(name)), nil, "") if err != nil { return err } return nil }
go
func (r *ProtocolLXD) DeleteImageAlias(name string) error { // Send the request _, _, err := r.query("DELETE", fmt.Sprintf("/images/aliases/%s", url.QueryEscape(name)), nil, "") if err != nil { return err } return nil }
[ "func", "(", "r", "*", "ProtocolLXD", ")", "DeleteImageAlias", "(", "name", "string", ")", "error", "{", "_", ",", "_", ",", "err", ":=", "r", ".", "query", "(", "\"DELETE\"", ",", "fmt", ".", "Sprintf", "(", "\"/images/aliases/%s\"", ",", "url", ".", ...
// DeleteImageAlias removes an alias from the LXD image store
[ "DeleteImageAlias", "removes", "an", "alias", "from", "the", "LXD", "image", "store" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_images.go#L699-L707
test
lxc/lxd
lxd/db/node/open.go
Open
func Open(dir string) (*sql.DB, error) { path := filepath.Join(dir, "local.db") db, err := sqliteOpen(path) if err != nil { return nil, fmt.Errorf("cannot open node database: %v", err) } return db, nil }
go
func Open(dir string) (*sql.DB, error) { path := filepath.Join(dir, "local.db") db, err := sqliteOpen(path) if err != nil { return nil, fmt.Errorf("cannot open node database: %v", err) } return db, nil }
[ "func", "Open", "(", "dir", "string", ")", "(", "*", "sql", ".", "DB", ",", "error", ")", "{", "path", ":=", "filepath", ".", "Join", "(", "dir", ",", "\"local.db\"", ")", "\n", "db", ",", "err", ":=", "sqliteOpen", "(", "path", ")", "\n", "if", ...
// Open the node-local database object.
[ "Open", "the", "node", "-", "local", "database", "object", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/node/open.go#L14-L22
test
lxc/lxd
lxd/db/node/open.go
EnsureSchema
func EnsureSchema(db *sql.DB, dir string, hook schema.Hook) (int, error) { backupDone := false schema := Schema() schema.File(filepath.Join(dir, "patch.local.sql")) // Optional custom queries schema.Hook(func(version int, tx *sql.Tx) error { if !backupDone { logger.Infof("Updating the LXD database schema. Bac...
go
func EnsureSchema(db *sql.DB, dir string, hook schema.Hook) (int, error) { backupDone := false schema := Schema() schema.File(filepath.Join(dir, "patch.local.sql")) // Optional custom queries schema.Hook(func(version int, tx *sql.Tx) error { if !backupDone { logger.Infof("Updating the LXD database schema. Bac...
[ "func", "EnsureSchema", "(", "db", "*", "sql", ".", "DB", ",", "dir", "string", ",", "hook", "schema", ".", "Hook", ")", "(", "int", ",", "error", ")", "{", "backupDone", ":=", "false", "\n", "schema", ":=", "Schema", "(", ")", "\n", "schema", ".",...
// EnsureSchema applies all relevant schema updates to the node-local // database. // // Return the initial schema version found before starting the update, along // with any error occurred.
[ "EnsureSchema", "applies", "all", "relevant", "schema", "updates", "to", "the", "node", "-", "local", "database", ".", "Return", "the", "initial", "schema", "version", "found", "before", "starting", "the", "update", "along", "with", "any", "error", "occurred", ...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/node/open.go#L29-L63
test
lxc/lxd
lxd/util/fs.go
FilesystemDetect
func FilesystemDetect(path string) (string, error) { fs := syscall.Statfs_t{} err := syscall.Statfs(path, &fs) if err != nil { return "", err } switch fs.Type { case FilesystemSuperMagicBtrfs: return "btrfs", nil case FilesystemSuperMagicZfs: return "zfs", nil case FilesystemSuperMagicTmpfs: return "t...
go
func FilesystemDetect(path string) (string, error) { fs := syscall.Statfs_t{} err := syscall.Statfs(path, &fs) if err != nil { return "", err } switch fs.Type { case FilesystemSuperMagicBtrfs: return "btrfs", nil case FilesystemSuperMagicZfs: return "zfs", nil case FilesystemSuperMagicTmpfs: return "t...
[ "func", "FilesystemDetect", "(", "path", "string", ")", "(", "string", ",", "error", ")", "{", "fs", ":=", "syscall", ".", "Statfs_t", "{", "}", "\n", "err", ":=", "syscall", ".", "Statfs", "(", "path", ",", "&", "fs", ")", "\n", "if", "err", "!=",...
// FilesystemDetect returns the filesystem on which the passed-in path sits.
[ "FilesystemDetect", "returns", "the", "filesystem", "on", "which", "the", "passed", "-", "in", "path", "sits", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/util/fs.go#L19-L44
test
lxc/lxd
lxd/db/node/update.go
Schema
func Schema() *schema.Schema { schema := schema.NewFromMap(updates) schema.Fresh(freshSchema) return schema }
go
func Schema() *schema.Schema { schema := schema.NewFromMap(updates) schema.Fresh(freshSchema) return schema }
[ "func", "Schema", "(", ")", "*", "schema", ".", "Schema", "{", "schema", ":=", "schema", ".", "NewFromMap", "(", "updates", ")", "\n", "schema", ".", "Fresh", "(", "freshSchema", ")", "\n", "return", "schema", "\n", "}" ]
// Schema for the local database.
[ "Schema", "for", "the", "local", "database", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/node/update.go#L19-L23
test
lxc/lxd
lxd/db/node/update.go
updateFromV37
func updateFromV37(tx *sql.Tx) error { count, err := query.Count(tx, "raft_nodes", "") if err != nil { return errors.Wrap(err, "Fetch count of Raft nodes") } if count == 0 { // This node is not clustered, nothing to do. return nil } // Copy the core.https_address config. _, err = tx.Exec(` INSERT INTO co...
go
func updateFromV37(tx *sql.Tx) error { count, err := query.Count(tx, "raft_nodes", "") if err != nil { return errors.Wrap(err, "Fetch count of Raft nodes") } if count == 0 { // This node is not clustered, nothing to do. return nil } // Copy the core.https_address config. _, err = tx.Exec(` INSERT INTO co...
[ "func", "updateFromV37", "(", "tx", "*", "sql", ".", "Tx", ")", "error", "{", "count", ",", "err", ":=", "query", ".", "Count", "(", "tx", ",", "\"raft_nodes\"", ",", "\"\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap"...
// Schema updates begin here // Copy core.https_address to cluster.https_address in case this node is // clustered.
[ "Schema", "updates", "begin", "here", "Copy", "core", ".", "https_address", "to", "cluster", ".", "https_address", "in", "case", "this", "node", "is", "clustered", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/node/update.go#L106-L127
test
lxc/lxd
shared/osarch/architectures_linux.go
ArchitectureGetLocal
func ArchitectureGetLocal() (string, error) { uname, err := shared.Uname() if err != nil { return ArchitectureDefault, err } return uname.Machine, nil }
go
func ArchitectureGetLocal() (string, error) { uname, err := shared.Uname() if err != nil { return ArchitectureDefault, err } return uname.Machine, nil }
[ "func", "ArchitectureGetLocal", "(", ")", "(", "string", ",", "error", ")", "{", "uname", ",", "err", ":=", "shared", ".", "Uname", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ArchitectureDefault", ",", "err", "\n", "}", "\n", "return", ...
// ArchitectureGetLocal returns the local hardware architecture
[ "ArchitectureGetLocal", "returns", "the", "local", "hardware", "architecture" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/osarch/architectures_linux.go#L10-L17
test
lxc/lxd
lxd/maas/controller.go
NewController
func NewController(url string, key string, machine string) (*Controller, error) { baseURL := fmt.Sprintf("%s/api/2.0/", url) // Connect to MAAS srv, err := gomaasapi.NewController(gomaasapi.ControllerArgs{ BaseURL: baseURL, APIKey: key, }) if err != nil { // Juju errors aren't user-friendly, try to extract...
go
func NewController(url string, key string, machine string) (*Controller, error) { baseURL := fmt.Sprintf("%s/api/2.0/", url) // Connect to MAAS srv, err := gomaasapi.NewController(gomaasapi.ControllerArgs{ BaseURL: baseURL, APIKey: key, }) if err != nil { // Juju errors aren't user-friendly, try to extract...
[ "func", "NewController", "(", "url", "string", ",", "key", "string", ",", "machine", "string", ")", "(", "*", "Controller", ",", "error", ")", "{", "baseURL", ":=", "fmt", ".", "Sprintf", "(", "\"%s/api/2.0/\"", ",", "url", ")", "\n", "srv", ",", "err"...
// NewController returns a new Controller using the specific MAAS server and machine
[ "NewController", "returns", "a", "new", "Controller", "using", "the", "specific", "MAAS", "server", "and", "machine" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/maas/controller.go#L62-L103
test
lxc/lxd
lxd/maas/controller.go
CreateContainer
func (c *Controller) CreateContainer(name string, interfaces []ContainerInterface) error { // Parse the provided interfaces macInterfaces, err := parseInterfaces(interfaces) if err != nil { return err } // Get all the subnets subnets, err := c.getSubnets() if err != nil { return err } // Create the devic...
go
func (c *Controller) CreateContainer(name string, interfaces []ContainerInterface) error { // Parse the provided interfaces macInterfaces, err := parseInterfaces(interfaces) if err != nil { return err } // Get all the subnets subnets, err := c.getSubnets() if err != nil { return err } // Create the devic...
[ "func", "(", "c", "*", "Controller", ")", "CreateContainer", "(", "name", "string", ",", "interfaces", "[", "]", "ContainerInterface", ")", "error", "{", "macInterfaces", ",", "err", ":=", "parseInterfaces", "(", "interfaces", ")", "\n", "if", "err", "!=", ...
// CreateContainer defines a new MAAS device for the controller
[ "CreateContainer", "defines", "a", "new", "MAAS", "device", "for", "the", "controller" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/maas/controller.go#L137-L212
test
lxc/lxd
lxd/maas/controller.go
DefinedContainer
func (c *Controller) DefinedContainer(name string) (bool, error) { devs, err := c.machine.Devices(gomaasapi.DevicesArgs{Hostname: []string{name}}) if err != nil { return false, err } if len(devs) == 1 { return true, nil } return false, nil }
go
func (c *Controller) DefinedContainer(name string) (bool, error) { devs, err := c.machine.Devices(gomaasapi.DevicesArgs{Hostname: []string{name}}) if err != nil { return false, err } if len(devs) == 1 { return true, nil } return false, nil }
[ "func", "(", "c", "*", "Controller", ")", "DefinedContainer", "(", "name", "string", ")", "(", "bool", ",", "error", ")", "{", "devs", ",", "err", ":=", "c", ".", "machine", ".", "Devices", "(", "gomaasapi", ".", "DevicesArgs", "{", "Hostname", ":", ...
// DefinedContainer returns true if the container is defined in MAAS
[ "DefinedContainer", "returns", "true", "if", "the", "container", "is", "defined", "in", "MAAS" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/maas/controller.go#L215-L226
test
lxc/lxd
lxd/maas/controller.go
UpdateContainer
func (c *Controller) UpdateContainer(name string, interfaces []ContainerInterface) error { // Parse the provided interfaces macInterfaces, err := parseInterfaces(interfaces) if err != nil { return err } // Get all the subnets subnets, err := c.getSubnets() if err != nil { return err } device, err := c.ge...
go
func (c *Controller) UpdateContainer(name string, interfaces []ContainerInterface) error { // Parse the provided interfaces macInterfaces, err := parseInterfaces(interfaces) if err != nil { return err } // Get all the subnets subnets, err := c.getSubnets() if err != nil { return err } device, err := c.ge...
[ "func", "(", "c", "*", "Controller", ")", "UpdateContainer", "(", "name", "string", ",", "interfaces", "[", "]", "ContainerInterface", ")", "error", "{", "macInterfaces", ",", "err", ":=", "parseInterfaces", "(", "interfaces", ")", "\n", "if", "err", "!=", ...
// UpdateContainer updates the MAAS device's interfaces with the new provided state
[ "UpdateContainer", "updates", "the", "MAAS", "device", "s", "interfaces", "with", "the", "new", "provided", "state" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/maas/controller.go#L229-L345
test
lxc/lxd
lxd/maas/controller.go
RenameContainer
func (c *Controller) RenameContainer(name string, newName string) error { device, err := c.getDevice(name) if err != nil { return err } // FIXME: We should convince the Juju folks to implement an Update() method on Device uri, err := url.Parse(fmt.Sprintf("%s/devices/%s/", c.url, device.SystemID())) if err != ...
go
func (c *Controller) RenameContainer(name string, newName string) error { device, err := c.getDevice(name) if err != nil { return err } // FIXME: We should convince the Juju folks to implement an Update() method on Device uri, err := url.Parse(fmt.Sprintf("%s/devices/%s/", c.url, device.SystemID())) if err != ...
[ "func", "(", "c", "*", "Controller", ")", "RenameContainer", "(", "name", "string", ",", "newName", "string", ")", "error", "{", "device", ",", "err", ":=", "c", ".", "getDevice", "(", "name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err"...
// RenameContainer renames the MAAS device for the container without releasing any allocation
[ "RenameContainer", "renames", "the", "MAAS", "device", "for", "the", "container", "without", "releasing", "any", "allocation" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/maas/controller.go#L348-L369
test
lxc/lxd
lxd/maas/controller.go
DeleteContainer
func (c *Controller) DeleteContainer(name string) error { device, err := c.getDevice(name) if err != nil { return err } err = device.Delete() if err != nil { return err } return nil }
go
func (c *Controller) DeleteContainer(name string) error { device, err := c.getDevice(name) if err != nil { return err } err = device.Delete() if err != nil { return err } return nil }
[ "func", "(", "c", "*", "Controller", ")", "DeleteContainer", "(", "name", "string", ")", "error", "{", "device", ",", "err", ":=", "c", ".", "getDevice", "(", "name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "err"...
// DeleteContainer removes the MAAS device for the container
[ "DeleteContainer", "removes", "the", "MAAS", "device", "for", "the", "container" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/maas/controller.go#L372-L384
test
lxc/lxd
lxd/db/schema/schema.go
Add
func (s *Schema) Add(update Update) { s.updates = append(s.updates, update) }
go
func (s *Schema) Add(update Update) { s.updates = append(s.updates, update) }
[ "func", "(", "s", "*", "Schema", ")", "Add", "(", "update", "Update", ")", "{", "s", ".", "updates", "=", "append", "(", "s", ".", "updates", ",", "update", ")", "\n", "}" ]
// Add a new update to the schema. It will be appended at the end of the // existing series.
[ "Add", "a", "new", "update", "to", "the", "schema", ".", "It", "will", "be", "appended", "at", "the", "end", "of", "the", "existing", "series", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/schema/schema.go#L88-L90
test
lxc/lxd
lxd/db/schema/schema.go
ensureSchemaTableExists
func ensureSchemaTableExists(tx *sql.Tx) error { exists, err := DoesSchemaTableExist(tx) if err != nil { return fmt.Errorf("failed to check if schema table is there: %v", err) } if !exists { err := createSchemaTable(tx) if err != nil { return fmt.Errorf("failed to create schema table: %v", err) } } ret...
go
func ensureSchemaTableExists(tx *sql.Tx) error { exists, err := DoesSchemaTableExist(tx) if err != nil { return fmt.Errorf("failed to check if schema table is there: %v", err) } if !exists { err := createSchemaTable(tx) if err != nil { return fmt.Errorf("failed to create schema table: %v", err) } } ret...
[ "func", "ensureSchemaTableExists", "(", "tx", "*", "sql", ".", "Tx", ")", "error", "{", "exists", ",", "err", ":=", "DoesSchemaTableExist", "(", "tx", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "\"failed to check if sche...
// Ensure that the schema exists.
[ "Ensure", "that", "the", "schema", "exists", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/schema/schema.go#L276-L288
test
lxc/lxd
lxd/db/schema/schema.go
queryCurrentVersion
func queryCurrentVersion(tx *sql.Tx) (int, error) { versions, err := selectSchemaVersions(tx) if err != nil { return -1, fmt.Errorf("failed to fetch update versions: %v", err) } // Fix bad upgrade code between 30 and 32 hasVersion := func(v int) bool { return shared.IntInSlice(v, versions) } if hasVersion(30) ...
go
func queryCurrentVersion(tx *sql.Tx) (int, error) { versions, err := selectSchemaVersions(tx) if err != nil { return -1, fmt.Errorf("failed to fetch update versions: %v", err) } // Fix bad upgrade code between 30 and 32 hasVersion := func(v int) bool { return shared.IntInSlice(v, versions) } if hasVersion(30) ...
[ "func", "queryCurrentVersion", "(", "tx", "*", "sql", ".", "Tx", ")", "(", "int", ",", "error", ")", "{", "versions", ",", "err", ":=", "selectSchemaVersions", "(", "tx", ")", "\n", "if", "err", "!=", "nil", "{", "return", "-", "1", ",", "fmt", "."...
// Return the highest update version currently applied. Zero means that no // updates have been applied yet.
[ "Return", "the", "highest", "update", "version", "currently", "applied", ".", "Zero", "means", "that", "no", "updates", "have", "been", "applied", "yet", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/schema/schema.go#L292-L338
test
lxc/lxd
lxd/db/schema/schema.go
ensureUpdatesAreApplied
func ensureUpdatesAreApplied(tx *sql.Tx, current int, updates []Update, hook Hook) error { if current > len(updates) { return fmt.Errorf( "schema version '%d' is more recent than expected '%d'", current, len(updates)) } // If there are no updates, there's nothing to do. if len(updates) == 0 { return nil ...
go
func ensureUpdatesAreApplied(tx *sql.Tx, current int, updates []Update, hook Hook) error { if current > len(updates) { return fmt.Errorf( "schema version '%d' is more recent than expected '%d'", current, len(updates)) } // If there are no updates, there's nothing to do. if len(updates) == 0 { return nil ...
[ "func", "ensureUpdatesAreApplied", "(", "tx", "*", "sql", ".", "Tx", ",", "current", "int", ",", "updates", "[", "]", "Update", ",", "hook", "Hook", ")", "error", "{", "if", "current", ">", "len", "(", "updates", ")", "{", "return", "fmt", ".", "Erro...
// Apply any pending update that was not yet applied.
[ "Apply", "any", "pending", "update", "that", "was", "not", "yet", "applied", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/schema/schema.go#L341-L375
test
lxc/lxd
lxd/db/schema/schema.go
checkSchemaVersionsHaveNoHoles
func checkSchemaVersionsHaveNoHoles(versions []int) error { // Sanity check that there are no "holes" in the recorded // versions. for i := range versions[:len(versions)-1] { if versions[i+1] != versions[i]+1 { return fmt.Errorf("Missing updates: %d to %d", versions[i], versions[i+1]) } } return nil }
go
func checkSchemaVersionsHaveNoHoles(versions []int) error { // Sanity check that there are no "holes" in the recorded // versions. for i := range versions[:len(versions)-1] { if versions[i+1] != versions[i]+1 { return fmt.Errorf("Missing updates: %d to %d", versions[i], versions[i+1]) } } return nil }
[ "func", "checkSchemaVersionsHaveNoHoles", "(", "versions", "[", "]", "int", ")", "error", "{", "for", "i", ":=", "range", "versions", "[", ":", "len", "(", "versions", ")", "-", "1", "]", "{", "if", "versions", "[", "i", "+", "1", "]", "!=", "version...
// Check that the given list of update version numbers doesn't have "holes", // that is each version equal the preceding version plus 1.
[ "Check", "that", "the", "given", "list", "of", "update", "version", "numbers", "doesn", "t", "have", "holes", "that", "is", "each", "version", "equal", "the", "preceding", "version", "plus", "1", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/schema/schema.go#L379-L388
test
lxc/lxd
lxd/db/schema/schema.go
checkAllUpdatesAreApplied
func checkAllUpdatesAreApplied(tx *sql.Tx, updates []Update) error { versions, err := selectSchemaVersions(tx) if err != nil { return fmt.Errorf("failed to fetch update versions: %v", err) } if len(versions) == 0 { return fmt.Errorf("expected schema table to contain at least one row") } err = checkSchemaVer...
go
func checkAllUpdatesAreApplied(tx *sql.Tx, updates []Update) error { versions, err := selectSchemaVersions(tx) if err != nil { return fmt.Errorf("failed to fetch update versions: %v", err) } if len(versions) == 0 { return fmt.Errorf("expected schema table to contain at least one row") } err = checkSchemaVer...
[ "func", "checkAllUpdatesAreApplied", "(", "tx", "*", "sql", ".", "Tx", ",", "updates", "[", "]", "Update", ")", "error", "{", "versions", ",", "err", ":=", "selectSchemaVersions", "(", "tx", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", "....
// Check that all the given updates are applied.
[ "Check", "that", "all", "the", "given", "updates", "are", "applied", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/schema/schema.go#L391-L411
test
lxc/lxd
lxd/db/schema/schema.go
formatSQL
func formatSQL(statement string) string { lines := strings.Split(statement, "\n") for i, line := range lines { if strings.Contains(line, "UNIQUE") { // Let UNIQUE(x, y) constraints alone. continue } lines[i] = strings.Replace(line, ", ", ",\n ", -1) } return strings.Join(lines, "\n") }
go
func formatSQL(statement string) string { lines := strings.Split(statement, "\n") for i, line := range lines { if strings.Contains(line, "UNIQUE") { // Let UNIQUE(x, y) constraints alone. continue } lines[i] = strings.Replace(line, ", ", ",\n ", -1) } return strings.Join(lines, "\n") }
[ "func", "formatSQL", "(", "statement", "string", ")", "string", "{", "lines", ":=", "strings", ".", "Split", "(", "statement", ",", "\"\\n\"", ")", "\n", "\\n", "\n", "for", "i", ",", "line", ":=", "range", "lines", "{", "if", "strings", ".", "Contains...
// Format the given SQL statement in a human-readable way. // // In particular make sure that each column definition in a CREATE TABLE clause // is in its own row, since SQLite dumps occasionally stuff more than one // column in the same line.
[ "Format", "the", "given", "SQL", "statement", "in", "a", "human", "-", "readable", "way", ".", "In", "particular", "make", "sure", "that", "each", "column", "definition", "in", "a", "CREATE", "TABLE", "clause", "is", "in", "its", "own", "row", "since", "...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/schema/schema.go#L418-L428
test
lxc/lxd
shared/util_linux.go
GetAllXattr
func GetAllXattr(path string) (xattrs map[string]string, err error) { e1 := fmt.Errorf("Extended attributes changed during retrieval") // Call llistxattr() twice: First, to determine the size of the buffer // we need to allocate to store the extended attributes, second, to // actually store the extended attributes...
go
func GetAllXattr(path string) (xattrs map[string]string, err error) { e1 := fmt.Errorf("Extended attributes changed during retrieval") // Call llistxattr() twice: First, to determine the size of the buffer // we need to allocate to store the extended attributes, second, to // actually store the extended attributes...
[ "func", "GetAllXattr", "(", "path", "string", ")", "(", "xattrs", "map", "[", "string", "]", "string", ",", "err", "error", ")", "{", "e1", ":=", "fmt", ".", "Errorf", "(", "\"Extended attributes changed during retrieval\"", ")", "\n", "pre", ",", "err", "...
// GetAllXattr retrieves all extended attributes associated with a file, // directory or symbolic link.
[ "GetAllXattr", "retrieves", "all", "extended", "attributes", "associated", "with", "a", "file", "directory", "or", "symbolic", "link", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/util_linux.go#L150-L220
test
lxc/lxd
shared/util_linux.go
GetErrno
func GetErrno(err error) (errno error, iserrno bool) { sysErr, ok := err.(*os.SyscallError) if ok { return sysErr.Err, true } pathErr, ok := err.(*os.PathError) if ok { return pathErr.Err, true } tmpErrno, ok := err.(syscall.Errno) if ok { return tmpErrno, true } return nil, false }
go
func GetErrno(err error) (errno error, iserrno bool) { sysErr, ok := err.(*os.SyscallError) if ok { return sysErr.Err, true } pathErr, ok := err.(*os.PathError) if ok { return pathErr.Err, true } tmpErrno, ok := err.(syscall.Errno) if ok { return tmpErrno, true } return nil, false }
[ "func", "GetErrno", "(", "err", "error", ")", "(", "errno", "error", ",", "iserrno", "bool", ")", "{", "sysErr", ",", "ok", ":=", "err", ".", "(", "*", "os", ".", "SyscallError", ")", "\n", "if", "ok", "{", "return", "sysErr", ".", "Err", ",", "t...
// Detect whether err is an errno.
[ "Detect", "whether", "err", "is", "an", "errno", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/util_linux.go#L265-L282
test
lxc/lxd
shared/util_linux.go
Uname
func Uname() (*Utsname, error) { /* * Based on: https://groups.google.com/forum/#!topic/golang-nuts/Jel8Bb-YwX8 * there is really no better way to do this, which is * unfortunate. Also, we ditch the more accepted CharsToString * version in that thread, since it doesn't seem as portable, * viz. github issue #...
go
func Uname() (*Utsname, error) { /* * Based on: https://groups.google.com/forum/#!topic/golang-nuts/Jel8Bb-YwX8 * there is really no better way to do this, which is * unfortunate. Also, we ditch the more accepted CharsToString * version in that thread, since it doesn't seem as portable, * viz. github issue #...
[ "func", "Uname", "(", ")", "(", "*", "Utsname", ",", "error", ")", "{", "uname", ":=", "syscall", ".", "Utsname", "{", "}", "\n", "err", ":=", "syscall", ".", "Uname", "(", "&", "uname", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ...
// Uname returns Utsname as strings
[ "Uname", "returns", "Utsname", "as", "strings" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/util_linux.go#L295-L318
test
lxc/lxd
lxd/db/cluster/stmt.go
RegisterStmt
func RegisterStmt(sql string) int { code := len(stmts) stmts[code] = sql return code }
go
func RegisterStmt(sql string) int { code := len(stmts) stmts[code] = sql return code }
[ "func", "RegisterStmt", "(", "sql", "string", ")", "int", "{", "code", ":=", "len", "(", "stmts", ")", "\n", "stmts", "[", "code", "]", "=", "sql", "\n", "return", "code", "\n", "}" ]
// RegisterStmt register a SQL statement. // // Registered statements will be prepared upfront and re-used, to speed up // execution. // // Return a unique registration code.
[ "RegisterStmt", "register", "a", "SQL", "statement", ".", "Registered", "statements", "will", "be", "prepared", "upfront", "and", "re", "-", "used", "to", "speed", "up", "execution", ".", "Return", "a", "unique", "registration", "code", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/cluster/stmt.go#L15-L19
test
lxc/lxd
lxd/db/cluster/stmt.go
PrepareStmts
func PrepareStmts(db *sql.DB) (map[int]*sql.Stmt, error) { index := map[int]*sql.Stmt{} for code, sql := range stmts { stmt, err := db.Prepare(sql) if err != nil { return nil, errors.Wrapf(err, "%q", sql) } index[code] = stmt } return index, nil }
go
func PrepareStmts(db *sql.DB) (map[int]*sql.Stmt, error) { index := map[int]*sql.Stmt{} for code, sql := range stmts { stmt, err := db.Prepare(sql) if err != nil { return nil, errors.Wrapf(err, "%q", sql) } index[code] = stmt } return index, nil }
[ "func", "PrepareStmts", "(", "db", "*", "sql", ".", "DB", ")", "(", "map", "[", "int", "]", "*", "sql", ".", "Stmt", ",", "error", ")", "{", "index", ":=", "map", "[", "int", "]", "*", "sql", ".", "Stmt", "{", "}", "\n", "for", "code", ",", ...
// PrepareStmts prepares all registered statements and returns an index from // statement code to prepared statement object.
[ "PrepareStmts", "prepares", "all", "registered", "statements", "and", "returns", "an", "index", "from", "statement", "code", "to", "prepared", "statement", "object", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/cluster/stmt.go#L23-L35
test
lxc/lxd
lxd/cluster/gateway.go
NewGateway
func NewGateway(db *db.Node, cert *shared.CertInfo, options ...Option) (*Gateway, error) { ctx, cancel := context.WithCancel(context.Background()) o := newOptions() for _, option := range options { option(o) } gateway := &Gateway{ db: db, cert: cert, options: o, ctx: ctx, cancel:...
go
func NewGateway(db *db.Node, cert *shared.CertInfo, options ...Option) (*Gateway, error) { ctx, cancel := context.WithCancel(context.Background()) o := newOptions() for _, option := range options { option(o) } gateway := &Gateway{ db: db, cert: cert, options: o, ctx: ctx, cancel:...
[ "func", "NewGateway", "(", "db", "*", "db", ".", "Node", ",", "cert", "*", "shared", ".", "CertInfo", ",", "options", "...", "Option", ")", "(", "*", "Gateway", ",", "error", ")", "{", "ctx", ",", "cancel", ":=", "context", ".", "WithCancel", "(", ...
// NewGateway creates a new Gateway for managing access to the dqlite cluster. // // When a new gateway is created, the node-level database is queried to check // what kind of role this node plays and if it's exposed over the network. It // will initialize internal data structures accordingly, for example starting a //...
[ "NewGateway", "creates", "a", "new", "Gateway", "for", "managing", "access", "to", "the", "dqlite", "cluster", ".", "When", "a", "new", "gateway", "is", "created", "the", "node", "-", "level", "database", "is", "queried", "to", "check", "what", "kind", "of...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/gateway.go#L37-L63
test
lxc/lxd
lxd/cluster/gateway.go
DialFunc
func (g *Gateway) DialFunc() dqlite.DialFunc { return func(ctx context.Context, address string) (net.Conn, error) { // Memory connection. if g.memoryDial != nil { return g.memoryDial(ctx, address) } return dqliteNetworkDial(ctx, address, g.cert) } }
go
func (g *Gateway) DialFunc() dqlite.DialFunc { return func(ctx context.Context, address string) (net.Conn, error) { // Memory connection. if g.memoryDial != nil { return g.memoryDial(ctx, address) } return dqliteNetworkDial(ctx, address, g.cert) } }
[ "func", "(", "g", "*", "Gateway", ")", "DialFunc", "(", ")", "dqlite", ".", "DialFunc", "{", "return", "func", "(", "ctx", "context", ".", "Context", ",", "address", "string", ")", "(", "net", ".", "Conn", ",", "error", ")", "{", "if", "g", ".", ...
// DialFunc returns a dial function that can be used to connect to one of the // dqlite nodes.
[ "DialFunc", "returns", "a", "dial", "function", "that", "can", "be", "used", "to", "connect", "to", "one", "of", "the", "dqlite", "nodes", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/gateway.go#L265-L274
test
lxc/lxd
lxd/cluster/gateway.go
Shutdown
func (g *Gateway) Shutdown() error { logger.Debugf("Stop database gateway") if g.raft != nil { err := g.raft.Shutdown() if err != nil { return errors.Wrap(err, "Failed to shutdown raft") } } if g.server != nil { g.Sync() g.server.Close() // Unset the memory dial, since Shutdown() is also called fo...
go
func (g *Gateway) Shutdown() error { logger.Debugf("Stop database gateway") if g.raft != nil { err := g.raft.Shutdown() if err != nil { return errors.Wrap(err, "Failed to shutdown raft") } } if g.server != nil { g.Sync() g.server.Close() // Unset the memory dial, since Shutdown() is also called fo...
[ "func", "(", "g", "*", "Gateway", ")", "Shutdown", "(", ")", "error", "{", "logger", ".", "Debugf", "(", "\"Stop database gateway\"", ")", "\n", "if", "g", ".", "raft", "!=", "nil", "{", "err", ":=", "g", ".", "raft", ".", "Shutdown", "(", ")", "\n...
// Shutdown this gateway, stopping the gRPC server and possibly the raft factory.
[ "Shutdown", "this", "gateway", "stopping", "the", "gRPC", "server", "and", "possibly", "the", "raft", "factory", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/gateway.go#L301-L321
test
lxc/lxd
lxd/cluster/gateway.go
Sync
func (g *Gateway) Sync() { if g.server == nil { return } dir := filepath.Join(g.db.Dir(), "global") err := g.server.Dump("db.bin", dir) if err != nil { // Just log a warning, since this is not fatal. logger.Warnf("Failed to dump database to disk: %v", err) } }
go
func (g *Gateway) Sync() { if g.server == nil { return } dir := filepath.Join(g.db.Dir(), "global") err := g.server.Dump("db.bin", dir) if err != nil { // Just log a warning, since this is not fatal. logger.Warnf("Failed to dump database to disk: %v", err) } }
[ "func", "(", "g", "*", "Gateway", ")", "Sync", "(", ")", "{", "if", "g", ".", "server", "==", "nil", "{", "return", "\n", "}", "\n", "dir", ":=", "filepath", ".", "Join", "(", "g", ".", "db", ".", "Dir", "(", ")", ",", "\"global\"", ")", "\n"...
// Sync dumps the content of the database to disk. This is useful for // inspection purposes, and it's also needed by the activateifneeded command so // it can inspect the database in order to decide whether to activate the // daemon or not.
[ "Sync", "dumps", "the", "content", "of", "the", "database", "to", "disk", ".", "This", "is", "useful", "for", "inspection", "purposes", "and", "it", "s", "also", "needed", "by", "the", "activateifneeded", "command", "so", "it", "can", "inspect", "the", "da...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/gateway.go#L327-L338
test
lxc/lxd
lxd/cluster/gateway.go
Reset
func (g *Gateway) Reset(cert *shared.CertInfo) error { err := g.Shutdown() if err != nil { return err } err = os.RemoveAll(filepath.Join(g.db.Dir(), "global")) if err != nil { return err } err = g.db.Transaction(func(tx *db.NodeTx) error { return tx.RaftNodesReplace(nil) }) if err != nil { return err ...
go
func (g *Gateway) Reset(cert *shared.CertInfo) error { err := g.Shutdown() if err != nil { return err } err = os.RemoveAll(filepath.Join(g.db.Dir(), "global")) if err != nil { return err } err = g.db.Transaction(func(tx *db.NodeTx) error { return tx.RaftNodesReplace(nil) }) if err != nil { return err ...
[ "func", "(", "g", "*", "Gateway", ")", "Reset", "(", "cert", "*", "shared", ".", "CertInfo", ")", "error", "{", "err", ":=", "g", ".", "Shutdown", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "err", "=", "os"...
// Reset the gateway, shutting it down and starting against from scratch using // the given certificate. // // This is used when disabling clustering on a node.
[ "Reset", "the", "gateway", "shutting", "it", "down", "and", "starting", "against", "from", "scratch", "using", "the", "given", "certificate", ".", "This", "is", "used", "when", "disabling", "clustering", "on", "a", "node", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/gateway.go#L344-L361
test
lxc/lxd
lxd/cluster/gateway.go
LeaderAddress
func (g *Gateway) LeaderAddress() (string, error) { // If we aren't clustered, return an error. if g.memoryDial != nil { return "", fmt.Errorf("Node is not clustered") } ctx, cancel := context.WithTimeout(g.ctx, 5*time.Second) defer cancel() // If this is a raft node, return the address of the current leader,...
go
func (g *Gateway) LeaderAddress() (string, error) { // If we aren't clustered, return an error. if g.memoryDial != nil { return "", fmt.Errorf("Node is not clustered") } ctx, cancel := context.WithTimeout(g.ctx, 5*time.Second) defer cancel() // If this is a raft node, return the address of the current leader,...
[ "func", "(", "g", "*", "Gateway", ")", "LeaderAddress", "(", ")", "(", "string", ",", "error", ")", "{", "if", "g", ".", "memoryDial", "!=", "nil", "{", "return", "\"\"", ",", "fmt", ".", "Errorf", "(", "\"Node is not clustered\"", ")", "\n", "}", "\...
// LeaderAddress returns the address of the current raft leader.
[ "LeaderAddress", "returns", "the", "address", "of", "the", "current", "raft", "leader", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/gateway.go#L364-L447
test
lxc/lxd
lxd/cluster/gateway.go
waitLeadership
func (g *Gateway) waitLeadership() error { n := 80 sleep := 250 * time.Millisecond for i := 0; i < n; i++ { if g.raft.raft.State() == raft.Leader { return nil } time.Sleep(sleep) } return fmt.Errorf("RAFT node did not self-elect within %s", time.Duration(n)*sleep) }
go
func (g *Gateway) waitLeadership() error { n := 80 sleep := 250 * time.Millisecond for i := 0; i < n; i++ { if g.raft.raft.State() == raft.Leader { return nil } time.Sleep(sleep) } return fmt.Errorf("RAFT node did not self-elect within %s", time.Duration(n)*sleep) }
[ "func", "(", "g", "*", "Gateway", ")", "waitLeadership", "(", ")", "error", "{", "n", ":=", "80", "\n", "sleep", ":=", "250", "*", "time", ".", "Millisecond", "\n", "for", "i", ":=", "0", ";", "i", "<", "n", ";", "i", "++", "{", "if", "g", "....
// Wait for the raft node to become leader. Should only be used by Bootstrap, // since we know that we'll self elect.
[ "Wait", "for", "the", "raft", "node", "to", "become", "leader", ".", "Should", "only", "be", "used", "by", "Bootstrap", "since", "we", "know", "that", "we", "ll", "self", "elect", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/gateway.go#L501-L511
test
lxc/lxd
lxd/cluster/gateway.go
currentRaftNodes
func (g *Gateway) currentRaftNodes() ([]db.RaftNode, error) { if g.raft == nil { return nil, raft.ErrNotLeader } servers, err := g.raft.Servers() if err != nil { return nil, err } provider := raftAddressProvider{db: g.db} nodes := make([]db.RaftNode, len(servers)) for i, server := range servers { address,...
go
func (g *Gateway) currentRaftNodes() ([]db.RaftNode, error) { if g.raft == nil { return nil, raft.ErrNotLeader } servers, err := g.raft.Servers() if err != nil { return nil, err } provider := raftAddressProvider{db: g.db} nodes := make([]db.RaftNode, len(servers)) for i, server := range servers { address,...
[ "func", "(", "g", "*", "Gateway", ")", "currentRaftNodes", "(", ")", "(", "[", "]", "db", ".", "RaftNode", ",", "error", ")", "{", "if", "g", ".", "raft", "==", "nil", "{", "return", "nil", ",", "raft", ".", "ErrNotLeader", "\n", "}", "\n", "serv...
// Return information about the LXD nodes that a currently part of the raft // cluster, as configured in the raft log. It returns an error if this node is // not the leader.
[ "Return", "information", "about", "the", "LXD", "nodes", "that", "a", "currently", "part", "of", "the", "raft", "cluster", "as", "configured", "in", "the", "raft", "log", ".", "It", "returns", "an", "error", "if", "this", "node", "is", "not", "the", "lea...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/gateway.go#L516-L545
test
lxc/lxd
lxd/cluster/gateway.go
cachedRaftNodes
func (g *Gateway) cachedRaftNodes() ([]string, error) { var addresses []string err := g.db.Transaction(func(tx *db.NodeTx) error { var err error addresses, err = tx.RaftNodeAddresses() return err }) if err != nil { return nil, errors.Wrap(err, "Failed to fetch raft nodes") } return addresses, nil }
go
func (g *Gateway) cachedRaftNodes() ([]string, error) { var addresses []string err := g.db.Transaction(func(tx *db.NodeTx) error { var err error addresses, err = tx.RaftNodeAddresses() return err }) if err != nil { return nil, errors.Wrap(err, "Failed to fetch raft nodes") } return addresses, nil }
[ "func", "(", "g", "*", "Gateway", ")", "cachedRaftNodes", "(", ")", "(", "[", "]", "string", ",", "error", ")", "{", "var", "addresses", "[", "]", "string", "\n", "err", ":=", "g", ".", "db", ".", "Transaction", "(", "func", "(", "tx", "*", "db",...
// Return the addresses of the raft nodes as stored in the node-level // database. // // These values might leg behind the actual values, and are refreshed // periodically during heartbeats.
[ "Return", "the", "addresses", "of", "the", "raft", "nodes", "as", "stored", "in", "the", "node", "-", "level", "database", ".", "These", "values", "might", "leg", "behind", "the", "actual", "values", "and", "are", "refreshed", "periodically", "during", "hear...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/gateway.go#L552-L563
test
lxc/lxd
lxd/cluster/gateway.go
dqliteMemoryDial
func dqliteMemoryDial(listener net.Listener) dqlite.DialFunc { return func(ctx context.Context, address string) (net.Conn, error) { return net.Dial("unix", listener.Addr().String()) } }
go
func dqliteMemoryDial(listener net.Listener) dqlite.DialFunc { return func(ctx context.Context, address string) (net.Conn, error) { return net.Dial("unix", listener.Addr().String()) } }
[ "func", "dqliteMemoryDial", "(", "listener", "net", ".", "Listener", ")", "dqlite", ".", "DialFunc", "{", "return", "func", "(", "ctx", "context", ".", "Context", ",", "address", "string", ")", "(", "net", ".", "Conn", ",", "error", ")", "{", "return", ...
// Create a dial function that connects to the given listener.
[ "Create", "a", "dial", "function", "that", "connects", "to", "the", "given", "listener", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/gateway.go#L640-L644
test
lxc/lxd
lxd/cluster/gateway.go
DqliteLog
func DqliteLog(l dqlite.LogLevel, format string, a ...interface{}) { format = fmt.Sprintf("Dqlite: %s", format) switch l { case dqlite.LogDebug: logger.Debugf(format, a...) case dqlite.LogInfo: logger.Debugf(format, a...) case dqlite.LogWarn: logger.Warnf(format, a...) case dqlite.LogError: logger.Errorf(...
go
func DqliteLog(l dqlite.LogLevel, format string, a ...interface{}) { format = fmt.Sprintf("Dqlite: %s", format) switch l { case dqlite.LogDebug: logger.Debugf(format, a...) case dqlite.LogInfo: logger.Debugf(format, a...) case dqlite.LogWarn: logger.Warnf(format, a...) case dqlite.LogError: logger.Errorf(...
[ "func", "DqliteLog", "(", "l", "dqlite", ".", "LogLevel", ",", "format", "string", ",", "a", "...", "interface", "{", "}", ")", "{", "format", "=", "fmt", ".", "Sprintf", "(", "\"Dqlite: %s\"", ",", "format", ")", "\n", "switch", "l", "{", "case", "d...
// DqliteLog redirects dqlite's logs to our own logger
[ "DqliteLog", "redirects", "dqlite", "s", "logs", "to", "our", "own", "logger" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/gateway.go#L651-L663
test
lxc/lxd
shared/api/response.go
MetadataAsMap
func (r *Response) MetadataAsMap() (map[string]interface{}, error) { ret := map[string]interface{}{} err := r.MetadataAsStruct(&ret) if err != nil { return nil, err } return ret, nil }
go
func (r *Response) MetadataAsMap() (map[string]interface{}, error) { ret := map[string]interface{}{} err := r.MetadataAsStruct(&ret) if err != nil { return nil, err } return ret, nil }
[ "func", "(", "r", "*", "Response", ")", "MetadataAsMap", "(", ")", "(", "map", "[", "string", "]", "interface", "{", "}", ",", "error", ")", "{", "ret", ":=", "map", "[", "string", "]", "interface", "{", "}", "{", "}", "\n", "err", ":=", "r", "...
// MetadataAsMap parses the Response metadata into a map
[ "MetadataAsMap", "parses", "the", "Response", "metadata", "into", "a", "map" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/api/response.go#L45-L53
test
lxc/lxd
shared/api/response.go
MetadataAsOperation
func (r *Response) MetadataAsOperation() (*Operation, error) { op := Operation{} err := r.MetadataAsStruct(&op) if err != nil { return nil, err } return &op, nil }
go
func (r *Response) MetadataAsOperation() (*Operation, error) { op := Operation{} err := r.MetadataAsStruct(&op) if err != nil { return nil, err } return &op, nil }
[ "func", "(", "r", "*", "Response", ")", "MetadataAsOperation", "(", ")", "(", "*", "Operation", ",", "error", ")", "{", "op", ":=", "Operation", "{", "}", "\n", "err", ":=", "r", ".", "MetadataAsStruct", "(", "&", "op", ")", "\n", "if", "err", "!="...
// MetadataAsOperation turns the Response metadata into an Operation
[ "MetadataAsOperation", "turns", "the", "Response", "metadata", "into", "an", "Operation" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/api/response.go#L56-L64
test
lxc/lxd
shared/api/response.go
MetadataAsStringSlice
func (r *Response) MetadataAsStringSlice() ([]string, error) { sl := []string{} err := r.MetadataAsStruct(&sl) if err != nil { return nil, err } return sl, nil }
go
func (r *Response) MetadataAsStringSlice() ([]string, error) { sl := []string{} err := r.MetadataAsStruct(&sl) if err != nil { return nil, err } return sl, nil }
[ "func", "(", "r", "*", "Response", ")", "MetadataAsStringSlice", "(", ")", "(", "[", "]", "string", ",", "error", ")", "{", "sl", ":=", "[", "]", "string", "{", "}", "\n", "err", ":=", "r", ".", "MetadataAsStruct", "(", "&", "sl", ")", "\n", "if"...
// MetadataAsStringSlice parses the Response metadata into a slice of string
[ "MetadataAsStringSlice", "parses", "the", "Response", "metadata", "into", "a", "slice", "of", "string" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/api/response.go#L67-L75
test
lxc/lxd
shared/api/response.go
MetadataAsStruct
func (r *Response) MetadataAsStruct(target interface{}) error { return json.Unmarshal(r.Metadata, &target) }
go
func (r *Response) MetadataAsStruct(target interface{}) error { return json.Unmarshal(r.Metadata, &target) }
[ "func", "(", "r", "*", "Response", ")", "MetadataAsStruct", "(", "target", "interface", "{", "}", ")", "error", "{", "return", "json", ".", "Unmarshal", "(", "r", ".", "Metadata", ",", "&", "target", ")", "\n", "}" ]
// MetadataAsStruct parses the Response metadata into a provided struct
[ "MetadataAsStruct", "parses", "the", "Response", "metadata", "into", "a", "provided", "struct" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/api/response.go#L78-L80
test
lxc/lxd
lxd-benchmark/benchmark/report.go
Load
func (r *CSVReport) Load() error { file, err := os.Open(r.Filename) if err != nil { return err } defer file.Close() reader := csv.NewReader(file) for line := 1; err != io.EOF; line++ { record, err := reader.Read() if err == io.EOF { break } else if err != nil { return err } err = r.addRecord(r...
go
func (r *CSVReport) Load() error { file, err := os.Open(r.Filename) if err != nil { return err } defer file.Close() reader := csv.NewReader(file) for line := 1; err != io.EOF; line++ { record, err := reader.Read() if err == io.EOF { break } else if err != nil { return err } err = r.addRecord(r...
[ "func", "(", "r", "*", "CSVReport", ")", "Load", "(", ")", "error", "{", "file", ",", "err", ":=", "os", ".", "Open", "(", "r", ".", "Filename", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "file", ".", ...
// Load reads current content of the filename and loads records.
[ "Load", "reads", "current", "content", "of", "the", "filename", "and", "loads", "records", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd-benchmark/benchmark/report.go#L30-L53
test
lxc/lxd
lxd-benchmark/benchmark/report.go
Write
func (r *CSVReport) Write() error { file, err := os.OpenFile(r.Filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0640) if err != nil { return err } defer file.Close() writer := csv.NewWriter(file) err = writer.WriteAll(r.records) if err != nil { return err } logf("Written report file %s", r.Filename) return...
go
func (r *CSVReport) Write() error { file, err := os.OpenFile(r.Filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0640) if err != nil { return err } defer file.Close() writer := csv.NewWriter(file) err = writer.WriteAll(r.records) if err != nil { return err } logf("Written report file %s", r.Filename) return...
[ "func", "(", "r", "*", "CSVReport", ")", "Write", "(", ")", "error", "{", "file", ",", "err", ":=", "os", ".", "OpenFile", "(", "r", ".", "Filename", ",", "os", ".", "O_WRONLY", "|", "os", ".", "O_CREATE", "|", "os", ".", "O_TRUNC", ",", "0640", ...
// Write writes current records to file.
[ "Write", "writes", "current", "records", "to", "file", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd-benchmark/benchmark/report.go#L56-L71
test
lxc/lxd
lxd-benchmark/benchmark/report.go
AddRecord
func (r *CSVReport) AddRecord(label string, elapsed time.Duration) error { if len(r.records) == 0 { r.addRecord(csvFields) } record := []string{ fmt.Sprintf("%d", time.Now().UnixNano()/int64(time.Millisecond)), // timestamp fmt.Sprintf("%d", elapsed/time.Millisecond), label, "", // responseCode is not...
go
func (r *CSVReport) AddRecord(label string, elapsed time.Duration) error { if len(r.records) == 0 { r.addRecord(csvFields) } record := []string{ fmt.Sprintf("%d", time.Now().UnixNano()/int64(time.Millisecond)), // timestamp fmt.Sprintf("%d", elapsed/time.Millisecond), label, "", // responseCode is not...
[ "func", "(", "r", "*", "CSVReport", ")", "AddRecord", "(", "label", "string", ",", "elapsed", "time", ".", "Duration", ")", "error", "{", "if", "len", "(", "r", ".", "records", ")", "==", "0", "{", "r", ".", "addRecord", "(", "csvFields", ")", "\n"...
// AddRecord adds a record to the report.
[ "AddRecord", "adds", "a", "record", "to", "the", "report", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd-benchmark/benchmark/report.go#L74-L87
test
lxc/lxd
lxc/config/file.go
LoadConfig
func LoadConfig(path string) (*Config, error) { // Open the config file content, err := ioutil.ReadFile(path) if err != nil { return nil, fmt.Errorf("Unable to read the configuration file: %v", err) } // Decode the yaml document c := NewConfig(filepath.Dir(path), false) err = yaml.Unmarshal(content, &c) if e...
go
func LoadConfig(path string) (*Config, error) { // Open the config file content, err := ioutil.ReadFile(path) if err != nil { return nil, fmt.Errorf("Unable to read the configuration file: %v", err) } // Decode the yaml document c := NewConfig(filepath.Dir(path), false) err = yaml.Unmarshal(content, &c) if e...
[ "func", "LoadConfig", "(", "path", "string", ")", "(", "*", "Config", ",", "error", ")", "{", "content", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf",...
// LoadConfig reads the configuration from the config path; if the path does // not exist, it returns a default configuration.
[ "LoadConfig", "reads", "the", "configuration", "from", "the", "config", "path", ";", "if", "the", "path", "does", "not", "exist", "it", "returns", "a", "default", "configuration", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxc/config/file.go#L16-L60
test
lxc/lxd
lxc/config/file.go
SaveConfig
func (c *Config) SaveConfig(path string) error { // Create a new copy for the config file conf := Config{} err := shared.DeepCopy(c, &conf) if err != nil { return fmt.Errorf("Unable to copy the configuration: %v", err) } // Remove the static remotes for k := range StaticRemotes { if k == "local" { contin...
go
func (c *Config) SaveConfig(path string) error { // Create a new copy for the config file conf := Config{} err := shared.DeepCopy(c, &conf) if err != nil { return fmt.Errorf("Unable to copy the configuration: %v", err) } // Remove the static remotes for k := range StaticRemotes { if k == "local" { contin...
[ "func", "(", "c", "*", "Config", ")", "SaveConfig", "(", "path", "string", ")", "error", "{", "conf", ":=", "Config", "{", "}", "\n", "err", ":=", "shared", ".", "DeepCopy", "(", "c", ",", "&", "conf", ")", "\n", "if", "err", "!=", "nil", "{", ...
// SaveConfig writes the provided configuration to the config file.
[ "SaveConfig", "writes", "the", "provided", "configuration", "to", "the", "config", "file", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxc/config/file.go#L63-L99
test
lxc/lxd
lxd/template/chroot.go
Get
func (l ChrootLoader) Get(path string) (io.Reader, error) { // Get the full path path, err := filepath.EvalSymlinks(path) if err != nil { return nil, err } basePath, err := filepath.EvalSymlinks(l.Path) if err != nil { return nil, err } // Validate that we're under the expected prefix if !strings.HasPref...
go
func (l ChrootLoader) Get(path string) (io.Reader, error) { // Get the full path path, err := filepath.EvalSymlinks(path) if err != nil { return nil, err } basePath, err := filepath.EvalSymlinks(l.Path) if err != nil { return nil, err } // Validate that we're under the expected prefix if !strings.HasPref...
[ "func", "(", "l", "ChrootLoader", ")", "Get", "(", "path", "string", ")", "(", "io", ".", "Reader", ",", "error", ")", "{", "path", ",", "err", ":=", "filepath", ".", "EvalSymlinks", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", ...
// Get reads the path's content from your local filesystem.
[ "Get", "reads", "the", "path", "s", "content", "from", "your", "local", "filesystem", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/template/chroot.go#L27-L51
test
lxc/lxd
lxc/config/config.go
ConfigPath
func (c *Config) ConfigPath(paths ...string) string { path := []string{c.ConfigDir} path = append(path, paths...) return filepath.Join(path...) }
go
func (c *Config) ConfigPath(paths ...string) string { path := []string{c.ConfigDir} path = append(path, paths...) return filepath.Join(path...) }
[ "func", "(", "c", "*", "Config", ")", "ConfigPath", "(", "paths", "...", "string", ")", "string", "{", "path", ":=", "[", "]", "string", "{", "c", ".", "ConfigDir", "}", "\n", "path", "=", "append", "(", "path", ",", "paths", "...", ")", "\n", "r...
// ConfigPath returns a joined path of the configuration directory and passed arguments
[ "ConfigPath", "returns", "a", "joined", "path", "of", "the", "configuration", "directory", "and", "passed", "arguments" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxc/config/config.go#L40-L45
test
lxc/lxd
lxc/config/config.go
ServerCertPath
func (c *Config) ServerCertPath(remote string) string { return c.ConfigPath("servercerts", fmt.Sprintf("%s.crt", remote)) }
go
func (c *Config) ServerCertPath(remote string) string { return c.ConfigPath("servercerts", fmt.Sprintf("%s.crt", remote)) }
[ "func", "(", "c", "*", "Config", ")", "ServerCertPath", "(", "remote", "string", ")", "string", "{", "return", "c", ".", "ConfigPath", "(", "\"servercerts\"", ",", "fmt", ".", "Sprintf", "(", "\"%s.crt\"", ",", "remote", ")", ")", "\n", "}" ]
// ServerCertPath returns the path for the remote's server certificate
[ "ServerCertPath", "returns", "the", "path", "for", "the", "remote", "s", "server", "certificate" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxc/config/config.go#L53-L55
test
lxc/lxd
lxc/config/config.go
NewConfig
func NewConfig(configDir string, defaults bool) *Config { config := &Config{ConfigDir: configDir} if defaults { config.Remotes = DefaultRemotes config.DefaultRemote = "local" } return config }
go
func NewConfig(configDir string, defaults bool) *Config { config := &Config{ConfigDir: configDir} if defaults { config.Remotes = DefaultRemotes config.DefaultRemote = "local" } return config }
[ "func", "NewConfig", "(", "configDir", "string", ",", "defaults", "bool", ")", "*", "Config", "{", "config", ":=", "&", "Config", "{", "ConfigDir", ":", "configDir", "}", "\n", "if", "defaults", "{", "config", ".", "Remotes", "=", "DefaultRemotes", "\n", ...
// NewConfig returns a Config, optionally using default remotes.
[ "NewConfig", "returns", "a", "Config", "optionally", "using", "default", "remotes", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxc/config/config.go#L65-L73
test
lxc/lxd
lxd/migrate_container.go
checkForPreDumpSupport
func (s *migrationSourceWs) checkForPreDumpSupport() (bool, int) { // Ask CRIU if this architecture/kernel/criu combination // supports pre-copy (dirty memory tracking) criuMigrationArgs := CriuMigrationArgs{ cmd: lxc.MIGRATE_FEATURE_CHECK, stateDir: "", function: "feature-check", stop: ...
go
func (s *migrationSourceWs) checkForPreDumpSupport() (bool, int) { // Ask CRIU if this architecture/kernel/criu combination // supports pre-copy (dirty memory tracking) criuMigrationArgs := CriuMigrationArgs{ cmd: lxc.MIGRATE_FEATURE_CHECK, stateDir: "", function: "feature-check", stop: ...
[ "func", "(", "s", "*", "migrationSourceWs", ")", "checkForPreDumpSupport", "(", ")", "(", "bool", ",", "int", ")", "{", "criuMigrationArgs", ":=", "CriuMigrationArgs", "{", "cmd", ":", "lxc", ".", "MIGRATE_FEATURE_CHECK", ",", "stateDir", ":", "\"\"", ",", "...
// Check if CRIU supports pre-dumping and number of // pre-dump iterations
[ "Check", "if", "CRIU", "supports", "pre", "-", "dumping", "and", "number", "of", "pre", "-", "dump", "iterations" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/migrate_container.go#L123-L177
test
lxc/lxd
lxd/migrate_container.go
preDumpLoop
func (s *migrationSourceWs) preDumpLoop(args *preDumpLoopArgs) (bool, error) { // Do a CRIU pre-dump criuMigrationArgs := CriuMigrationArgs{ cmd: lxc.MIGRATE_PRE_DUMP, stop: false, actionScript: false, preDumpDir: args.preDumpDir, dumpDir: args.dumpDir, stateDir: args.checkpoin...
go
func (s *migrationSourceWs) preDumpLoop(args *preDumpLoopArgs) (bool, error) { // Do a CRIU pre-dump criuMigrationArgs := CriuMigrationArgs{ cmd: lxc.MIGRATE_PRE_DUMP, stop: false, actionScript: false, preDumpDir: args.preDumpDir, dumpDir: args.dumpDir, stateDir: args.checkpoin...
[ "func", "(", "s", "*", "migrationSourceWs", ")", "preDumpLoop", "(", "args", "*", "preDumpLoopArgs", ")", "(", "bool", ",", "error", ")", "{", "criuMigrationArgs", ":=", "CriuMigrationArgs", "{", "cmd", ":", "lxc", ".", "MIGRATE_PRE_DUMP", ",", "stop", ":", ...
// The function preDumpLoop is the main logic behind the pre-copy migration. // This function contains the actual pre-dump, the corresponding rsync // transfer and it tells the outer loop to abort if the threshold // of memory pages transferred by pre-dumping has been reached.
[ "The", "function", "preDumpLoop", "is", "the", "main", "logic", "behind", "the", "pre", "-", "copy", "migration", ".", "This", "function", "contains", "the", "actual", "pre", "-", "dump", "the", "corresponding", "rsync", "transfer", "and", "it", "tells", "th...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/migrate_container.go#L230-L315
test
lxc/lxd
shared/generate/root.go
newRoot
func newRoot() *cobra.Command { cmd := &cobra.Command{ Use: "lxd-generate", Short: "Code generation tool for LXD development", Long: `This is the entry point for all "go:generate" directives used in LXD's source code.`, RunE: func(cmd *cobra.Command, args []string) error { return fmt.Errorf("Not implement...
go
func newRoot() *cobra.Command { cmd := &cobra.Command{ Use: "lxd-generate", Short: "Code generation tool for LXD development", Long: `This is the entry point for all "go:generate" directives used in LXD's source code.`, RunE: func(cmd *cobra.Command, args []string) error { return fmt.Errorf("Not implement...
[ "func", "newRoot", "(", ")", "*", "cobra", ".", "Command", "{", "cmd", ":=", "&", "cobra", ".", "Command", "{", "Use", ":", "\"lxd-generate\"", ",", "Short", ":", "\"Code generation tool for LXD development\"", ",", "Long", ":", "`This is the entry point for all \...
// Return a new root command.
[ "Return", "a", "new", "root", "command", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/root.go#L10-L23
test
lxc/lxd
shared/version/api.go
APIExtensionsCount
func APIExtensionsCount() int { count := len(APIExtensions) // This environment variable is an internal one to force the code // to believe that we an API extensions version greater than we // actually have. It's used by integration tests to exercise the // cluster upgrade process. artificialBump := os.Getenv("L...
go
func APIExtensionsCount() int { count := len(APIExtensions) // This environment variable is an internal one to force the code // to believe that we an API extensions version greater than we // actually have. It's used by integration tests to exercise the // cluster upgrade process. artificialBump := os.Getenv("L...
[ "func", "APIExtensionsCount", "(", ")", "int", "{", "count", ":=", "len", "(", "APIExtensions", ")", "\n", "artificialBump", ":=", "os", ".", "Getenv", "(", "\"LXD_ARTIFICIALLY_BUMP_API_EXTENSIONS\"", ")", "\n", "if", "artificialBump", "!=", "\"\"", "{", "n", ...
// APIExtensionsCount returns the number of available API extensions.
[ "APIExtensionsCount", "returns", "the", "number", "of", "available", "API", "extensions", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/version/api.go#L157-L173
test
lxc/lxd
lxd/db/query/slices.go
SelectURIs
func SelectURIs(stmt *sql.Stmt, f func(a ...interface{}) string, args ...interface{}) ([]string, error) { rows, err := stmt.Query(args...) if err != nil { return nil, errors.Wrapf(err, "Failed to query URIs") } defer rows.Close() columns, err := rows.Columns() if err != nil { return nil, errors.Wrap(err, "Ro...
go
func SelectURIs(stmt *sql.Stmt, f func(a ...interface{}) string, args ...interface{}) ([]string, error) { rows, err := stmt.Query(args...) if err != nil { return nil, errors.Wrapf(err, "Failed to query URIs") } defer rows.Close() columns, err := rows.Columns() if err != nil { return nil, errors.Wrap(err, "Ro...
[ "func", "SelectURIs", "(", "stmt", "*", "sql", ".", "Stmt", ",", "f", "func", "(", "a", "...", "interface", "{", "}", ")", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "[", "]", "string", ",", "error", ")", "{", "rows", ",", "...
// SelectURIs returns a list of LXD API URI strings for the resource yielded by // the given query. // // The f argument must be a function that formats the entity URI using the // columns yielded by the query.
[ "SelectURIs", "returns", "a", "list", "of", "LXD", "API", "URI", "strings", "for", "the", "resource", "yielded", "by", "the", "given", "query", ".", "The", "f", "argument", "must", "be", "a", "function", "that", "formats", "the", "entity", "URI", "using", ...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/query/slices.go#L16-L54
test
lxc/lxd
lxd/db/query/slices.go
SelectStrings
func SelectStrings(tx *sql.Tx, query string, args ...interface{}) ([]string, error) { values := []string{} scan := func(rows *sql.Rows) error { var value string err := rows.Scan(&value) if err != nil { return err } values = append(values, value) return nil } err := scanSingleColumn(tx, query, args, ...
go
func SelectStrings(tx *sql.Tx, query string, args ...interface{}) ([]string, error) { values := []string{} scan := func(rows *sql.Rows) error { var value string err := rows.Scan(&value) if err != nil { return err } values = append(values, value) return nil } err := scanSingleColumn(tx, query, args, ...
[ "func", "SelectStrings", "(", "tx", "*", "sql", ".", "Tx", ",", "query", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "[", "]", "string", ",", "error", ")", "{", "values", ":=", "[", "]", "string", "{", "}", "\n", "scan", ":=", ...
// SelectStrings executes a statement which must yield rows with a single string // column. It returns the list of column values.
[ "SelectStrings", "executes", "a", "statement", "which", "must", "yield", "rows", "with", "a", "single", "string", "column", ".", "It", "returns", "the", "list", "of", "column", "values", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/query/slices.go#L58-L76
test
lxc/lxd
lxd/db/query/slices.go
scanSingleColumn
func scanSingleColumn(tx *sql.Tx, query string, args []interface{}, typeName string, scan scanFunc) error { rows, err := tx.Query(query, args...) if err != nil { return err } defer rows.Close() for rows.Next() { err := scan(rows) if err != nil { return err } } err = rows.Err() if err != nil { ret...
go
func scanSingleColumn(tx *sql.Tx, query string, args []interface{}, typeName string, scan scanFunc) error { rows, err := tx.Query(query, args...) if err != nil { return err } defer rows.Close() for rows.Next() { err := scan(rows) if err != nil { return err } } err = rows.Err() if err != nil { ret...
[ "func", "scanSingleColumn", "(", "tx", "*", "sql", ".", "Tx", ",", "query", "string", ",", "args", "[", "]", "interface", "{", "}", ",", "typeName", "string", ",", "scan", "scanFunc", ")", "error", "{", "rows", ",", "err", ":=", "tx", ".", "Query", ...
// Execute the given query and ensure that it yields rows with a single column // of the given database type. For every row yielded, execute the given // scanner.
[ "Execute", "the", "given", "query", "and", "ensure", "that", "it", "yields", "rows", "with", "a", "single", "column", "of", "the", "given", "database", "type", ".", "For", "every", "row", "yielded", "execute", "the", "given", "scanner", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/query/slices.go#L126-L145
test
lxc/lxd
shared/log15/handler.go
LazyHandler
func LazyHandler(h Handler) Handler { return FuncHandler(func(r *Record) error { // go through the values (odd indices) and reassign // the values of any lazy fn to the result of its execution hadErr := false for i := 1; i < len(r.Ctx); i += 2 { lz, ok := r.Ctx[i].(Lazy) if ok { v, err := evaluateLaz...
go
func LazyHandler(h Handler) Handler { return FuncHandler(func(r *Record) error { // go through the values (odd indices) and reassign // the values of any lazy fn to the result of its execution hadErr := false for i := 1; i < len(r.Ctx); i += 2 { lz, ok := r.Ctx[i].(Lazy) if ok { v, err := evaluateLaz...
[ "func", "LazyHandler", "(", "h", "Handler", ")", "Handler", "{", "return", "FuncHandler", "(", "func", "(", "r", "*", "Record", ")", "error", "{", "hadErr", ":=", "false", "\n", "for", "i", ":=", "1", ";", "i", "<", "len", "(", "r", ".", "Ctx", "...
// LazyHandler writes all values to the wrapped handler after evaluating // any lazy functions in the record's context. It is already wrapped // around StreamHandler and SyslogHandler in this library, you'll only need // it if you write your own Handler.
[ "LazyHandler", "writes", "all", "values", "to", "the", "wrapped", "handler", "after", "evaluating", "any", "lazy", "functions", "in", "the", "record", "s", "context", ".", "It", "is", "already", "wrapped", "around", "StreamHandler", "and", "SyslogHandler", "in",...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/log15/handler.go#L274-L302
test
lxc/lxd
shared/log15/stack/stack.go
Callers
func Callers() Trace { pcs := poolBuf() pcs = pcs[:cap(pcs)] n := runtime.Callers(2, pcs) cs := make([]Call, n) for i, pc := range pcs[:n] { cs[i] = Call(pc) } putPoolBuf(pcs) return cs }
go
func Callers() Trace { pcs := poolBuf() pcs = pcs[:cap(pcs)] n := runtime.Callers(2, pcs) cs := make([]Call, n) for i, pc := range pcs[:n] { cs[i] = Call(pc) } putPoolBuf(pcs) return cs }
[ "func", "Callers", "(", ")", "Trace", "{", "pcs", ":=", "poolBuf", "(", ")", "\n", "pcs", "=", "pcs", "[", ":", "cap", "(", "pcs", ")", "]", "\n", "n", ":=", "runtime", ".", "Callers", "(", "2", ",", "pcs", ")", "\n", "cs", ":=", "make", "(",...
// Callers returns a Trace for the current goroutine with element 0 // identifying the calling function.
[ "Callers", "returns", "a", "Trace", "for", "the", "current", "goroutine", "with", "element", "0", "identifying", "the", "calling", "function", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/log15/stack/stack.go#L117-L127
test
lxc/lxd
shared/log15/stack/stack.go
name
func (pc Call) name() string { pcFix := uintptr(pc) - 1 // work around for go issue #7690 fn := runtime.FuncForPC(pcFix) if fn == nil { return "???" } return fn.Name() }
go
func (pc Call) name() string { pcFix := uintptr(pc) - 1 // work around for go issue #7690 fn := runtime.FuncForPC(pcFix) if fn == nil { return "???" } return fn.Name() }
[ "func", "(", "pc", "Call", ")", "name", "(", ")", "string", "{", "pcFix", ":=", "uintptr", "(", "pc", ")", "-", "1", "\n", "fn", ":=", "runtime", ".", "FuncForPC", "(", "pcFix", ")", "\n", "if", "fn", "==", "nil", "{", "return", "\"???\"", "\n", ...
// name returns the import path qualified name of the function containing the // call.
[ "name", "returns", "the", "import", "path", "qualified", "name", "of", "the", "function", "containing", "the", "call", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/log15/stack/stack.go#L131-L138
test
lxc/lxd
shared/log15/stack/stack.go
TrimBelow
func (pcs Trace) TrimBelow(pc Call) Trace { for len(pcs) > 0 && pcs[0] != pc { pcs = pcs[1:] } return pcs }
go
func (pcs Trace) TrimBelow(pc Call) Trace { for len(pcs) > 0 && pcs[0] != pc { pcs = pcs[1:] } return pcs }
[ "func", "(", "pcs", "Trace", ")", "TrimBelow", "(", "pc", "Call", ")", "Trace", "{", "for", "len", "(", "pcs", ")", ">", "0", "&&", "pcs", "[", "0", "]", "!=", "pc", "{", "pcs", "=", "pcs", "[", "1", ":", "]", "\n", "}", "\n", "return", "pc...
// TrimBelow returns a slice of the Trace with all entries below pc removed.
[ "TrimBelow", "returns", "a", "slice", "of", "the", "Trace", "with", "all", "entries", "below", "pc", "removed", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/log15/stack/stack.go#L168-L173
test
lxc/lxd
shared/log15/stack/stack.go
TrimAbove
func (pcs Trace) TrimAbove(pc Call) Trace { for len(pcs) > 0 && pcs[len(pcs)-1] != pc { pcs = pcs[:len(pcs)-1] } return pcs }
go
func (pcs Trace) TrimAbove(pc Call) Trace { for len(pcs) > 0 && pcs[len(pcs)-1] != pc { pcs = pcs[:len(pcs)-1] } return pcs }
[ "func", "(", "pcs", "Trace", ")", "TrimAbove", "(", "pc", "Call", ")", "Trace", "{", "for", "len", "(", "pcs", ")", ">", "0", "&&", "pcs", "[", "len", "(", "pcs", ")", "-", "1", "]", "!=", "pc", "{", "pcs", "=", "pcs", "[", ":", "len", "(",...
// TrimAbove returns a slice of the Trace with all entries above pc removed.
[ "TrimAbove", "returns", "a", "slice", "of", "the", "Trace", "with", "all", "entries", "above", "pc", "removed", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/log15/stack/stack.go#L176-L181
test
lxc/lxd
shared/log15/stack/stack.go
TrimBelowName
func (pcs Trace) TrimBelowName(name string) Trace { for len(pcs) > 0 && pcs[0].name() != name { pcs = pcs[1:] } return pcs }
go
func (pcs Trace) TrimBelowName(name string) Trace { for len(pcs) > 0 && pcs[0].name() != name { pcs = pcs[1:] } return pcs }
[ "func", "(", "pcs", "Trace", ")", "TrimBelowName", "(", "name", "string", ")", "Trace", "{", "for", "len", "(", "pcs", ")", ">", "0", "&&", "pcs", "[", "0", "]", ".", "name", "(", ")", "!=", "name", "{", "pcs", "=", "pcs", "[", "1", ":", "]",...
// TrimBelowName returns a slice of the Trace with all entries below the // lowest with function name name removed.
[ "TrimBelowName", "returns", "a", "slice", "of", "the", "Trace", "with", "all", "entries", "below", "the", "lowest", "with", "function", "name", "name", "removed", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/log15/stack/stack.go#L185-L190
test
lxc/lxd
shared/log15/stack/stack.go
TrimAboveName
func (pcs Trace) TrimAboveName(name string) Trace { for len(pcs) > 0 && pcs[len(pcs)-1].name() != name { pcs = pcs[:len(pcs)-1] } return pcs }
go
func (pcs Trace) TrimAboveName(name string) Trace { for len(pcs) > 0 && pcs[len(pcs)-1].name() != name { pcs = pcs[:len(pcs)-1] } return pcs }
[ "func", "(", "pcs", "Trace", ")", "TrimAboveName", "(", "name", "string", ")", "Trace", "{", "for", "len", "(", "pcs", ")", ">", "0", "&&", "pcs", "[", "len", "(", "pcs", ")", "-", "1", "]", ".", "name", "(", ")", "!=", "name", "{", "pcs", "=...
// TrimAboveName returns a slice of the Trace with all entries above the // highest with function name name removed.
[ "TrimAboveName", "returns", "a", "slice", "of", "the", "Trace", "with", "all", "entries", "above", "the", "highest", "with", "function", "name", "name", "removed", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/log15/stack/stack.go#L194-L199
test
lxc/lxd
shared/log15/stack/stack.go
TrimRuntime
func (pcs Trace) TrimRuntime() Trace { for len(pcs) > 0 && inGoroot(pcs[len(pcs)-1].file()) { pcs = pcs[:len(pcs)-1] } return pcs }
go
func (pcs Trace) TrimRuntime() Trace { for len(pcs) > 0 && inGoroot(pcs[len(pcs)-1].file()) { pcs = pcs[:len(pcs)-1] } return pcs }
[ "func", "(", "pcs", "Trace", ")", "TrimRuntime", "(", ")", "Trace", "{", "for", "len", "(", "pcs", ")", ">", "0", "&&", "inGoroot", "(", "pcs", "[", "len", "(", "pcs", ")", "-", "1", "]", ".", "file", "(", ")", ")", "{", "pcs", "=", "pcs", ...
// TrimRuntime returns a slice of the Trace with the topmost entries from the // go runtime removed. It considers any calls originating from files under // GOROOT as part of the runtime.
[ "TrimRuntime", "returns", "a", "slice", "of", "the", "Trace", "with", "the", "topmost", "entries", "from", "the", "go", "runtime", "removed", ".", "It", "considers", "any", "calls", "originating", "from", "files", "under", "GOROOT", "as", "part", "of", "the"...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/log15/stack/stack.go#L220-L225
test
lxc/lxd
shared/idmap/shift_linux.go
GetCaps
func GetCaps(path string) ([]byte, error) { xattrs, err := shared.GetAllXattr(path) if err != nil { return nil, err } valueStr, ok := xattrs["security.capability"] if !ok { return nil, nil } return []byte(valueStr), nil }
go
func GetCaps(path string) ([]byte, error) { xattrs, err := shared.GetAllXattr(path) if err != nil { return nil, err } valueStr, ok := xattrs["security.capability"] if !ok { return nil, nil } return []byte(valueStr), nil }
[ "func", "GetCaps", "(", "path", "string", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "xattrs", ",", "err", ":=", "shared", ".", "GetAllXattr", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}",...
// GetCaps extracts the list of capabilities effective on the file
[ "GetCaps", "extracts", "the", "list", "of", "capabilities", "effective", "on", "the", "file" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/idmap/shift_linux.go#L171-L183
test
lxc/lxd
shared/idmap/shift_linux.go
SetCaps
func SetCaps(path string, caps []byte, uid int64) error { cpath := C.CString(path) defer C.free(unsafe.Pointer(cpath)) ccaps := C.CString(string(caps)) defer C.free(unsafe.Pointer(ccaps)) r := C.set_vfs_ns_caps(cpath, ccaps, C.ssize_t(len(caps)), C.uint32_t(uid)) if r != 0 { return fmt.Errorf("Failed to apply...
go
func SetCaps(path string, caps []byte, uid int64) error { cpath := C.CString(path) defer C.free(unsafe.Pointer(cpath)) ccaps := C.CString(string(caps)) defer C.free(unsafe.Pointer(ccaps)) r := C.set_vfs_ns_caps(cpath, ccaps, C.ssize_t(len(caps)), C.uint32_t(uid)) if r != 0 { return fmt.Errorf("Failed to apply...
[ "func", "SetCaps", "(", "path", "string", ",", "caps", "[", "]", "byte", ",", "uid", "int64", ")", "error", "{", "cpath", ":=", "C", ".", "CString", "(", "path", ")", "\n", "defer", "C", ".", "free", "(", "unsafe", ".", "Pointer", "(", "cpath", "...
// SetCaps applies the caps for a particular root uid
[ "SetCaps", "applies", "the", "caps", "for", "a", "particular", "root", "uid" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/idmap/shift_linux.go#L186-L199
test
lxc/lxd
shared/ioprogress/reader.go
Read
func (pt *ProgressReader) Read(p []byte) (int, error) { // Do normal reader tasks n, err := pt.ReadCloser.Read(p) // Do the actual progress tracking if pt.Tracker != nil { pt.Tracker.total += int64(n) pt.Tracker.update(n) } return n, err }
go
func (pt *ProgressReader) Read(p []byte) (int, error) { // Do normal reader tasks n, err := pt.ReadCloser.Read(p) // Do the actual progress tracking if pt.Tracker != nil { pt.Tracker.total += int64(n) pt.Tracker.update(n) } return n, err }
[ "func", "(", "pt", "*", "ProgressReader", ")", "Read", "(", "p", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "n", ",", "err", ":=", "pt", ".", "ReadCloser", ".", "Read", "(", "p", ")", "\n", "if", "pt", ".", "Tracker", "!=", "n...
// Read in ProgressReader is the same as io.Read
[ "Read", "in", "ProgressReader", "is", "the", "same", "as", "io", ".", "Read" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/ioprogress/reader.go#L14-L25
test
lxc/lxd
lxd/storage/quota/projectquota.go
Supported
func Supported(path string) (bool, error) { // Get the backing device devPath, err := devForPath(path) if err != nil { return false, err } // Call quotactl through CGo cDevPath := C.CString(devPath) defer C.free(unsafe.Pointer(cDevPath)) return C.quota_supported(cDevPath) == 0, nil }
go
func Supported(path string) (bool, error) { // Get the backing device devPath, err := devForPath(path) if err != nil { return false, err } // Call quotactl through CGo cDevPath := C.CString(devPath) defer C.free(unsafe.Pointer(cDevPath)) return C.quota_supported(cDevPath) == 0, nil }
[ "func", "Supported", "(", "path", "string", ")", "(", "bool", ",", "error", ")", "{", "devPath", ",", "err", ":=", "devForPath", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n", "cDevPath", ":="...
// Supported check if the given path supports project quotas
[ "Supported", "check", "if", "the", "given", "path", "supports", "project", "quotas" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage/quota/projectquota.go#L193-L205
test
lxc/lxd
lxd/storage/quota/projectquota.go
GetProject
func GetProject(path string) (uint32, error) { // Call ioctl through CGo cPath := C.CString(path) defer C.free(unsafe.Pointer(cPath)) id := C.quota_get_path(cPath) if id < 0 { return 0, fmt.Errorf("Failed to get project from '%s'", path) } return uint32(id), nil }
go
func GetProject(path string) (uint32, error) { // Call ioctl through CGo cPath := C.CString(path) defer C.free(unsafe.Pointer(cPath)) id := C.quota_get_path(cPath) if id < 0 { return 0, fmt.Errorf("Failed to get project from '%s'", path) } return uint32(id), nil }
[ "func", "GetProject", "(", "path", "string", ")", "(", "uint32", ",", "error", ")", "{", "cPath", ":=", "C", ".", "CString", "(", "path", ")", "\n", "defer", "C", ".", "free", "(", "unsafe", ".", "Pointer", "(", "cPath", ")", ")", "\n", "id", ":=...
// GetProject returns the project quota ID for the given path
[ "GetProject", "returns", "the", "project", "quota", "ID", "for", "the", "given", "path" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage/quota/projectquota.go#L208-L219
test
lxc/lxd
lxd/storage/quota/projectquota.go
SetProject
func SetProject(path string, id uint32) error { // Call ioctl through CGo cPath := C.CString(path) defer C.free(unsafe.Pointer(cPath)) if C.quota_set_path(cPath, C.uint32_t(id)) != 0 { return fmt.Errorf("Failed to set project id '%d' on '%s'", id, path) } return nil }
go
func SetProject(path string, id uint32) error { // Call ioctl through CGo cPath := C.CString(path) defer C.free(unsafe.Pointer(cPath)) if C.quota_set_path(cPath, C.uint32_t(id)) != 0 { return fmt.Errorf("Failed to set project id '%d' on '%s'", id, path) } return nil }
[ "func", "SetProject", "(", "path", "string", ",", "id", "uint32", ")", "error", "{", "cPath", ":=", "C", ".", "CString", "(", "path", ")", "\n", "defer", "C", ".", "free", "(", "unsafe", ".", "Pointer", "(", "cPath", ")", ")", "\n", "if", "C", "....
// SetProject sets the project quota ID for the given path
[ "SetProject", "sets", "the", "project", "quota", "ID", "for", "the", "given", "path" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage/quota/projectquota.go#L222-L232
test
lxc/lxd
lxd/storage/quota/projectquota.go
DeleteProject
func DeleteProject(path string, id uint32) error { // Unset the project from the path err := SetProject(path, 0) if err != nil { return err } // Unset the quota on the project err = SetProjectQuota(path, id, 0) if err != nil { return err } return nil }
go
func DeleteProject(path string, id uint32) error { // Unset the project from the path err := SetProject(path, 0) if err != nil { return err } // Unset the quota on the project err = SetProjectQuota(path, id, 0) if err != nil { return err } return nil }
[ "func", "DeleteProject", "(", "path", "string", ",", "id", "uint32", ")", "error", "{", "err", ":=", "SetProject", "(", "path", ",", "0", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "err", "=", "SetProjectQuota", "(", ...
// DeleteProject unsets the project id from the path and clears the quota for the project id
[ "DeleteProject", "unsets", "the", "project", "id", "from", "the", "path", "and", "clears", "the", "quota", "for", "the", "project", "id" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage/quota/projectquota.go#L235-L249
test
lxc/lxd
lxd/storage/quota/projectquota.go
GetProjectUsage
func GetProjectUsage(path string, id uint32) (int64, error) { // Get the backing device devPath, err := devForPath(path) if err != nil { return -1, err } // Call quotactl through CGo cDevPath := C.CString(devPath) defer C.free(unsafe.Pointer(cDevPath)) size := C.quota_get_usage(cDevPath, C.uint32_t(id)) if...
go
func GetProjectUsage(path string, id uint32) (int64, error) { // Get the backing device devPath, err := devForPath(path) if err != nil { return -1, err } // Call quotactl through CGo cDevPath := C.CString(devPath) defer C.free(unsafe.Pointer(cDevPath)) size := C.quota_get_usage(cDevPath, C.uint32_t(id)) if...
[ "func", "GetProjectUsage", "(", "path", "string", ",", "id", "uint32", ")", "(", "int64", ",", "error", ")", "{", "devPath", ",", "err", ":=", "devForPath", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "-", "1", ",", "err", "\n"...
// GetProjectUsage returns the current consumption
[ "GetProjectUsage", "returns", "the", "current", "consumption" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage/quota/projectquota.go#L252-L269
test
lxc/lxd
lxd/storage/quota/projectquota.go
SetProjectQuota
func SetProjectQuota(path string, id uint32, bytes int64) error { // Get the backing device devPath, err := devForPath(path) if err != nil { return err } // Call quotactl through CGo cDevPath := C.CString(devPath) defer C.free(unsafe.Pointer(cDevPath)) if C.quota_set(cDevPath, C.uint32_t(id), C.int(bytes/10...
go
func SetProjectQuota(path string, id uint32, bytes int64) error { // Get the backing device devPath, err := devForPath(path) if err != nil { return err } // Call quotactl through CGo cDevPath := C.CString(devPath) defer C.free(unsafe.Pointer(cDevPath)) if C.quota_set(cDevPath, C.uint32_t(id), C.int(bytes/10...
[ "func", "SetProjectQuota", "(", "path", "string", ",", "id", "uint32", ",", "bytes", "int64", ")", "error", "{", "devPath", ",", "err", ":=", "devForPath", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "cDev...
// SetProjectQuota sets the quota on the project id
[ "SetProjectQuota", "sets", "the", "quota", "on", "the", "project", "id" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage/quota/projectquota.go#L272-L288
test
lxc/lxd
lxd/backup.go
backupLoadByName
func backupLoadByName(s *state.State, project, name string) (*backup, error) { // Get the backup database record args, err := s.Cluster.ContainerGetBackup(project, name) if err != nil { return nil, errors.Wrap(err, "Load backup from database") } // Load the container it belongs to c, err := containerLoadById(s...
go
func backupLoadByName(s *state.State, project, name string) (*backup, error) { // Get the backup database record args, err := s.Cluster.ContainerGetBackup(project, name) if err != nil { return nil, errors.Wrap(err, "Load backup from database") } // Load the container it belongs to c, err := containerLoadById(s...
[ "func", "backupLoadByName", "(", "s", "*", "state", ".", "State", ",", "project", ",", "name", "string", ")", "(", "*", "backup", ",", "error", ")", "{", "args", ",", "err", ":=", "s", ".", "Cluster", ".", "ContainerGetBackup", "(", "project", ",", "...
// Load a backup from the database
[ "Load", "a", "backup", "from", "the", "database" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/backup.go#L28-L52
test
lxc/lxd
lxd/backup.go
backupCreate
func backupCreate(s *state.State, args db.ContainerBackupArgs, sourceContainer container) error { // Create the database entry err := s.Cluster.ContainerBackupCreate(args) if err != nil { if err == db.ErrAlreadyDefined { return fmt.Errorf("backup '%s' already exists", args.Name) } return errors.Wrap(err, "...
go
func backupCreate(s *state.State, args db.ContainerBackupArgs, sourceContainer container) error { // Create the database entry err := s.Cluster.ContainerBackupCreate(args) if err != nil { if err == db.ErrAlreadyDefined { return fmt.Errorf("backup '%s' already exists", args.Name) } return errors.Wrap(err, "...
[ "func", "backupCreate", "(", "s", "*", "state", ".", "State", ",", "args", "db", ".", "ContainerBackupArgs", ",", "sourceContainer", "container", ")", "error", "{", "err", ":=", "s", ".", "Cluster", ".", "ContainerBackupCreate", "(", "args", ")", "\n", "if...
// Create a new backup
[ "Create", "a", "new", "backup" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/backup.go#L55-L80
test