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/cluster/connect.go
ConnectIfVolumeIsRemote
func ConnectIfVolumeIsRemote(cluster *db.Cluster, poolID int64, volumeName string, volumeType int, cert *shared.CertInfo) (lxd.ContainerServer, error) { var addresses []string // Node addresses err := cluster.Transaction(func(tx *db.ClusterTx) error { var err error addresses, err = tx.StorageVolumeNodeAddresses(p...
go
func ConnectIfVolumeIsRemote(cluster *db.Cluster, poolID int64, volumeName string, volumeType int, cert *shared.CertInfo) (lxd.ContainerServer, error) { var addresses []string // Node addresses err := cluster.Transaction(func(tx *db.ClusterTx) error { var err error addresses, err = tx.StorageVolumeNodeAddresses(p...
[ "func", "ConnectIfVolumeIsRemote", "(", "cluster", "*", "db", ".", "Cluster", ",", "poolID", "int64", ",", "volumeName", "string", ",", "volumeType", "int", ",", "cert", "*", "shared", ".", "CertInfo", ")", "(", "lxd", ".", "ContainerServer", ",", "error", ...
// ConnectIfVolumeIsRemote figures out the address of the node on which the // volume with the given name is defined. If it's not the local node will // connect to it and return the connected client, otherwise it will just return // nil. // // If there is more than one node with a matching volume name, an error is // r...
[ "ConnectIfVolumeIsRemote", "figures", "out", "the", "address", "of", "the", "node", "on", "which", "the", "volume", "with", "the", "given", "name", "is", "defined", ".", "If", "it", "s", "not", "the", "local", "node", "will", "connect", "to", "it", "and", ...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/connect.go#L64-L99
test
lxc/lxd
lxd/cluster/connect.go
SetupTrust
func SetupTrust(cert, targetAddress, targetCert, targetPassword string) error { // Connect to the target cluster node. args := &lxd.ConnectionArgs{ TLSServerCert: targetCert, } target, err := lxd.ConnectLXD(fmt.Sprintf("https://%s", targetAddress), args) if err != nil { return errors.Wrap(err, "failed to conne...
go
func SetupTrust(cert, targetAddress, targetCert, targetPassword string) error { // Connect to the target cluster node. args := &lxd.ConnectionArgs{ TLSServerCert: targetCert, } target, err := lxd.ConnectLXD(fmt.Sprintf("https://%s", targetAddress), args) if err != nil { return errors.Wrap(err, "failed to conne...
[ "func", "SetupTrust", "(", "cert", ",", "targetAddress", ",", "targetCert", ",", "targetPassword", "string", ")", "error", "{", "args", ":=", "&", "lxd", ".", "ConnectionArgs", "{", "TLSServerCert", ":", "targetCert", ",", "}", "\n", "target", ",", "err", ...
// SetupTrust is a convenience around ContainerServer.CreateCertificate that // adds the given client certificate to the trusted pool of the cluster at the // given address, using the given password.
[ "SetupTrust", "is", "a", "convenience", "around", "ContainerServer", ".", "CreateCertificate", "that", "adds", "the", "given", "client", "certificate", "to", "the", "trusted", "pool", "of", "the", "cluster", "at", "the", "given", "address", "using", "the", "give...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/connect.go#L104-L133
test
lxc/lxd
client/lxd_storage_pools.go
GetStoragePools
func (r *ProtocolLXD) GetStoragePools() ([]api.StoragePool, error) { if !r.HasExtension("storage") { return nil, fmt.Errorf("The server is missing the required \"storage\" API extension") } pools := []api.StoragePool{} // Fetch the raw value _, err := r.queryStruct("GET", "/storage-pools?recursion=1", nil, "",...
go
func (r *ProtocolLXD) GetStoragePools() ([]api.StoragePool, error) { if !r.HasExtension("storage") { return nil, fmt.Errorf("The server is missing the required \"storage\" API extension") } pools := []api.StoragePool{} // Fetch the raw value _, err := r.queryStruct("GET", "/storage-pools?recursion=1", nil, "",...
[ "func", "(", "r", "*", "ProtocolLXD", ")", "GetStoragePools", "(", ")", "(", "[", "]", "api", ".", "StoragePool", ",", "error", ")", "{", "if", "!", "r", ".", "HasExtension", "(", "\"storage\"", ")", "{", "return", "nil", ",", "fmt", ".", "Errorf", ...
// GetStoragePools returns a list of StoragePool entries
[ "GetStoragePools", "returns", "a", "list", "of", "StoragePool", "entries" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_storage_pools.go#L38-L52
test
lxc/lxd
client/lxd_storage_pools.go
GetStoragePool
func (r *ProtocolLXD) GetStoragePool(name string) (*api.StoragePool, string, error) { if !r.HasExtension("storage") { return nil, "", fmt.Errorf("The server is missing the required \"storage\" API extension") } pool := api.StoragePool{} // Fetch the raw value etag, err := r.queryStruct("GET", fmt.Sprintf("/sto...
go
func (r *ProtocolLXD) GetStoragePool(name string) (*api.StoragePool, string, error) { if !r.HasExtension("storage") { return nil, "", fmt.Errorf("The server is missing the required \"storage\" API extension") } pool := api.StoragePool{} // Fetch the raw value etag, err := r.queryStruct("GET", fmt.Sprintf("/sto...
[ "func", "(", "r", "*", "ProtocolLXD", ")", "GetStoragePool", "(", "name", "string", ")", "(", "*", "api", ".", "StoragePool", ",", "string", ",", "error", ")", "{", "if", "!", "r", ".", "HasExtension", "(", "\"storage\"", ")", "{", "return", "nil", "...
// GetStoragePool returns a StoragePool entry for the provided pool name
[ "GetStoragePool", "returns", "a", "StoragePool", "entry", "for", "the", "provided", "pool", "name" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_storage_pools.go#L55-L69
test
lxc/lxd
client/lxd_storage_pools.go
CreateStoragePool
func (r *ProtocolLXD) CreateStoragePool(pool api.StoragePoolsPost) error { if !r.HasExtension("storage") { return fmt.Errorf("The server is missing the required \"storage\" API extension") } if pool.Driver == "ceph" && !r.HasExtension("storage_driver_ceph") { return fmt.Errorf("The server is missing the require...
go
func (r *ProtocolLXD) CreateStoragePool(pool api.StoragePoolsPost) error { if !r.HasExtension("storage") { return fmt.Errorf("The server is missing the required \"storage\" API extension") } if pool.Driver == "ceph" && !r.HasExtension("storage_driver_ceph") { return fmt.Errorf("The server is missing the require...
[ "func", "(", "r", "*", "ProtocolLXD", ")", "CreateStoragePool", "(", "pool", "api", ".", "StoragePoolsPost", ")", "error", "{", "if", "!", "r", ".", "HasExtension", "(", "\"storage\"", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"The server is missing t...
// CreateStoragePool defines a new storage pool using the provided StoragePool struct
[ "CreateStoragePool", "defines", "a", "new", "storage", "pool", "using", "the", "provided", "StoragePool", "struct" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_storage_pools.go#L72-L88
test
lxc/lxd
client/lxd_storage_pools.go
UpdateStoragePool
func (r *ProtocolLXD) UpdateStoragePool(name string, pool api.StoragePoolPut, ETag string) error { if !r.HasExtension("storage") { return fmt.Errorf("The server is missing the required \"storage\" API extension") } // Send the request _, _, err := r.query("PUT", fmt.Sprintf("/storage-pools/%s", url.QueryEscape(n...
go
func (r *ProtocolLXD) UpdateStoragePool(name string, pool api.StoragePoolPut, ETag string) error { if !r.HasExtension("storage") { return fmt.Errorf("The server is missing the required \"storage\" API extension") } // Send the request _, _, err := r.query("PUT", fmt.Sprintf("/storage-pools/%s", url.QueryEscape(n...
[ "func", "(", "r", "*", "ProtocolLXD", ")", "UpdateStoragePool", "(", "name", "string", ",", "pool", "api", ".", "StoragePoolPut", ",", "ETag", "string", ")", "error", "{", "if", "!", "r", ".", "HasExtension", "(", "\"storage\"", ")", "{", "return", "fmt"...
// UpdateStoragePool updates the pool to match the provided StoragePool struct
[ "UpdateStoragePool", "updates", "the", "pool", "to", "match", "the", "provided", "StoragePool", "struct" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_storage_pools.go#L91-L103
test
lxc/lxd
client/lxd_storage_pools.go
DeleteStoragePool
func (r *ProtocolLXD) DeleteStoragePool(name string) error { if !r.HasExtension("storage") { return fmt.Errorf("The server is missing the required \"storage\" API extension") } // Send the request _, _, err := r.query("DELETE", fmt.Sprintf("/storage-pools/%s", url.QueryEscape(name)), nil, "") if err != nil { ...
go
func (r *ProtocolLXD) DeleteStoragePool(name string) error { if !r.HasExtension("storage") { return fmt.Errorf("The server is missing the required \"storage\" API extension") } // Send the request _, _, err := r.query("DELETE", fmt.Sprintf("/storage-pools/%s", url.QueryEscape(name)), nil, "") if err != nil { ...
[ "func", "(", "r", "*", "ProtocolLXD", ")", "DeleteStoragePool", "(", "name", "string", ")", "error", "{", "if", "!", "r", ".", "HasExtension", "(", "\"storage\"", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"The server is missing the required \\\"storage\\\...
// DeleteStoragePool deletes a storage pool
[ "DeleteStoragePool", "deletes", "a", "storage", "pool" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_storage_pools.go#L106-L118
test
lxc/lxd
client/lxd_storage_pools.go
GetStoragePoolResources
func (r *ProtocolLXD) GetStoragePoolResources(name string) (*api.ResourcesStoragePool, error) { if !r.HasExtension("resources") { return nil, fmt.Errorf("The server is missing the required \"resources\" API extension") } res := api.ResourcesStoragePool{} // Fetch the raw value _, err := r.queryStruct("GET", fm...
go
func (r *ProtocolLXD) GetStoragePoolResources(name string) (*api.ResourcesStoragePool, error) { if !r.HasExtension("resources") { return nil, fmt.Errorf("The server is missing the required \"resources\" API extension") } res := api.ResourcesStoragePool{} // Fetch the raw value _, err := r.queryStruct("GET", fm...
[ "func", "(", "r", "*", "ProtocolLXD", ")", "GetStoragePoolResources", "(", "name", "string", ")", "(", "*", "api", ".", "ResourcesStoragePool", ",", "error", ")", "{", "if", "!", "r", ".", "HasExtension", "(", "\"resources\"", ")", "{", "return", "nil", ...
// GetStoragePoolResources gets the resources available to a given storage pool
[ "GetStoragePoolResources", "gets", "the", "resources", "available", "to", "a", "given", "storage", "pool" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_storage_pools.go#L121-L135
test
lxc/lxd
lxd/sys/fs.go
initDirs
func (s *OS) initDirs() error { dirs := []struct { path string mode os.FileMode }{ {s.VarDir, 0711}, {filepath.Join(s.VarDir, "backups"), 0700}, {s.CacheDir, 0700}, {filepath.Join(s.VarDir, "containers"), 0711}, {filepath.Join(s.VarDir, "database"), 0700}, {filepath.Join(s.VarDir, "devices"), 0711}, ...
go
func (s *OS) initDirs() error { dirs := []struct { path string mode os.FileMode }{ {s.VarDir, 0711}, {filepath.Join(s.VarDir, "backups"), 0700}, {s.CacheDir, 0700}, {filepath.Join(s.VarDir, "containers"), 0711}, {filepath.Join(s.VarDir, "database"), 0700}, {filepath.Join(s.VarDir, "devices"), 0711}, ...
[ "func", "(", "s", "*", "OS", ")", "initDirs", "(", ")", "error", "{", "dirs", ":=", "[", "]", "struct", "{", "path", "string", "\n", "mode", "os", ".", "FileMode", "\n", "}", "{", "{", "s", ".", "VarDir", ",", "0711", "}", ",", "{", "filepath",...
// Make sure all our directories are available.
[ "Make", "sure", "all", "our", "directories", "are", "available", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/sys/fs.go#L37-L67
test
lxc/lxd
lxd/db/config.go
Config
func (n *NodeTx) Config() (map[string]string, error) { return query.SelectConfig(n.tx, "config", "") }
go
func (n *NodeTx) Config() (map[string]string, error) { return query.SelectConfig(n.tx, "config", "") }
[ "func", "(", "n", "*", "NodeTx", ")", "Config", "(", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "return", "query", ".", "SelectConfig", "(", "n", ".", "tx", ",", "\"config\"", ",", "\"\"", ")", "\n", "}" ]
// Config fetches all LXD node-level config keys.
[ "Config", "fetches", "all", "LXD", "node", "-", "level", "config", "keys", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/config.go#L6-L8
test
lxc/lxd
lxd/db/config.go
UpdateConfig
func (n *NodeTx) UpdateConfig(values map[string]string) error { return query.UpdateConfig(n.tx, "config", values) }
go
func (n *NodeTx) UpdateConfig(values map[string]string) error { return query.UpdateConfig(n.tx, "config", values) }
[ "func", "(", "n", "*", "NodeTx", ")", "UpdateConfig", "(", "values", "map", "[", "string", "]", "string", ")", "error", "{", "return", "query", ".", "UpdateConfig", "(", "n", ".", "tx", ",", "\"config\"", ",", "values", ")", "\n", "}" ]
// UpdateConfig updates the given LXD node-level configuration keys in the // config table. Config keys set to empty values will be deleted.
[ "UpdateConfig", "updates", "the", "given", "LXD", "node", "-", "level", "configuration", "keys", "in", "the", "config", "table", ".", "Config", "keys", "set", "to", "empty", "values", "will", "be", "deleted", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/config.go#L12-L14
test
lxc/lxd
lxd/db/config.go
Config
func (c *ClusterTx) Config() (map[string]string, error) { return query.SelectConfig(c.tx, "config", "") }
go
func (c *ClusterTx) Config() (map[string]string, error) { return query.SelectConfig(c.tx, "config", "") }
[ "func", "(", "c", "*", "ClusterTx", ")", "Config", "(", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "return", "query", ".", "SelectConfig", "(", "c", ".", "tx", ",", "\"config\"", ",", "\"\"", ")", "\n", "}" ]
// Config fetches all LXD cluster config keys.
[ "Config", "fetches", "all", "LXD", "cluster", "config", "keys", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/config.go#L17-L19
test
lxc/lxd
lxd/db/config.go
UpdateConfig
func (c *ClusterTx) UpdateConfig(values map[string]string) error { return query.UpdateConfig(c.tx, "config", values) }
go
func (c *ClusterTx) UpdateConfig(values map[string]string) error { return query.UpdateConfig(c.tx, "config", values) }
[ "func", "(", "c", "*", "ClusterTx", ")", "UpdateConfig", "(", "values", "map", "[", "string", "]", "string", ")", "error", "{", "return", "query", ".", "UpdateConfig", "(", "c", ".", "tx", ",", "\"config\"", ",", "values", ")", "\n", "}" ]
// UpdateConfig updates the given LXD cluster configuration keys in the // config table. Config keys set to empty values will be deleted.
[ "UpdateConfig", "updates", "the", "given", "LXD", "cluster", "configuration", "keys", "in", "the", "config", "table", ".", "Config", "keys", "set", "to", "empty", "values", "will", "be", "deleted", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/config.go#L23-L25
test
lxc/lxd
lxd/storage_pools.go
storagePoolClusterConfigForEtag
func storagePoolClusterConfigForEtag(dbConfig map[string]string) map[string]string { config := util.CopyConfig(dbConfig) for _, key := range db.StoragePoolNodeConfigKeys { delete(config, key) } return config }
go
func storagePoolClusterConfigForEtag(dbConfig map[string]string) map[string]string { config := util.CopyConfig(dbConfig) for _, key := range db.StoragePoolNodeConfigKeys { delete(config, key) } return config }
[ "func", "storagePoolClusterConfigForEtag", "(", "dbConfig", "map", "[", "string", "]", "string", ")", "map", "[", "string", "]", "string", "{", "config", ":=", "util", ".", "CopyConfig", "(", "dbConfig", ")", "\n", "for", "_", ",", "key", ":=", "range", ...
// This helper deletes any node-specific values from the config object, since // they should not be part of the calculated etag.
[ "This", "helper", "deletes", "any", "node", "-", "specific", "values", "from", "the", "config", "object", "since", "they", "should", "not", "be", "part", "of", "the", "calculated", "etag", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage_pools.go#L491-L497
test
lxc/lxd
client/lxd_events.go
GetEvents
func (r *ProtocolLXD) GetEvents() (*EventListener, error) { // Prevent anything else from interacting with the listeners r.eventListenersLock.Lock() defer r.eventListenersLock.Unlock() // Setup a new listener listener := EventListener{ r: r, chActive: make(chan bool), } if r.eventListeners != nil { ...
go
func (r *ProtocolLXD) GetEvents() (*EventListener, error) { // Prevent anything else from interacting with the listeners r.eventListenersLock.Lock() defer r.eventListenersLock.Unlock() // Setup a new listener listener := EventListener{ r: r, chActive: make(chan bool), } if r.eventListeners != nil { ...
[ "func", "(", "r", "*", "ProtocolLXD", ")", "GetEvents", "(", ")", "(", "*", "EventListener", ",", "error", ")", "{", "r", ".", "eventListenersLock", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "eventListenersLock", ".", "Unlock", "(", ")", "\n", ...
// Event handling functions // GetEvents connects to the LXD monitoring interface
[ "Event", "handling", "functions", "GetEvents", "connects", "to", "the", "LXD", "monitoring", "interface" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_events.go#L14-L127
test
lxc/lxd
shared/logging/format.go
LogfmtFormat
func LogfmtFormat() log.Format { return log.FormatFunc(func(r *log.Record) []byte { common := []interface{}{r.KeyNames.Time, r.Time, r.KeyNames.Lvl, r.Lvl, r.KeyNames.Msg, r.Msg} buf := &bytes.Buffer{} logfmt(buf, common, 0, false) buf.Truncate(buf.Len() - 1) buf.WriteByte(' ') logfmt(buf, r.Ctx, 0, true)...
go
func LogfmtFormat() log.Format { return log.FormatFunc(func(r *log.Record) []byte { common := []interface{}{r.KeyNames.Time, r.Time, r.KeyNames.Lvl, r.Lvl, r.KeyNames.Msg, r.Msg} buf := &bytes.Buffer{} logfmt(buf, common, 0, false) buf.Truncate(buf.Len() - 1) buf.WriteByte(' ') logfmt(buf, r.Ctx, 0, true)...
[ "func", "LogfmtFormat", "(", ")", "log", ".", "Format", "{", "return", "log", ".", "FormatFunc", "(", "func", "(", "r", "*", "log", ".", "Record", ")", "[", "]", "byte", "{", "common", ":=", "[", "]", "interface", "{", "}", "{", "r", ".", "KeyNam...
// LogfmtFormat return a formatter for a text log file
[ "LogfmtFormat", "return", "a", "formatter", "for", "a", "text", "log", "file" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/logging/format.go#L71-L82
test
lxc/lxd
lxd/db/storage_volumes.go
StorageVolumeNodeAddresses
func (c *ClusterTx) StorageVolumeNodeAddresses(poolID int64, project, name string, typ int) ([]string, error) { nodes := []struct { id int64 address string }{} dest := func(i int) []interface{} { nodes = append(nodes, struct { id int64 address string }{}) return []interface{}{&nodes[i].id, ...
go
func (c *ClusterTx) StorageVolumeNodeAddresses(poolID int64, project, name string, typ int) ([]string, error) { nodes := []struct { id int64 address string }{} dest := func(i int) []interface{} { nodes = append(nodes, struct { id int64 address string }{}) return []interface{}{&nodes[i].id, ...
[ "func", "(", "c", "*", "ClusterTx", ")", "StorageVolumeNodeAddresses", "(", "poolID", "int64", ",", "project", ",", "name", "string", ",", "typ", "int", ")", "(", "[", "]", "string", ",", "error", ")", "{", "nodes", ":=", "[", "]", "struct", "{", "id...
// StorageVolumeNodeAddresses returns the addresses of all nodes on which the // volume with the given name if defined. // // The empty string is used in place of the address of the current node.
[ "StorageVolumeNodeAddresses", "returns", "the", "addresses", "of", "all", "nodes", "on", "which", "the", "volume", "with", "the", "given", "name", "if", "defined", ".", "The", "empty", "string", "is", "used", "in", "place", "of", "the", "address", "of", "the...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_volumes.go#L38-L84
test
lxc/lxd
lxd/db/storage_volumes.go
StorageVolumeNodeGet
func (c *Cluster) StorageVolumeNodeGet(volumeID int64) (string, error) { name := "" query := ` SELECT nodes.name FROM storage_volumes JOIN nodes ON nodes.id=storage_volumes.node_id WHERE storage_volumes.id=? ` inargs := []interface{}{volumeID} outargs := []interface{}{&name} err := dbQueryRowScan(c.db, query...
go
func (c *Cluster) StorageVolumeNodeGet(volumeID int64) (string, error) { name := "" query := ` SELECT nodes.name FROM storage_volumes JOIN nodes ON nodes.id=storage_volumes.node_id WHERE storage_volumes.id=? ` inargs := []interface{}{volumeID} outargs := []interface{}{&name} err := dbQueryRowScan(c.db, query...
[ "func", "(", "c", "*", "Cluster", ")", "StorageVolumeNodeGet", "(", "volumeID", "int64", ")", "(", "string", ",", "error", ")", "{", "name", ":=", "\"\"", "\n", "query", ":=", "`SELECT nodes.name FROM storage_volumes JOIN nodes ON nodes.id=storage_volumes.node_id WHE...
// StorageVolumeNodeGet returns the name of the node a storage volume is on.
[ "StorageVolumeNodeGet", "returns", "the", "name", "of", "the", "node", "a", "storage", "volume", "is", "on", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_volumes.go#L87-L107
test
lxc/lxd
lxd/db/storage_volumes.go
StorageVolumeConfigGet
func (c *Cluster) StorageVolumeConfigGet(volumeID int64) (map[string]string, error) { var key, value string query := "SELECT key, value FROM storage_volumes_config WHERE storage_volume_id=?" inargs := []interface{}{volumeID} outargs := []interface{}{key, value} results, err := queryScan(c.db, query, inargs, outar...
go
func (c *Cluster) StorageVolumeConfigGet(volumeID int64) (map[string]string, error) { var key, value string query := "SELECT key, value FROM storage_volumes_config WHERE storage_volume_id=?" inargs := []interface{}{volumeID} outargs := []interface{}{key, value} results, err := queryScan(c.db, query, inargs, outar...
[ "func", "(", "c", "*", "Cluster", ")", "StorageVolumeConfigGet", "(", "volumeID", "int64", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "var", "key", ",", "value", "string", "\n", "query", ":=", "\"SELECT key, value FROM storage_vol...
// StorageVolumeConfigGet gets the config of a storage volume.
[ "StorageVolumeConfigGet", "gets", "the", "config", "of", "a", "storage", "volume", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_volumes.go#L110-L131
test
lxc/lxd
lxd/db/storage_volumes.go
StorageVolumeDescriptionGet
func (c *Cluster) StorageVolumeDescriptionGet(volumeID int64) (string, error) { description := sql.NullString{} query := "SELECT description FROM storage_volumes WHERE id=?" inargs := []interface{}{volumeID} outargs := []interface{}{&description} err := dbQueryRowScan(c.db, query, inargs, outargs) if err != nil ...
go
func (c *Cluster) StorageVolumeDescriptionGet(volumeID int64) (string, error) { description := sql.NullString{} query := "SELECT description FROM storage_volumes WHERE id=?" inargs := []interface{}{volumeID} outargs := []interface{}{&description} err := dbQueryRowScan(c.db, query, inargs, outargs) if err != nil ...
[ "func", "(", "c", "*", "Cluster", ")", "StorageVolumeDescriptionGet", "(", "volumeID", "int64", ")", "(", "string", ",", "error", ")", "{", "description", ":=", "sql", ".", "NullString", "{", "}", "\n", "query", ":=", "\"SELECT description FROM storage_volumes W...
// StorageVolumeDescriptionGet gets the description of a storage volume.
[ "StorageVolumeDescriptionGet", "gets", "the", "description", "of", "a", "storage", "volume", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_volumes.go#L134-L149
test
lxc/lxd
lxd/db/storage_volumes.go
StorageVolumeIsAvailable
func (c *Cluster) StorageVolumeIsAvailable(pool, volume string) (bool, error) { isAvailable := false err := c.Transaction(func(tx *ClusterTx) error { id, err := tx.StoragePoolID(pool) if err != nil { return errors.Wrapf(err, "Fetch storage pool ID for %q", pool) } driver, err := tx.StoragePoolDriver(id) ...
go
func (c *Cluster) StorageVolumeIsAvailable(pool, volume string) (bool, error) { isAvailable := false err := c.Transaction(func(tx *ClusterTx) error { id, err := tx.StoragePoolID(pool) if err != nil { return errors.Wrapf(err, "Fetch storage pool ID for %q", pool) } driver, err := tx.StoragePoolDriver(id) ...
[ "func", "(", "c", "*", "Cluster", ")", "StorageVolumeIsAvailable", "(", "pool", ",", "volume", "string", ")", "(", "bool", ",", "error", ")", "{", "isAvailable", ":=", "false", "\n", "err", ":=", "c", ".", "Transaction", "(", "func", "(", "tx", "*", ...
// StorageVolumeIsAvailable checks that if a custom volume available for being attached. // // Always return true for non-Ceph volumes. // // For Ceph volumes, return true if the volume is either not attached to any // other container, or attached to containers on this node.
[ "StorageVolumeIsAvailable", "checks", "that", "if", "a", "custom", "volume", "available", "for", "being", "attached", ".", "Always", "return", "true", "for", "non", "-", "Ceph", "volumes", ".", "For", "Ceph", "volumes", "return", "true", "if", "the", "volume",...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_volumes.go#L194-L250
test
lxc/lxd
lxd/db/storage_volumes.go
StorageVolumeDescriptionUpdate
func StorageVolumeDescriptionUpdate(tx *sql.Tx, volumeID int64, description string) error { _, err := tx.Exec("UPDATE storage_volumes SET description=? WHERE id=?", description, volumeID) return err }
go
func StorageVolumeDescriptionUpdate(tx *sql.Tx, volumeID int64, description string) error { _, err := tx.Exec("UPDATE storage_volumes SET description=? WHERE id=?", description, volumeID) return err }
[ "func", "StorageVolumeDescriptionUpdate", "(", "tx", "*", "sql", ".", "Tx", ",", "volumeID", "int64", ",", "description", "string", ")", "error", "{", "_", ",", "err", ":=", "tx", ".", "Exec", "(", "\"UPDATE storage_volumes SET description=? WHERE id=?\"", ",", ...
// StorageVolumeDescriptionUpdate updates the description of a storage volume.
[ "StorageVolumeDescriptionUpdate", "updates", "the", "description", "of", "a", "storage", "volume", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_volumes.go#L253-L256
test
lxc/lxd
lxd/db/storage_volumes.go
StorageVolumeConfigAdd
func StorageVolumeConfigAdd(tx *sql.Tx, volumeID int64, volumeConfig map[string]string) error { str := "INSERT INTO storage_volumes_config (storage_volume_id, key, value) VALUES(?, ?, ?)" stmt, err := tx.Prepare(str) defer stmt.Close() if err != nil { return err } for k, v := range volumeConfig { if v == "" ...
go
func StorageVolumeConfigAdd(tx *sql.Tx, volumeID int64, volumeConfig map[string]string) error { str := "INSERT INTO storage_volumes_config (storage_volume_id, key, value) VALUES(?, ?, ?)" stmt, err := tx.Prepare(str) defer stmt.Close() if err != nil { return err } for k, v := range volumeConfig { if v == "" ...
[ "func", "StorageVolumeConfigAdd", "(", "tx", "*", "sql", ".", "Tx", ",", "volumeID", "int64", ",", "volumeConfig", "map", "[", "string", "]", "string", ")", "error", "{", "str", ":=", "\"INSERT INTO storage_volumes_config (storage_volume_id, key, value) VALUES(?, ?, ?)\...
// StorageVolumeConfigAdd adds a new storage volume config into database.
[ "StorageVolumeConfigAdd", "adds", "a", "new", "storage", "volume", "config", "into", "database", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_volumes.go#L259-L279
test
lxc/lxd
lxd/db/storage_volumes.go
StorageVolumeConfigClear
func StorageVolumeConfigClear(tx *sql.Tx, volumeID int64) error { _, err := tx.Exec("DELETE FROM storage_volumes_config WHERE storage_volume_id=?", volumeID) if err != nil { return err } return nil }
go
func StorageVolumeConfigClear(tx *sql.Tx, volumeID int64) error { _, err := tx.Exec("DELETE FROM storage_volumes_config WHERE storage_volume_id=?", volumeID) if err != nil { return err } return nil }
[ "func", "StorageVolumeConfigClear", "(", "tx", "*", "sql", ".", "Tx", ",", "volumeID", "int64", ")", "error", "{", "_", ",", "err", ":=", "tx", ".", "Exec", "(", "\"DELETE FROM storage_volumes_config WHERE storage_volume_id=?\"", ",", "volumeID", ")", "\n", "if"...
// StorageVolumeConfigClear deletes storage volume config.
[ "StorageVolumeConfigClear", "deletes", "storage", "volume", "config", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_volumes.go#L282-L289
test
lxc/lxd
lxd/db/storage_volumes.go
storageVolumeIDsGet
func storageVolumeIDsGet(tx *sql.Tx, project, volumeName string, volumeType int, poolID int64) ([]int64, error) { ids, err := query.SelectIntegers(tx, ` SELECT storage_volumes.id FROM storage_volumes JOIN projects ON projects.id = storage_volumes.project_id WHERE projects.name=? AND storage_volumes.name=? AND sto...
go
func storageVolumeIDsGet(tx *sql.Tx, project, volumeName string, volumeType int, poolID int64) ([]int64, error) { ids, err := query.SelectIntegers(tx, ` SELECT storage_volumes.id FROM storage_volumes JOIN projects ON projects.id = storage_volumes.project_id WHERE projects.name=? AND storage_volumes.name=? AND sto...
[ "func", "storageVolumeIDsGet", "(", "tx", "*", "sql", ".", "Tx", ",", "project", ",", "volumeName", "string", ",", "volumeType", "int", ",", "poolID", "int64", ")", "(", "[", "]", "int64", ",", "error", ")", "{", "ids", ",", "err", ":=", "query", "."...
// Get the IDs of all volumes with the given name and type associated with the // given pool, regardless of their node_id column.
[ "Get", "the", "IDs", "of", "all", "volumes", "with", "the", "given", "name", "and", "type", "associated", "with", "the", "given", "pool", "regardless", "of", "their", "node_id", "column", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_volumes.go#L293-L308
test
lxc/lxd
lxd/db/storage_volumes.go
StorageVolumeCleanupImages
func (c *Cluster) StorageVolumeCleanupImages(fingerprints []string) error { stmt := fmt.Sprintf( "DELETE FROM storage_volumes WHERE type=? AND name NOT IN %s", query.Params(len(fingerprints))) args := []interface{}{StoragePoolVolumeTypeImage} for _, fingerprint := range fingerprints { args = append(args, finge...
go
func (c *Cluster) StorageVolumeCleanupImages(fingerprints []string) error { stmt := fmt.Sprintf( "DELETE FROM storage_volumes WHERE type=? AND name NOT IN %s", query.Params(len(fingerprints))) args := []interface{}{StoragePoolVolumeTypeImage} for _, fingerprint := range fingerprints { args = append(args, finge...
[ "func", "(", "c", "*", "Cluster", ")", "StorageVolumeCleanupImages", "(", "fingerprints", "[", "]", "string", ")", "error", "{", "stmt", ":=", "fmt", ".", "Sprintf", "(", "\"DELETE FROM storage_volumes WHERE type=? AND name NOT IN %s\"", ",", "query", ".", "Params",...
// StorageVolumeCleanupImages removes the volumes with the given fingerprints.
[ "StorageVolumeCleanupImages", "removes", "the", "volumes", "with", "the", "given", "fingerprints", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_volumes.go#L311-L321
test
lxc/lxd
lxd/db/storage_volumes.go
StorageVolumeMoveToLVMThinPoolNameKey
func (c *Cluster) StorageVolumeMoveToLVMThinPoolNameKey() error { err := exec(c.db, "UPDATE storage_pools_config SET key='lvm.thinpool_name' WHERE key='volume.lvm.thinpool_name';") if err != nil { return err } err = exec(c.db, "DELETE FROM storage_volumes_config WHERE key='lvm.thinpool_name';") if err != nil { ...
go
func (c *Cluster) StorageVolumeMoveToLVMThinPoolNameKey() error { err := exec(c.db, "UPDATE storage_pools_config SET key='lvm.thinpool_name' WHERE key='volume.lvm.thinpool_name';") if err != nil { return err } err = exec(c.db, "DELETE FROM storage_volumes_config WHERE key='lvm.thinpool_name';") if err != nil { ...
[ "func", "(", "c", "*", "Cluster", ")", "StorageVolumeMoveToLVMThinPoolNameKey", "(", ")", "error", "{", "err", ":=", "exec", "(", "c", ".", "db", ",", "\"UPDATE storage_pools_config SET key='lvm.thinpool_name' WHERE key='volume.lvm.thinpool_name';\"", ")", "\n", "if", "...
// StorageVolumeMoveToLVMThinPoolNameKey upgrades the config keys of LVM // volumes.
[ "StorageVolumeMoveToLVMThinPoolNameKey", "upgrades", "the", "config", "keys", "of", "LVM", "volumes", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_volumes.go#L325-L337
test
lxc/lxd
shared/generate/file/buffer.go
L
func (b *Buffer) L(format string, a ...interface{}) { fmt.Fprintf(b.buf, format, a...) b.N() }
go
func (b *Buffer) L(format string, a ...interface{}) { fmt.Fprintf(b.buf, format, a...) b.N() }
[ "func", "(", "b", "*", "Buffer", ")", "L", "(", "format", "string", ",", "a", "...", "interface", "{", "}", ")", "{", "fmt", ".", "Fprintf", "(", "b", ".", "buf", ",", "format", ",", "a", "...", ")", "\n", "b", ".", "N", "(", ")", "\n", "}"...
// L accumulates a single line of source code.
[ "L", "accumulates", "a", "single", "line", "of", "source", "code", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/file/buffer.go#L26-L29
test
lxc/lxd
shared/generate/file/buffer.go
code
func (b *Buffer) code() ([]byte, error) { code, err := format.Source(b.buf.Bytes()) if err != nil { return nil, errors.Wrap(err, "Can't format generated source code") } return code, nil }
go
func (b *Buffer) code() ([]byte, error) { code, err := format.Source(b.buf.Bytes()) if err != nil { return nil, errors.Wrap(err, "Can't format generated source code") } return code, nil }
[ "func", "(", "b", "*", "Buffer", ")", "code", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "code", ",", "err", ":=", "format", ".", "Source", "(", "b", ".", "buf", ".", "Bytes", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{"...
// Returns the source code to add to the target file.
[ "Returns", "the", "source", "code", "to", "add", "to", "the", "target", "file", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/file/buffer.go#L37-L43
test
lxc/lxd
shared/logger/format.go
Pretty
func Pretty(input interface{}) string { pretty, err := json.MarshalIndent(input, "\t", "\t") if err != nil { return fmt.Sprintf("%v", input) } return fmt.Sprintf("\n\t%s", pretty) }
go
func Pretty(input interface{}) string { pretty, err := json.MarshalIndent(input, "\t", "\t") if err != nil { return fmt.Sprintf("%v", input) } return fmt.Sprintf("\n\t%s", pretty) }
[ "func", "Pretty", "(", "input", "interface", "{", "}", ")", "string", "{", "pretty", ",", "err", ":=", "json", ".", "MarshalIndent", "(", "input", ",", "\"\\t\"", ",", "\\t", ")", "\n", "\"\\t\"", "\n", "\\t", "\n", "}" ]
// Pretty will attempt to convert any Go structure into a string suitable for logging
[ "Pretty", "will", "attempt", "to", "convert", "any", "Go", "structure", "into", "a", "string", "suitable", "for", "logging" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/logger/format.go#L10-L17
test
lxc/lxd
lxd/endpoints/network.go
NetworkPublicKey
func (e *Endpoints) NetworkPublicKey() []byte { e.mu.RLock() defer e.mu.RUnlock() return e.cert.PublicKey() }
go
func (e *Endpoints) NetworkPublicKey() []byte { e.mu.RLock() defer e.mu.RUnlock() return e.cert.PublicKey() }
[ "func", "(", "e", "*", "Endpoints", ")", "NetworkPublicKey", "(", ")", "[", "]", "byte", "{", "e", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "e", ".", "mu", ".", "RUnlock", "(", ")", "\n", "return", "e", ".", "cert", ".", "PublicKey", "...
// NetworkPublicKey returns the public key of the TLS certificate used by the // network endpoint.
[ "NetworkPublicKey", "returns", "the", "public", "key", "of", "the", "TLS", "certificate", "used", "by", "the", "network", "endpoint", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/endpoints/network.go#L18-L23
test
lxc/lxd
lxd/endpoints/network.go
NetworkPrivateKey
func (e *Endpoints) NetworkPrivateKey() []byte { e.mu.RLock() defer e.mu.RUnlock() return e.cert.PrivateKey() }
go
func (e *Endpoints) NetworkPrivateKey() []byte { e.mu.RLock() defer e.mu.RUnlock() return e.cert.PrivateKey() }
[ "func", "(", "e", "*", "Endpoints", ")", "NetworkPrivateKey", "(", ")", "[", "]", "byte", "{", "e", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "e", ".", "mu", ".", "RUnlock", "(", ")", "\n", "return", "e", ".", "cert", ".", "PrivateKey", ...
// NetworkPrivateKey returns the private key of the TLS certificate used by the // network endpoint.
[ "NetworkPrivateKey", "returns", "the", "private", "key", "of", "the", "TLS", "certificate", "used", "by", "the", "network", "endpoint", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/endpoints/network.go#L27-L32
test
lxc/lxd
lxd/endpoints/network.go
NetworkCert
func (e *Endpoints) NetworkCert() *shared.CertInfo { e.mu.RLock() defer e.mu.RUnlock() return e.cert }
go
func (e *Endpoints) NetworkCert() *shared.CertInfo { e.mu.RLock() defer e.mu.RUnlock() return e.cert }
[ "func", "(", "e", "*", "Endpoints", ")", "NetworkCert", "(", ")", "*", "shared", ".", "CertInfo", "{", "e", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "e", ".", "mu", ".", "RUnlock", "(", ")", "\n", "return", "e", ".", "cert", "\n", "}" ...
// NetworkCert returns the full TLS certificate information for this endpoint.
[ "NetworkCert", "returns", "the", "full", "TLS", "certificate", "information", "for", "this", "endpoint", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/endpoints/network.go#L35-L40
test
lxc/lxd
lxd/endpoints/network.go
NetworkAddress
func (e *Endpoints) NetworkAddress() string { e.mu.RLock() defer e.mu.RUnlock() listener := e.listeners[network] if listener == nil { return "" } return listener.Addr().String() }
go
func (e *Endpoints) NetworkAddress() string { e.mu.RLock() defer e.mu.RUnlock() listener := e.listeners[network] if listener == nil { return "" } return listener.Addr().String() }
[ "func", "(", "e", "*", "Endpoints", ")", "NetworkAddress", "(", ")", "string", "{", "e", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "e", ".", "mu", ".", "RUnlock", "(", ")", "\n", "listener", ":=", "e", ".", "listeners", "[", "network", "]...
// NetworkAddress returns the network addresss of the network endpoint, or an // empty string if there's no network endpoint
[ "NetworkAddress", "returns", "the", "network", "addresss", "of", "the", "network", "endpoint", "or", "an", "empty", "string", "if", "there", "s", "no", "network", "endpoint" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/endpoints/network.go#L44-L53
test
lxc/lxd
lxd/endpoints/network.go
NetworkUpdateAddress
func (e *Endpoints) NetworkUpdateAddress(address string) error { if address != "" { address = util.CanonicalNetworkAddress(address) } oldAddress := e.NetworkAddress() if address == oldAddress { return nil } clusterAddress := e.ClusterAddress() logger.Infof("Update network address") e.mu.Lock() defer e....
go
func (e *Endpoints) NetworkUpdateAddress(address string) error { if address != "" { address = util.CanonicalNetworkAddress(address) } oldAddress := e.NetworkAddress() if address == oldAddress { return nil } clusterAddress := e.ClusterAddress() logger.Infof("Update network address") e.mu.Lock() defer e....
[ "func", "(", "e", "*", "Endpoints", ")", "NetworkUpdateAddress", "(", "address", "string", ")", "error", "{", "if", "address", "!=", "\"\"", "{", "address", "=", "util", ".", "CanonicalNetworkAddress", "(", "address", ")", "\n", "}", "\n", "oldAddress", ":...
// NetworkUpdateAddress updates the address for the network endpoint, shutting // it down and restarting it.
[ "NetworkUpdateAddress", "updates", "the", "address", "for", "the", "network", "endpoint", "shutting", "it", "down", "and", "restarting", "it", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/endpoints/network.go#L57-L128
test
lxc/lxd
lxd/endpoints/network.go
NetworkUpdateCert
func (e *Endpoints) NetworkUpdateCert(cert *shared.CertInfo) { e.mu.Lock() defer e.mu.Unlock() e.cert = cert listener, ok := e.listeners[network] if !ok { return } listener.(*networkListener).Config(cert) // Update the cluster listener too, if enabled. listener, ok = e.listeners[cluster] if !ok { return ...
go
func (e *Endpoints) NetworkUpdateCert(cert *shared.CertInfo) { e.mu.Lock() defer e.mu.Unlock() e.cert = cert listener, ok := e.listeners[network] if !ok { return } listener.(*networkListener).Config(cert) // Update the cluster listener too, if enabled. listener, ok = e.listeners[cluster] if !ok { return ...
[ "func", "(", "e", "*", "Endpoints", ")", "NetworkUpdateCert", "(", "cert", "*", "shared", ".", "CertInfo", ")", "{", "e", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "e", ".", "mu", ".", "Unlock", "(", ")", "\n", "e", ".", "cert", "=", "ce...
// NetworkUpdateCert updates the TLS keypair and CA used by the network // endpoint. // // If the network endpoint is active, in-flight requests will continue using // the old certificate, and only new requests will use the new one.
[ "NetworkUpdateCert", "updates", "the", "TLS", "keypair", "and", "CA", "used", "by", "the", "network", "endpoint", ".", "If", "the", "network", "endpoint", "is", "active", "in", "-", "flight", "requests", "will", "continue", "using", "the", "old", "certificate"...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/endpoints/network.go#L135-L151
test
lxc/lxd
lxd/endpoints/network.go
networkCreateListener
func networkCreateListener(address string, cert *shared.CertInfo) net.Listener { listener, err := net.Listen("tcp", util.CanonicalNetworkAddress(address)) if err != nil { logger.Error("Cannot listen on https socket, skipping...", log.Ctx{"err": err}) return nil } return networkTLSListener(listener, cert) }
go
func networkCreateListener(address string, cert *shared.CertInfo) net.Listener { listener, err := net.Listen("tcp", util.CanonicalNetworkAddress(address)) if err != nil { logger.Error("Cannot listen on https socket, skipping...", log.Ctx{"err": err}) return nil } return networkTLSListener(listener, cert) }
[ "func", "networkCreateListener", "(", "address", "string", ",", "cert", "*", "shared", ".", "CertInfo", ")", "net", ".", "Listener", "{", "listener", ",", "err", ":=", "net", ".", "Listen", "(", "\"tcp\"", ",", "util", ".", "CanonicalNetworkAddress", "(", ...
// Create a new net.Listener bound to the tcp socket of the network endpoint.
[ "Create", "a", "new", "net", ".", "Listener", "bound", "to", "the", "tcp", "socket", "of", "the", "network", "endpoint", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/endpoints/network.go#L154-L161
test
lxc/lxd
lxd/endpoints/network.go
Accept
func (l *networkListener) Accept() (net.Conn, error) { c, err := l.Listener.Accept() if err != nil { return nil, err } l.mu.RLock() defer l.mu.RUnlock() config := l.config return tls.Server(c, config), nil }
go
func (l *networkListener) Accept() (net.Conn, error) { c, err := l.Listener.Accept() if err != nil { return nil, err } l.mu.RLock() defer l.mu.RUnlock() config := l.config return tls.Server(c, config), nil }
[ "func", "(", "l", "*", "networkListener", ")", "Accept", "(", ")", "(", "net", ".", "Conn", ",", "error", ")", "{", "c", ",", "err", ":=", "l", ".", "Listener", ".", "Accept", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",",...
// Accept waits for and returns the next incoming TLS connection then use the // current TLS configuration to handle it.
[ "Accept", "waits", "for", "and", "returns", "the", "next", "incoming", "TLS", "connection", "then", "use", "the", "current", "TLS", "configuration", "to", "handle", "it", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/endpoints/network.go#L182-L191
test
lxc/lxd
lxd/endpoints/network.go
Config
func (l *networkListener) Config(cert *shared.CertInfo) { config := util.ServerTLSConfig(cert) l.mu.Lock() defer l.mu.Unlock() l.config = config }
go
func (l *networkListener) Config(cert *shared.CertInfo) { config := util.ServerTLSConfig(cert) l.mu.Lock() defer l.mu.Unlock() l.config = config }
[ "func", "(", "l", "*", "networkListener", ")", "Config", "(", "cert", "*", "shared", ".", "CertInfo", ")", "{", "config", ":=", "util", ".", "ServerTLSConfig", "(", "cert", ")", "\n", "l", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "l", ".", ...
// Config safely swaps the underlying TLS configuration.
[ "Config", "safely", "swaps", "the", "underlying", "TLS", "configuration", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/endpoints/network.go#L194-L201
test
lxc/lxd
lxd/db/node.go
IsOffline
func (n NodeInfo) IsOffline(threshold time.Duration) bool { return nodeIsOffline(threshold, n.Heartbeat) }
go
func (n NodeInfo) IsOffline(threshold time.Duration) bool { return nodeIsOffline(threshold, n.Heartbeat) }
[ "func", "(", "n", "NodeInfo", ")", "IsOffline", "(", "threshold", "time", ".", "Duration", ")", "bool", "{", "return", "nodeIsOffline", "(", "threshold", ",", "n", ".", "Heartbeat", ")", "\n", "}" ]
// IsOffline returns true if the last successful heartbeat time of the node is // older than the given threshold.
[ "IsOffline", "returns", "true", "if", "the", "last", "successful", "heartbeat", "time", "of", "the", "node", "is", "older", "than", "the", "given", "threshold", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/node.go#L29-L31
test
lxc/lxd
lxd/db/node.go
NodeByAddress
func (c *ClusterTx) NodeByAddress(address string) (NodeInfo, error) { null := NodeInfo{} nodes, err := c.nodes(false /* not pending */, "address=?", address) if err != nil { return null, err } switch len(nodes) { case 0: return null, ErrNoSuchObject case 1: return nodes[0], nil default: return null, fmt...
go
func (c *ClusterTx) NodeByAddress(address string) (NodeInfo, error) { null := NodeInfo{} nodes, err := c.nodes(false /* not pending */, "address=?", address) if err != nil { return null, err } switch len(nodes) { case 0: return null, ErrNoSuchObject case 1: return nodes[0], nil default: return null, fmt...
[ "func", "(", "c", "*", "ClusterTx", ")", "NodeByAddress", "(", "address", "string", ")", "(", "NodeInfo", ",", "error", ")", "{", "null", ":=", "NodeInfo", "{", "}", "\n", "nodes", ",", "err", ":=", "c", ".", "nodes", "(", "false", ",", "\"address=?\...
// NodeByAddress returns the node with the given network address.
[ "NodeByAddress", "returns", "the", "node", "with", "the", "given", "network", "address", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/node.go#L40-L54
test
lxc/lxd
lxd/db/node.go
NodePendingByAddress
func (c *ClusterTx) NodePendingByAddress(address string) (NodeInfo, error) { null := NodeInfo{} nodes, err := c.nodes(true /*pending */, "address=?", address) if err != nil { return null, err } switch len(nodes) { case 0: return null, ErrNoSuchObject case 1: return nodes[0], nil default: return null, fm...
go
func (c *ClusterTx) NodePendingByAddress(address string) (NodeInfo, error) { null := NodeInfo{} nodes, err := c.nodes(true /*pending */, "address=?", address) if err != nil { return null, err } switch len(nodes) { case 0: return null, ErrNoSuchObject case 1: return nodes[0], nil default: return null, fm...
[ "func", "(", "c", "*", "ClusterTx", ")", "NodePendingByAddress", "(", "address", "string", ")", "(", "NodeInfo", ",", "error", ")", "{", "null", ":=", "NodeInfo", "{", "}", "\n", "nodes", ",", "err", ":=", "c", ".", "nodes", "(", "true", ",", "\"addr...
// NodePendingByAddress returns the pending node with the given network address.
[ "NodePendingByAddress", "returns", "the", "pending", "node", "with", "the", "given", "network", "address", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/node.go#L57-L71
test
lxc/lxd
lxd/db/node.go
NodeByName
func (c *ClusterTx) NodeByName(name string) (NodeInfo, error) { null := NodeInfo{} nodes, err := c.nodes(false /* not pending */, "name=?", name) if err != nil { return null, err } switch len(nodes) { case 0: return null, ErrNoSuchObject case 1: return nodes[0], nil default: return null, fmt.Errorf("mor...
go
func (c *ClusterTx) NodeByName(name string) (NodeInfo, error) { null := NodeInfo{} nodes, err := c.nodes(false /* not pending */, "name=?", name) if err != nil { return null, err } switch len(nodes) { case 0: return null, ErrNoSuchObject case 1: return nodes[0], nil default: return null, fmt.Errorf("mor...
[ "func", "(", "c", "*", "ClusterTx", ")", "NodeByName", "(", "name", "string", ")", "(", "NodeInfo", ",", "error", ")", "{", "null", ":=", "NodeInfo", "{", "}", "\n", "nodes", ",", "err", ":=", "c", ".", "nodes", "(", "false", ",", "\"name=?\"", ","...
// NodeByName returns the node with the given name.
[ "NodeByName", "returns", "the", "node", "with", "the", "given", "name", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/node.go#L74-L88
test
lxc/lxd
lxd/db/node.go
NodeName
func (c *ClusterTx) NodeName() (string, error) { stmt := "SELECT name FROM nodes WHERE id=?" names, err := query.SelectStrings(c.tx, stmt, c.nodeID) if err != nil { return "", err } switch len(names) { case 0: return "", nil case 1: return names[0], nil default: return "", fmt.Errorf("inconsistency: non...
go
func (c *ClusterTx) NodeName() (string, error) { stmt := "SELECT name FROM nodes WHERE id=?" names, err := query.SelectStrings(c.tx, stmt, c.nodeID) if err != nil { return "", err } switch len(names) { case 0: return "", nil case 1: return names[0], nil default: return "", fmt.Errorf("inconsistency: non...
[ "func", "(", "c", "*", "ClusterTx", ")", "NodeName", "(", ")", "(", "string", ",", "error", ")", "{", "stmt", ":=", "\"SELECT name FROM nodes WHERE id=?\"", "\n", "names", ",", "err", ":=", "query", ".", "SelectStrings", "(", "c", ".", "tx", ",", "stmt",...
// NodeName returns the name of the node this method is invoked on.
[ "NodeName", "returns", "the", "name", "of", "the", "node", "this", "method", "is", "invoked", "on", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/node.go#L91-L105
test
lxc/lxd
lxd/db/node.go
NodeAddress
func (c *ClusterTx) NodeAddress() (string, error) { stmt := "SELECT address FROM nodes WHERE id=?" addresses, err := query.SelectStrings(c.tx, stmt, c.nodeID) if err != nil { return "", err } switch len(addresses) { case 0: return "", nil case 1: return addresses[0], nil default: return "", fmt.Errorf("...
go
func (c *ClusterTx) NodeAddress() (string, error) { stmt := "SELECT address FROM nodes WHERE id=?" addresses, err := query.SelectStrings(c.tx, stmt, c.nodeID) if err != nil { return "", err } switch len(addresses) { case 0: return "", nil case 1: return addresses[0], nil default: return "", fmt.Errorf("...
[ "func", "(", "c", "*", "ClusterTx", ")", "NodeAddress", "(", ")", "(", "string", ",", "error", ")", "{", "stmt", ":=", "\"SELECT address FROM nodes WHERE id=?\"", "\n", "addresses", ",", "err", ":=", "query", ".", "SelectStrings", "(", "c", ".", "tx", ",",...
// NodeAddress returns the address of the node this method is invoked on.
[ "NodeAddress", "returns", "the", "address", "of", "the", "node", "this", "method", "is", "invoked", "on", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/node.go#L108-L122
test
lxc/lxd
lxd/db/node.go
NodeIsOutdated
func (c *ClusterTx) NodeIsOutdated() (bool, error) { nodes, err := c.nodes(false /* not pending */, "") if err != nil { return false, errors.Wrap(err, "Failed to fetch nodes") } // Figure our own version. version := [2]int{} for _, node := range nodes { if node.ID == c.nodeID { version = node.Version() ...
go
func (c *ClusterTx) NodeIsOutdated() (bool, error) { nodes, err := c.nodes(false /* not pending */, "") if err != nil { return false, errors.Wrap(err, "Failed to fetch nodes") } // Figure our own version. version := [2]int{} for _, node := range nodes { if node.ID == c.nodeID { version = node.Version() ...
[ "func", "(", "c", "*", "ClusterTx", ")", "NodeIsOutdated", "(", ")", "(", "bool", ",", "error", ")", "{", "nodes", ",", "err", ":=", "c", ".", "nodes", "(", "false", ",", "\"\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", ...
// NodeIsOutdated returns true if there's some cluster node having an API or // schema version greater than the node this method is invoked on.
[ "NodeIsOutdated", "returns", "true", "if", "there", "s", "some", "cluster", "node", "having", "an", "API", "or", "schema", "version", "greater", "than", "the", "node", "this", "method", "is", "invoked", "on", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/node.go#L126-L160
test
lxc/lxd
lxd/db/node.go
NodesCount
func (c *ClusterTx) NodesCount() (int, error) { count, err := query.Count(c.tx, "nodes", "") if err != nil { return 0, errors.Wrap(err, "failed to count existing nodes") } return count, nil }
go
func (c *ClusterTx) NodesCount() (int, error) { count, err := query.Count(c.tx, "nodes", "") if err != nil { return 0, errors.Wrap(err, "failed to count existing nodes") } return count, nil }
[ "func", "(", "c", "*", "ClusterTx", ")", "NodesCount", "(", ")", "(", "int", ",", "error", ")", "{", "count", ",", "err", ":=", "query", ".", "Count", "(", "c", ".", "tx", ",", "\"nodes\"", ",", "\"\"", ")", "\n", "if", "err", "!=", "nil", "{",...
// NodesCount returns the number of nodes in the LXD cluster. // // Since there's always at least one node row, even when not-clustered, the // return value is greater than zero
[ "NodesCount", "returns", "the", "number", "of", "nodes", "in", "the", "LXD", "cluster", ".", "Since", "there", "s", "always", "at", "least", "one", "node", "row", "even", "when", "not", "-", "clustered", "the", "return", "value", "is", "greater", "than", ...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/node.go#L174-L180
test
lxc/lxd
lxd/db/node.go
NodeRename
func (c *ClusterTx) NodeRename(old, new string) error { count, err := query.Count(c.tx, "nodes", "name=?", new) if err != nil { return errors.Wrap(err, "failed to check existing nodes") } if count != 0 { return ErrAlreadyDefined } stmt := `UPDATE nodes SET name=? WHERE name=?` result, err := c.tx.Exec(stmt, ...
go
func (c *ClusterTx) NodeRename(old, new string) error { count, err := query.Count(c.tx, "nodes", "name=?", new) if err != nil { return errors.Wrap(err, "failed to check existing nodes") } if count != 0 { return ErrAlreadyDefined } stmt := `UPDATE nodes SET name=? WHERE name=?` result, err := c.tx.Exec(stmt, ...
[ "func", "(", "c", "*", "ClusterTx", ")", "NodeRename", "(", "old", ",", "new", "string", ")", "error", "{", "count", ",", "err", ":=", "query", ".", "Count", "(", "c", ".", "tx", ",", "\"nodes\"", ",", "\"name=?\"", ",", "new", ")", "\n", "if", "...
// NodeRename changes the name of an existing node. // // Return an error if a node with the same name already exists.
[ "NodeRename", "changes", "the", "name", "of", "an", "existing", "node", ".", "Return", "an", "error", "if", "a", "node", "with", "the", "same", "name", "already", "exists", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/node.go#L185-L206
test
lxc/lxd
lxd/db/node.go
nodes
func (c *ClusterTx) nodes(pending bool, where string, args ...interface{}) ([]NodeInfo, error) { nodes := []NodeInfo{} dest := func(i int) []interface{} { nodes = append(nodes, NodeInfo{}) return []interface{}{ &nodes[i].ID, &nodes[i].Name, &nodes[i].Address, &nodes[i].Description, &nodes[i].Schema...
go
func (c *ClusterTx) nodes(pending bool, where string, args ...interface{}) ([]NodeInfo, error) { nodes := []NodeInfo{} dest := func(i int) []interface{} { nodes = append(nodes, NodeInfo{}) return []interface{}{ &nodes[i].ID, &nodes[i].Name, &nodes[i].Address, &nodes[i].Description, &nodes[i].Schema...
[ "func", "(", "c", "*", "ClusterTx", ")", "nodes", "(", "pending", "bool", ",", "where", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "[", "]", "NodeInfo", ",", "error", ")", "{", "nodes", ":=", "[", "]", "NodeInfo", "{", "}", "\...
// Nodes returns all LXD nodes part of the cluster.
[ "Nodes", "returns", "all", "LXD", "nodes", "part", "of", "the", "cluster", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/node.go#L209-L244
test
lxc/lxd
lxd/db/node.go
NodeAdd
func (c *ClusterTx) NodeAdd(name string, address string) (int64, error) { columns := []string{"name", "address", "schema", "api_extensions"} values := []interface{}{name, address, cluster.SchemaVersion, version.APIExtensionsCount()} return query.UpsertObject(c.tx, "nodes", columns, values) }
go
func (c *ClusterTx) NodeAdd(name string, address string) (int64, error) { columns := []string{"name", "address", "schema", "api_extensions"} values := []interface{}{name, address, cluster.SchemaVersion, version.APIExtensionsCount()} return query.UpsertObject(c.tx, "nodes", columns, values) }
[ "func", "(", "c", "*", "ClusterTx", ")", "NodeAdd", "(", "name", "string", ",", "address", "string", ")", "(", "int64", ",", "error", ")", "{", "columns", ":=", "[", "]", "string", "{", "\"name\"", ",", "\"address\"", ",", "\"schema\"", ",", "\"api_ext...
// NodeAdd adds a node to the current list of LXD nodes that are part of the // cluster. It returns the ID of the newly inserted row.
[ "NodeAdd", "adds", "a", "node", "to", "the", "current", "list", "of", "LXD", "nodes", "that", "are", "part", "of", "the", "cluster", ".", "It", "returns", "the", "ID", "of", "the", "newly", "inserted", "row", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/node.go#L248-L252
test
lxc/lxd
lxd/db/node.go
NodePending
func (c *ClusterTx) NodePending(id int64, pending bool) error { value := 0 if pending { value = 1 } result, err := c.tx.Exec("UPDATE nodes SET pending=? WHERE id=?", value, id) if err != nil { return err } n, err := result.RowsAffected() if err != nil { return err } if n != 1 { return fmt.Errorf("quer...
go
func (c *ClusterTx) NodePending(id int64, pending bool) error { value := 0 if pending { value = 1 } result, err := c.tx.Exec("UPDATE nodes SET pending=? WHERE id=?", value, id) if err != nil { return err } n, err := result.RowsAffected() if err != nil { return err } if n != 1 { return fmt.Errorf("quer...
[ "func", "(", "c", "*", "ClusterTx", ")", "NodePending", "(", "id", "int64", ",", "pending", "bool", ")", "error", "{", "value", ":=", "0", "\n", "if", "pending", "{", "value", "=", "1", "\n", "}", "\n", "result", ",", "err", ":=", "c", ".", "tx",...
// NodePending toggles the pending flag for the node. A node is pending when // it's been accepted in the cluster, but has not yet actually joined it.
[ "NodePending", "toggles", "the", "pending", "flag", "for", "the", "node", ".", "A", "node", "is", "pending", "when", "it", "s", "been", "accepted", "in", "the", "cluster", "but", "has", "not", "yet", "actually", "joined", "it", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/node.go#L256-L273
test
lxc/lxd
lxd/db/node.go
NodeUpdate
func (c *ClusterTx) NodeUpdate(id int64, name string, address string) error { result, err := c.tx.Exec("UPDATE nodes SET name=?, address=? WHERE id=?", name, address, id) if err != nil { return err } n, err := result.RowsAffected() if err != nil { return err } if n != 1 { return fmt.Errorf("query updated %...
go
func (c *ClusterTx) NodeUpdate(id int64, name string, address string) error { result, err := c.tx.Exec("UPDATE nodes SET name=?, address=? WHERE id=?", name, address, id) if err != nil { return err } n, err := result.RowsAffected() if err != nil { return err } if n != 1 { return fmt.Errorf("query updated %...
[ "func", "(", "c", "*", "ClusterTx", ")", "NodeUpdate", "(", "id", "int64", ",", "name", "string", ",", "address", "string", ")", "error", "{", "result", ",", "err", ":=", "c", ".", "tx", ".", "Exec", "(", "\"UPDATE nodes SET name=?, address=? WHERE id=?\"", ...
// NodeUpdate updates the name an address of a node.
[ "NodeUpdate", "updates", "the", "name", "an", "address", "of", "a", "node", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/node.go#L276-L289
test
lxc/lxd
lxd/db/node.go
NodeRemove
func (c *ClusterTx) NodeRemove(id int64) error { result, err := c.tx.Exec("DELETE FROM nodes WHERE id=?", id) if err != nil { return err } n, err := result.RowsAffected() if err != nil { return err } if n != 1 { return fmt.Errorf("query deleted %d rows instead of 1", n) } return nil }
go
func (c *ClusterTx) NodeRemove(id int64) error { result, err := c.tx.Exec("DELETE FROM nodes WHERE id=?", id) if err != nil { return err } n, err := result.RowsAffected() if err != nil { return err } if n != 1 { return fmt.Errorf("query deleted %d rows instead of 1", n) } return nil }
[ "func", "(", "c", "*", "ClusterTx", ")", "NodeRemove", "(", "id", "int64", ")", "error", "{", "result", ",", "err", ":=", "c", ".", "tx", ".", "Exec", "(", "\"DELETE FROM nodes WHERE id=?\"", ",", "id", ")", "\n", "if", "err", "!=", "nil", "{", "retu...
// NodeRemove removes the node with the given id.
[ "NodeRemove", "removes", "the", "node", "with", "the", "given", "id", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/node.go#L292-L305
test
lxc/lxd
lxd/db/node.go
NodeHeartbeat
func (c *ClusterTx) NodeHeartbeat(address string, heartbeat time.Time) error { stmt := "UPDATE nodes SET heartbeat=? WHERE address=?" result, err := c.tx.Exec(stmt, heartbeat, address) if err != nil { return err } n, err := result.RowsAffected() if err != nil { return err } if n != 1 { return fmt.Errorf("...
go
func (c *ClusterTx) NodeHeartbeat(address string, heartbeat time.Time) error { stmt := "UPDATE nodes SET heartbeat=? WHERE address=?" result, err := c.tx.Exec(stmt, heartbeat, address) if err != nil { return err } n, err := result.RowsAffected() if err != nil { return err } if n != 1 { return fmt.Errorf("...
[ "func", "(", "c", "*", "ClusterTx", ")", "NodeHeartbeat", "(", "address", "string", ",", "heartbeat", "time", ".", "Time", ")", "error", "{", "stmt", ":=", "\"UPDATE nodes SET heartbeat=? WHERE address=?\"", "\n", "result", ",", "err", ":=", "c", ".", "tx", ...
// NodeHeartbeat updates the heartbeat column of the node with the given address.
[ "NodeHeartbeat", "updates", "the", "heartbeat", "column", "of", "the", "node", "with", "the", "given", "address", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/node.go#L308-L322
test
lxc/lxd
lxd/db/node.go
NodeIsEmpty
func (c *ClusterTx) NodeIsEmpty(id int64) (string, error) { // Check if the node has any containers. containers, err := query.SelectStrings(c.tx, "SELECT name FROM containers WHERE node_id=?", id) if err != nil { return "", errors.Wrapf(err, "Failed to get containers for node %d", id) } if len(containers) > 0 { ...
go
func (c *ClusterTx) NodeIsEmpty(id int64) (string, error) { // Check if the node has any containers. containers, err := query.SelectStrings(c.tx, "SELECT name FROM containers WHERE node_id=?", id) if err != nil { return "", errors.Wrapf(err, "Failed to get containers for node %d", id) } if len(containers) > 0 { ...
[ "func", "(", "c", "*", "ClusterTx", ")", "NodeIsEmpty", "(", "id", "int64", ")", "(", "string", ",", "error", ")", "{", "containers", ",", "err", ":=", "query", ".", "SelectStrings", "(", "c", ".", "tx", ",", "\"SELECT name FROM containers WHERE node_id=?\""...
// NodeIsEmpty returns an empty string if the node with the given ID has no // containers or images associated with it. Otherwise, it returns a message // say what's left.
[ "NodeIsEmpty", "returns", "an", "empty", "string", "if", "the", "node", "with", "the", "given", "ID", "has", "no", "containers", "or", "images", "associated", "with", "it", ".", "Otherwise", "it", "returns", "a", "message", "say", "what", "s", "left", "." ...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/node.go#L327-L397
test
lxc/lxd
lxd/db/node.go
NodeClear
func (c *ClusterTx) NodeClear(id int64) error { _, err := c.tx.Exec("DELETE FROM containers WHERE node_id=?", id) if err != nil { return err } // Get the IDs of the images this node is hosting. ids, err := query.SelectIntegers(c.tx, "SELECT image_id FROM images_nodes WHERE node_id=?", id) if err != nil { ret...
go
func (c *ClusterTx) NodeClear(id int64) error { _, err := c.tx.Exec("DELETE FROM containers WHERE node_id=?", id) if err != nil { return err } // Get the IDs of the images this node is hosting. ids, err := query.SelectIntegers(c.tx, "SELECT image_id FROM images_nodes WHERE node_id=?", id) if err != nil { ret...
[ "func", "(", "c", "*", "ClusterTx", ")", "NodeClear", "(", "id", "int64", ")", "error", "{", "_", ",", "err", ":=", "c", ".", "tx", ".", "Exec", "(", "\"DELETE FROM containers WHERE node_id=?\"", ",", "id", ")", "\n", "if", "err", "!=", "nil", "{", "...
// NodeClear removes any container or image associated with this node.
[ "NodeClear", "removes", "any", "container", "or", "image", "associated", "with", "this", "node", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/node.go#L400-L434
test
lxc/lxd
lxd/db/node.go
NodeOfflineThreshold
func (c *ClusterTx) NodeOfflineThreshold() (time.Duration, error) { threshold := time.Duration(DefaultOfflineThreshold) * time.Second values, err := query.SelectStrings( c.tx, "SELECT value FROM config WHERE key='cluster.offline_threshold'") if err != nil { return -1, err } if len(values) > 0 { seconds, err ...
go
func (c *ClusterTx) NodeOfflineThreshold() (time.Duration, error) { threshold := time.Duration(DefaultOfflineThreshold) * time.Second values, err := query.SelectStrings( c.tx, "SELECT value FROM config WHERE key='cluster.offline_threshold'") if err != nil { return -1, err } if len(values) > 0 { seconds, err ...
[ "func", "(", "c", "*", "ClusterTx", ")", "NodeOfflineThreshold", "(", ")", "(", "time", ".", "Duration", ",", "error", ")", "{", "threshold", ":=", "time", ".", "Duration", "(", "DefaultOfflineThreshold", ")", "*", "time", ".", "Second", "\n", "values", ...
// NodeOfflineThreshold returns the amount of time that needs to elapse after // which a series of unsuccessful heartbeat will make the node be considered // offline.
[ "NodeOfflineThreshold", "returns", "the", "amount", "of", "time", "that", "needs", "to", "elapse", "after", "which", "a", "series", "of", "unsuccessful", "heartbeat", "will", "make", "the", "node", "be", "considered", "offline", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/node.go#L439-L454
test
lxc/lxd
lxd/db/node.go
NodeUpdateVersion
func (c *ClusterTx) NodeUpdateVersion(id int64, version [2]int) error { stmt := "UPDATE nodes SET schema=?, api_extensions=? WHERE id=?" result, err := c.tx.Exec(stmt, version[0], version[1], id) if err != nil { return errors.Wrap(err, "Failed to update nodes table") } n, err := result.RowsAffected() if err !...
go
func (c *ClusterTx) NodeUpdateVersion(id int64, version [2]int) error { stmt := "UPDATE nodes SET schema=?, api_extensions=? WHERE id=?" result, err := c.tx.Exec(stmt, version[0], version[1], id) if err != nil { return errors.Wrap(err, "Failed to update nodes table") } n, err := result.RowsAffected() if err !...
[ "func", "(", "c", "*", "ClusterTx", ")", "NodeUpdateVersion", "(", "id", "int64", ",", "version", "[", "2", "]", "int", ")", "error", "{", "stmt", ":=", "\"UPDATE nodes SET schema=?, api_extensions=? WHERE id=?\"", "\n", "result", ",", "err", ":=", "c", ".", ...
// NodeUpdateVersion updates the schema and API version of the node with the // given id. This is used only in tests.
[ "NodeUpdateVersion", "updates", "the", "schema", "and", "API", "version", "of", "the", "node", "with", "the", "given", "id", ".", "This", "is", "used", "only", "in", "tests", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/node.go#L500-L518
test
lxc/lxd
lxd/db/query/transaction.go
Transaction
func Transaction(db *sql.DB, f func(*sql.Tx) error) error { tx, err := db.Begin() if err != nil { return errors.Wrap(err, "failed to begin transaction") } err = f(tx) if err != nil { return rollback(tx, err) } err = tx.Commit() if err == sql.ErrTxDone { err = nil // Ignore duplicate commits/rollbacks }...
go
func Transaction(db *sql.DB, f func(*sql.Tx) error) error { tx, err := db.Begin() if err != nil { return errors.Wrap(err, "failed to begin transaction") } err = f(tx) if err != nil { return rollback(tx, err) } err = tx.Commit() if err == sql.ErrTxDone { err = nil // Ignore duplicate commits/rollbacks }...
[ "func", "Transaction", "(", "db", "*", "sql", ".", "DB", ",", "f", "func", "(", "*", "sql", ".", "Tx", ")", "error", ")", "error", "{", "tx", ",", "err", ":=", "db", ".", "Begin", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "erro...
// Transaction executes the given function within a database transaction.
[ "Transaction", "executes", "the", "given", "function", "within", "a", "database", "transaction", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/query/transaction.go#L11-L27
test
lxc/lxd
lxd/db/query/transaction.go
rollback
func rollback(tx *sql.Tx, reason error) error { err := tx.Rollback() if err != nil { logger.Warnf("Failed to rollback transaction after error (%v): %v", reason, err) } return reason }
go
func rollback(tx *sql.Tx, reason error) error { err := tx.Rollback() if err != nil { logger.Warnf("Failed to rollback transaction after error (%v): %v", reason, err) } return reason }
[ "func", "rollback", "(", "tx", "*", "sql", ".", "Tx", ",", "reason", "error", ")", "error", "{", "err", ":=", "tx", ".", "Rollback", "(", ")", "\n", "if", "err", "!=", "nil", "{", "logger", ".", "Warnf", "(", "\"Failed to rollback transaction after error...
// Rollback a transaction after the given error occurred. If the rollback // succeeds the given error is returned, otherwise a new error that wraps it // gets generated and returned.
[ "Rollback", "a", "transaction", "after", "the", "given", "error", "occurred", ".", "If", "the", "rollback", "succeeds", "the", "given", "error", "is", "returned", "otherwise", "a", "new", "error", "that", "wraps", "it", "gets", "generated", "and", "returned", ...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/query/transaction.go#L32-L39
test
lxc/lxd
lxd/db/profiles.mapper.go
ProfileURIs
func (c *ClusterTx) ProfileURIs(filter ProfileFilter) ([]string, error) { // Check which filter criteria are active. criteria := map[string]interface{}{} if filter.Project != "" { criteria["Project"] = filter.Project } if filter.Name != "" { criteria["Name"] = filter.Name } // Pick the prepared statement an...
go
func (c *ClusterTx) ProfileURIs(filter ProfileFilter) ([]string, error) { // Check which filter criteria are active. criteria := map[string]interface{}{} if filter.Project != "" { criteria["Project"] = filter.Project } if filter.Name != "" { criteria["Name"] = filter.Name } // Pick the prepared statement an...
[ "func", "(", "c", "*", "ClusterTx", ")", "ProfileURIs", "(", "filter", "ProfileFilter", ")", "(", "[", "]", "string", ",", "error", ")", "{", "criteria", ":=", "map", "[", "string", "]", "interface", "{", "}", "{", "}", "\n", "if", "filter", ".", "...
// ProfileURIs returns all available profile URIs.
[ "ProfileURIs", "returns", "all", "available", "profile", "URIs", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/profiles.mapper.go#L121-L155
test
lxc/lxd
lxd/db/profiles.mapper.go
ProfileGet
func (c *ClusterTx) ProfileGet(project string, name string) (*Profile, error) { filter := ProfileFilter{} filter.Project = project filter.Name = name objects, err := c.ProfileList(filter) if err != nil { return nil, errors.Wrap(err, "Failed to fetch Profile") } switch len(objects) { case 0: return nil, Er...
go
func (c *ClusterTx) ProfileGet(project string, name string) (*Profile, error) { filter := ProfileFilter{} filter.Project = project filter.Name = name objects, err := c.ProfileList(filter) if err != nil { return nil, errors.Wrap(err, "Failed to fetch Profile") } switch len(objects) { case 0: return nil, Er...
[ "func", "(", "c", "*", "ClusterTx", ")", "ProfileGet", "(", "project", "string", ",", "name", "string", ")", "(", "*", "Profile", ",", "error", ")", "{", "filter", ":=", "ProfileFilter", "{", "}", "\n", "filter", ".", "Project", "=", "project", "\n", ...
// ProfileGet returns the profile with the given key.
[ "ProfileGet", "returns", "the", "profile", "with", "the", "given", "key", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/profiles.mapper.go#L272-L290
test
lxc/lxd
lxd/db/profiles.mapper.go
ProfileExists
func (c *ClusterTx) ProfileExists(project string, name string) (bool, error) { _, err := c.ProfileID(project, name) if err != nil { if err == ErrNoSuchObject { return false, nil } return false, err } return true, nil }
go
func (c *ClusterTx) ProfileExists(project string, name string) (bool, error) { _, err := c.ProfileID(project, name) if err != nil { if err == ErrNoSuchObject { return false, nil } return false, err } return true, nil }
[ "func", "(", "c", "*", "ClusterTx", ")", "ProfileExists", "(", "project", "string", ",", "name", "string", ")", "(", "bool", ",", "error", ")", "{", "_", ",", "err", ":=", "c", ".", "ProfileID", "(", "project", ",", "name", ")", "\n", "if", "err", ...
// ProfileExists checks if a profile with the given key exists.
[ "ProfileExists", "checks", "if", "a", "profile", "with", "the", "given", "key", "exists", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/profiles.mapper.go#L293-L303
test
lxc/lxd
lxd/db/profiles.mapper.go
ProfileConfigRef
func (c *ClusterTx) ProfileConfigRef(filter ProfileFilter) (map[string]map[string]map[string]string, error) { // Result slice. objects := make([]struct { Project string Name string Key string Value string }, 0) // Check which filter criteria are active. criteria := map[string]interface{}{} if fi...
go
func (c *ClusterTx) ProfileConfigRef(filter ProfileFilter) (map[string]map[string]map[string]string, error) { // Result slice. objects := make([]struct { Project string Name string Key string Value string }, 0) // Check which filter criteria are active. criteria := map[string]interface{}{} if fi...
[ "func", "(", "c", "*", "ClusterTx", ")", "ProfileConfigRef", "(", "filter", "ProfileFilter", ")", "(", "map", "[", "string", "]", "map", "[", "string", "]", "map", "[", "string", "]", "string", ",", "error", ")", "{", "objects", ":=", "make", "(", "[...
// ProfileConfigRef returns entities used by profiles.
[ "ProfileConfigRef", "returns", "entities", "used", "by", "profiles", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/profiles.mapper.go#L335-L415
test
lxc/lxd
lxd/db/profiles.mapper.go
ProfileUsedByRef
func (c *ClusterTx) ProfileUsedByRef(filter ProfileFilter) (map[string]map[string][]string, error) { // Result slice. objects := make([]struct { Project string Name string Value string }, 0) // Check which filter criteria are active. criteria := map[string]interface{}{} if filter.Project != "" { cri...
go
func (c *ClusterTx) ProfileUsedByRef(filter ProfileFilter) (map[string]map[string][]string, error) { // Result slice. objects := make([]struct { Project string Name string Value string }, 0) // Check which filter criteria are active. criteria := map[string]interface{}{} if filter.Project != "" { cri...
[ "func", "(", "c", "*", "ClusterTx", ")", "ProfileUsedByRef", "(", "filter", "ProfileFilter", ")", "(", "map", "[", "string", "]", "map", "[", "string", "]", "[", "]", "string", ",", "error", ")", "{", "objects", ":=", "make", "(", "[", "]", "struct",...
// ProfileUsedByRef returns entities used by profiles.
[ "ProfileUsedByRef", "returns", "entities", "used", "by", "profiles", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/profiles.mapper.go#L522-L598
test
lxc/lxd
lxd/db/profiles.mapper.go
ProfileCreate
func (c *ClusterTx) ProfileCreate(object Profile) (int64, error) { // Check if a profile with the same key exists. exists, err := c.ProfileExists(object.Project, object.Name) if err != nil { return -1, errors.Wrap(err, "Failed to check for duplicates") } if exists { return -1, fmt.Errorf("This profile already ...
go
func (c *ClusterTx) ProfileCreate(object Profile) (int64, error) { // Check if a profile with the same key exists. exists, err := c.ProfileExists(object.Project, object.Name) if err != nil { return -1, errors.Wrap(err, "Failed to check for duplicates") } if exists { return -1, fmt.Errorf("This profile already ...
[ "func", "(", "c", "*", "ClusterTx", ")", "ProfileCreate", "(", "object", "Profile", ")", "(", "int64", ",", "error", ")", "{", "exists", ",", "err", ":=", "c", ".", "ProfileExists", "(", "object", ".", "Project", ",", "object", ".", "Name", ")", "\n"...
// ProfileCreate adds a new profile to the database.
[ "ProfileCreate", "adds", "a", "new", "profile", "to", "the", "database", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/profiles.mapper.go#L601-L670
test
lxc/lxd
lxd/db/profiles.mapper.go
ProfileRename
func (c *ClusterTx) ProfileRename(project string, name string, to string) error { stmt := c.stmt(profileRename) result, err := stmt.Exec(to, project, name) if err != nil { return errors.Wrap(err, "Rename profile") } n, err := result.RowsAffected() if err != nil { return errors.Wrap(err, "Fetch affected rows"...
go
func (c *ClusterTx) ProfileRename(project string, name string, to string) error { stmt := c.stmt(profileRename) result, err := stmt.Exec(to, project, name) if err != nil { return errors.Wrap(err, "Rename profile") } n, err := result.RowsAffected() if err != nil { return errors.Wrap(err, "Fetch affected rows"...
[ "func", "(", "c", "*", "ClusterTx", ")", "ProfileRename", "(", "project", "string", ",", "name", "string", ",", "to", "string", ")", "error", "{", "stmt", ":=", "c", ".", "stmt", "(", "profileRename", ")", "\n", "result", ",", "err", ":=", "stmt", "....
// ProfileRename renames the profile matching the given key parameters.
[ "ProfileRename", "renames", "the", "profile", "matching", "the", "given", "key", "parameters", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/profiles.mapper.go#L673-L688
test
lxc/lxd
lxd/db/profiles.mapper.go
ProfileDelete
func (c *ClusterTx) ProfileDelete(project string, name string) error { stmt := c.stmt(profileDelete) result, err := stmt.Exec(project, name) if err != nil { return errors.Wrap(err, "Delete profile") } n, err := result.RowsAffected() if err != nil { return errors.Wrap(err, "Fetch affected rows") } if n != 1...
go
func (c *ClusterTx) ProfileDelete(project string, name string) error { stmt := c.stmt(profileDelete) result, err := stmt.Exec(project, name) if err != nil { return errors.Wrap(err, "Delete profile") } n, err := result.RowsAffected() if err != nil { return errors.Wrap(err, "Fetch affected rows") } if n != 1...
[ "func", "(", "c", "*", "ClusterTx", ")", "ProfileDelete", "(", "project", "string", ",", "name", "string", ")", "error", "{", "stmt", ":=", "c", ".", "stmt", "(", "profileDelete", ")", "\n", "result", ",", "err", ":=", "stmt", ".", "Exec", "(", "proj...
// ProfileDelete deletes the profile matching the given key parameters.
[ "ProfileDelete", "deletes", "the", "profile", "matching", "the", "given", "key", "parameters", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/profiles.mapper.go#L691-L707
test
lxc/lxd
lxd/util/net.go
ServerTLSConfig
func ServerTLSConfig(cert *shared.CertInfo) *tls.Config { config := shared.InitTLSConfig() config.ClientAuth = tls.RequestClientCert config.Certificates = []tls.Certificate{cert.KeyPair()} config.NextProtos = []string{"h2"} // Required by gRPC if cert.CA() != nil { pool := x509.NewCertPool() pool.AddCert(cert...
go
func ServerTLSConfig(cert *shared.CertInfo) *tls.Config { config := shared.InitTLSConfig() config.ClientAuth = tls.RequestClientCert config.Certificates = []tls.Certificate{cert.KeyPair()} config.NextProtos = []string{"h2"} // Required by gRPC if cert.CA() != nil { pool := x509.NewCertPool() pool.AddCert(cert...
[ "func", "ServerTLSConfig", "(", "cert", "*", "shared", ".", "CertInfo", ")", "*", "tls", ".", "Config", "{", "config", ":=", "shared", ".", "InitTLSConfig", "(", ")", "\n", "config", ".", "ClientAuth", "=", "tls", ".", "RequestClientCert", "\n", "config", ...
// ServerTLSConfig returns a new server-side tls.Config generated from the give // certificate info.
[ "ServerTLSConfig", "returns", "a", "new", "server", "-", "side", "tls", ".", "Config", "generated", "from", "the", "give", "certificate", "info", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/util/net.go#L88-L105
test
lxc/lxd
lxd/util/net.go
NetworkInterfaceAddress
func NetworkInterfaceAddress() string { ifaces, err := net.Interfaces() if err != nil { return "" } for _, iface := range ifaces { if shared.IsLoopback(&iface) { continue } addrs, err := iface.Addrs() if err != nil { continue } if len(addrs) == 0 { continue } addr, ok := addrs[0].(*net.IP...
go
func NetworkInterfaceAddress() string { ifaces, err := net.Interfaces() if err != nil { return "" } for _, iface := range ifaces { if shared.IsLoopback(&iface) { continue } addrs, err := iface.Addrs() if err != nil { continue } if len(addrs) == 0 { continue } addr, ok := addrs[0].(*net.IP...
[ "func", "NetworkInterfaceAddress", "(", ")", "string", "{", "ifaces", ",", "err", ":=", "net", ".", "Interfaces", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"\"", "\n", "}", "\n", "for", "_", ",", "iface", ":=", "range", "ifaces", "{"...
// NetworkInterfaceAddress returns the first non-loopback address of any of the // system network interfaces. // // Return the empty string if none is found.
[ "NetworkInterfaceAddress", "returns", "the", "first", "non", "-", "loopback", "address", "of", "any", "of", "the", "system", "network", "interfaces", ".", "Return", "the", "empty", "string", "if", "none", "is", "found", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/util/net.go#L111-L134
test
lxc/lxd
lxd/util/net.go
IsAddressCovered
func IsAddressCovered(address1, address2 string) bool { if address1 == address2 { return true } host1, port1, err := net.SplitHostPort(address1) if err != nil { return false } host2, port2, err := net.SplitHostPort(address2) if err != nil { return false } // If the ports are different, then address1 i...
go
func IsAddressCovered(address1, address2 string) bool { if address1 == address2 { return true } host1, port1, err := net.SplitHostPort(address1) if err != nil { return false } host2, port2, err := net.SplitHostPort(address2) if err != nil { return false } // If the ports are different, then address1 i...
[ "func", "IsAddressCovered", "(", "address1", ",", "address2", "string", ")", "bool", "{", "if", "address1", "==", "address2", "{", "return", "true", "\n", "}", "\n", "host1", ",", "port1", ",", "err", ":=", "net", ".", "SplitHostPort", "(", "address1", "...
// IsAddressCovered detects if network address1 is actually covered by // address2, in the sense that they are either the same address or address2 is // specified using a wildcard with the same port of address1.
[ "IsAddressCovered", "detects", "if", "network", "address1", "is", "actually", "covered", "by", "address2", "in", "the", "sense", "that", "they", "are", "either", "the", "same", "address", "or", "address2", "is", "specified", "using", "a", "wildcard", "with", "...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/util/net.go#L139-L177
test
lxc/lxd
lxd/db/query/objects.go
SelectObjects
func SelectObjects(stmt *sql.Stmt, dest Dest, args ...interface{}) error { rows, err := stmt.Query(args...) if err != nil { return err } defer rows.Close() for i := 0; rows.Next(); i++ { err := rows.Scan(dest(i)...) if err != nil { return err } } err = rows.Err() if err != nil { return err } re...
go
func SelectObjects(stmt *sql.Stmt, dest Dest, args ...interface{}) error { rows, err := stmt.Query(args...) if err != nil { return err } defer rows.Close() for i := 0; rows.Next(); i++ { err := rows.Scan(dest(i)...) if err != nil { return err } } err = rows.Err() if err != nil { return err } re...
[ "func", "SelectObjects", "(", "stmt", "*", "sql", ".", "Stmt", ",", "dest", "Dest", ",", "args", "...", "interface", "{", "}", ")", "error", "{", "rows", ",", "err", ":=", "stmt", ".", "Query", "(", "args", "...", ")", "\n", "if", "err", "!=", "n...
// SelectObjects executes a statement which must yield rows with a specific // columns schema. It invokes the given Dest hook for each yielded row.
[ "SelectObjects", "executes", "a", "statement", "which", "must", "yield", "rows", "with", "a", "specific", "columns", "schema", ".", "It", "invokes", "the", "given", "Dest", "hook", "for", "each", "yielded", "row", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/query/objects.go#L11-L30
test
lxc/lxd
lxd/db/query/objects.go
DeleteObject
func DeleteObject(tx *sql.Tx, table string, id int64) (bool, error) { stmt := fmt.Sprintf("DELETE FROM %s WHERE id=?", table) result, err := tx.Exec(stmt, id) if err != nil { return false, err } n, err := result.RowsAffected() if err != nil { return false, err } if n > 1 { return true, fmt.Errorf("more th...
go
func DeleteObject(tx *sql.Tx, table string, id int64) (bool, error) { stmt := fmt.Sprintf("DELETE FROM %s WHERE id=?", table) result, err := tx.Exec(stmt, id) if err != nil { return false, err } n, err := result.RowsAffected() if err != nil { return false, err } if n > 1 { return true, fmt.Errorf("more th...
[ "func", "DeleteObject", "(", "tx", "*", "sql", ".", "Tx", ",", "table", "string", ",", "id", "int64", ")", "(", "bool", ",", "error", ")", "{", "stmt", ":=", "fmt", ".", "Sprintf", "(", "\"DELETE FROM %s WHERE id=?\"", ",", "table", ")", "\n", "result"...
// DeleteObject removes the row identified by the given ID. The given table // must have a primary key column called 'id'. // // It returns a flag indicating if a matching row was actually found and // deleted or not.
[ "DeleteObject", "removes", "the", "row", "identified", "by", "the", "given", "ID", ".", "The", "given", "table", "must", "have", "a", "primary", "key", "column", "called", "id", ".", "It", "returns", "a", "flag", "indicating", "if", "a", "matching", "row",...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/query/objects.go#L71-L85
test
lxc/lxd
lxd/task/task.go
loop
func (t *Task) loop(ctx context.Context) { // Kick off the task immediately (as long as the the schedule is // greater than zero, see below). delay := immediately for { var timer <-chan time.Time schedule, err := t.schedule() switch err { case ErrSkip: // Reset the delay to be exactly the schedule, so ...
go
func (t *Task) loop(ctx context.Context) { // Kick off the task immediately (as long as the the schedule is // greater than zero, see below). delay := immediately for { var timer <-chan time.Time schedule, err := t.schedule() switch err { case ErrSkip: // Reset the delay to be exactly the schedule, so ...
[ "func", "(", "t", "*", "Task", ")", "loop", "(", "ctx", "context", ".", "Context", ")", "{", "delay", ":=", "immediately", "\n", "for", "{", "var", "timer", "<-", "chan", "time", ".", "Time", "\n", "schedule", ",", "err", ":=", "t", ".", "schedule"...
// Execute the our task function according to our schedule, until the given // context gets cancelled.
[ "Execute", "the", "our", "task", "function", "according", "to", "our", "schedule", "until", "the", "given", "context", "gets", "cancelled", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/task/task.go#L28-L89
test
lxc/lxd
shared/termios/termios_unix.go
IsTerminal
func IsTerminal(fd int) bool { _, err := GetState(fd) return err == nil }
go
func IsTerminal(fd int) bool { _, err := GetState(fd) return err == nil }
[ "func", "IsTerminal", "(", "fd", "int", ")", "bool", "{", "_", ",", "err", ":=", "GetState", "(", "fd", ")", "\n", "return", "err", "==", "nil", "\n", "}" ]
// IsTerminal returns true if the given file descriptor is a terminal.
[ "IsTerminal", "returns", "true", "if", "the", "given", "file", "descriptor", "is", "a", "terminal", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/termios/termios_unix.go#L22-L25
test
lxc/lxd
lxd/endpoints/socket.go
socketUnixListen
func socketUnixListen(path string) (net.Listener, error) { addr, err := net.ResolveUnixAddr("unix", path) if err != nil { return nil, fmt.Errorf("cannot resolve socket address: %v", err) } listener, err := net.ListenUnix("unix", addr) if err != nil { return nil, fmt.Errorf("cannot bind socket: %v", err) } ...
go
func socketUnixListen(path string) (net.Listener, error) { addr, err := net.ResolveUnixAddr("unix", path) if err != nil { return nil, fmt.Errorf("cannot resolve socket address: %v", err) } listener, err := net.ListenUnix("unix", addr) if err != nil { return nil, fmt.Errorf("cannot bind socket: %v", err) } ...
[ "func", "socketUnixListen", "(", "path", "string", ")", "(", "net", ".", "Listener", ",", "error", ")", "{", "addr", ",", "err", ":=", "net", ".", "ResolveUnixAddr", "(", "\"unix\"", ",", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "n...
// Bind to the given unix socket path.
[ "Bind", "to", "the", "given", "unix", "socket", "path", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/endpoints/socket.go#L15-L28
test
lxc/lxd
lxd/endpoints/socket.go
socketUnixRemoveStale
func socketUnixRemoveStale(path string) error { // If there's no socket file at all, there's nothing to do. if !shared.PathExists(path) { return nil } logger.Debugf("Detected stale unix socket, deleting") err := os.Remove(path) if err != nil { return fmt.Errorf("could not delete stale local socket: %v", err)...
go
func socketUnixRemoveStale(path string) error { // If there's no socket file at all, there's nothing to do. if !shared.PathExists(path) { return nil } logger.Debugf("Detected stale unix socket, deleting") err := os.Remove(path) if err != nil { return fmt.Errorf("could not delete stale local socket: %v", err)...
[ "func", "socketUnixRemoveStale", "(", "path", "string", ")", "error", "{", "if", "!", "shared", ".", "PathExists", "(", "path", ")", "{", "return", "nil", "\n", "}", "\n", "logger", ".", "Debugf", "(", "\"Detected stale unix socket, deleting\"", ")", "\n", "...
// Remove any stale socket file at the given path.
[ "Remove", "any", "stale", "socket", "file", "at", "the", "given", "path", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/endpoints/socket.go#L62-L75
test
lxc/lxd
lxd/endpoints/socket.go
socketUnixSetPermissions
func socketUnixSetPermissions(path string, mode os.FileMode) error { err := os.Chmod(path, mode) if err != nil { return fmt.Errorf("cannot set permissions on local socket: %v", err) } return nil }
go
func socketUnixSetPermissions(path string, mode os.FileMode) error { err := os.Chmod(path, mode) if err != nil { return fmt.Errorf("cannot set permissions on local socket: %v", err) } return nil }
[ "func", "socketUnixSetPermissions", "(", "path", "string", ",", "mode", "os", ".", "FileMode", ")", "error", "{", "err", ":=", "os", ".", "Chmod", "(", "path", ",", "mode", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "("...
// Change the file mode of the given unix socket file,
[ "Change", "the", "file", "mode", "of", "the", "given", "unix", "socket", "file" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/endpoints/socket.go#L78-L84
test
lxc/lxd
lxd/endpoints/socket.go
socketUnixSetOwnership
func socketUnixSetOwnership(path string, group string) error { var gid int var err error if group != "" { gid, err = shared.GroupId(group) if err != nil { return fmt.Errorf("cannot get group ID of '%s': %v", group, err) } } else { gid = os.Getgid() } err = os.Chown(path, os.Getuid(), gid) if err != ...
go
func socketUnixSetOwnership(path string, group string) error { var gid int var err error if group != "" { gid, err = shared.GroupId(group) if err != nil { return fmt.Errorf("cannot get group ID of '%s': %v", group, err) } } else { gid = os.Getgid() } err = os.Chown(path, os.Getuid(), gid) if err != ...
[ "func", "socketUnixSetOwnership", "(", "path", "string", ",", "group", "string", ")", "error", "{", "var", "gid", "int", "\n", "var", "err", "error", "\n", "if", "group", "!=", "\"\"", "{", "gid", ",", "err", "=", "shared", ".", "GroupId", "(", "group"...
// Change the ownership of the given unix socket file,
[ "Change", "the", "ownership", "of", "the", "given", "unix", "socket", "file" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/endpoints/socket.go#L87-L107
test
lxc/lxd
lxd/storage_ceph_utils.go
cephOSDPoolExists
func cephOSDPoolExists(ClusterName string, poolName string, userName string) bool { _, err := shared.RunCommand( "ceph", "--name", fmt.Sprintf("client.%s", userName), "--cluster", ClusterName, "osd", "pool", "get", poolName, "size") if err != nil { return false } return true }
go
func cephOSDPoolExists(ClusterName string, poolName string, userName string) bool { _, err := shared.RunCommand( "ceph", "--name", fmt.Sprintf("client.%s", userName), "--cluster", ClusterName, "osd", "pool", "get", poolName, "size") if err != nil { return false } return true }
[ "func", "cephOSDPoolExists", "(", "ClusterName", "string", ",", "poolName", "string", ",", "userName", "string", ")", "bool", "{", "_", ",", "err", ":=", "shared", ".", "RunCommand", "(", "\"ceph\"", ",", "\"--name\"", ",", "fmt", ".", "Sprintf", "(", "\"c...
// cephOSDPoolExists checks whether a given OSD pool exists.
[ "cephOSDPoolExists", "checks", "whether", "a", "given", "OSD", "pool", "exists", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage_ceph_utils.go#L22-L37
test
lxc/lxd
lxd/storage_ceph_utils.go
cephOSDPoolDestroy
func cephOSDPoolDestroy(clusterName string, poolName string, userName string) error { _, err := shared.RunCommand("ceph", "--name", fmt.Sprintf("client.%s", userName), "--cluster", clusterName, "osd", "pool", "delete", poolName, poolName, "--yes-i-really-really-mean-it") if err != nil { return err ...
go
func cephOSDPoolDestroy(clusterName string, poolName string, userName string) error { _, err := shared.RunCommand("ceph", "--name", fmt.Sprintf("client.%s", userName), "--cluster", clusterName, "osd", "pool", "delete", poolName, poolName, "--yes-i-really-really-mean-it") if err != nil { return err ...
[ "func", "cephOSDPoolDestroy", "(", "clusterName", "string", ",", "poolName", "string", ",", "userName", "string", ")", "error", "{", "_", ",", "err", ":=", "shared", ".", "RunCommand", "(", "\"ceph\"", ",", "\"--name\"", ",", "fmt", ".", "Sprintf", "(", "\...
// cephOSDPoolDestroy destroys an OSD pool. // - A call to cephOSDPoolDestroy will destroy a pool including any storage // volumes that still exist in the pool. // - In case the OSD pool that is supposed to be deleted does not exist this // command will still exit 0. This means that if the caller wants to be sure /...
[ "cephOSDPoolDestroy", "destroys", "an", "OSD", "pool", ".", "-", "A", "call", "to", "cephOSDPoolDestroy", "will", "destroy", "a", "pool", "including", "any", "storage", "volumes", "that", "still", "exist", "in", "the", "pool", ".", "-", "In", "case", "the", ...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage_ceph_utils.go#L46-L61
test
lxc/lxd
lxd/storage_ceph_utils.go
cephRBDVolumeExists
func cephRBDVolumeExists(clusterName string, poolName string, volumeName string, volumeType string, userName string) bool { _, err := shared.RunCommand( "rbd", "--id", userName, "--cluster", clusterName, "--pool", poolName, "image-meta", "list", fmt.Sprintf("%s_%s", volumeType, volumeName)) if err != n...
go
func cephRBDVolumeExists(clusterName string, poolName string, volumeName string, volumeType string, userName string) bool { _, err := shared.RunCommand( "rbd", "--id", userName, "--cluster", clusterName, "--pool", poolName, "image-meta", "list", fmt.Sprintf("%s_%s", volumeType, volumeName)) if err != n...
[ "func", "cephRBDVolumeExists", "(", "clusterName", "string", ",", "poolName", "string", ",", "volumeName", "string", ",", "volumeType", "string", ",", "userName", "string", ")", "bool", "{", "_", ",", "err", ":=", "shared", ".", "RunCommand", "(", "\"rbd\"", ...
// cephRBDVolumeExists checks whether a given RBD storage volume exists.
[ "cephRBDVolumeExists", "checks", "whether", "a", "given", "RBD", "storage", "volume", "exists", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage_ceph_utils.go#L84-L98
test
lxc/lxd
lxd/storage_ceph_utils.go
cephRBDSnapshotProtect
func cephRBDSnapshotProtect(clusterName string, poolName string, volumeName string, volumeType string, snapshotName string, userName string) error { _, err := shared.RunCommand( "rbd", "--id", userName, "--cluster", clusterName, "--pool", poolName, "snap", "protect", "--snap", snapshotName, fmt.Sprin...
go
func cephRBDSnapshotProtect(clusterName string, poolName string, volumeName string, volumeType string, snapshotName string, userName string) error { _, err := shared.RunCommand( "rbd", "--id", userName, "--cluster", clusterName, "--pool", poolName, "snap", "protect", "--snap", snapshotName, fmt.Sprin...
[ "func", "cephRBDSnapshotProtect", "(", "clusterName", "string", ",", "poolName", "string", ",", "volumeName", "string", ",", "volumeType", "string", ",", "snapshotName", "string", ",", "userName", "string", ")", "error", "{", "_", ",", "err", ":=", "shared", "...
// cephRBDSnapshotProtect protects a given snapshot from being deleted // This is a precondition to be able to create RBD clones from a given snapshot.
[ "cephRBDSnapshotProtect", "protects", "a", "given", "snapshot", "from", "being", "deleted", "This", "is", "a", "precondition", "to", "be", "able", "to", "create", "RBD", "clones", "from", "a", "given", "snapshot", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage_ceph_utils.go#L279-L307
test
lxc/lxd
lxd/storage_ceph_utils.go
cephRBDCloneCreate
func cephRBDCloneCreate(sourceClusterName string, sourcePoolName string, sourceVolumeName string, sourceVolumeType string, sourceSnapshotName string, targetPoolName string, targetVolumeName string, targetVolumeType string, userName string) error { _, err := shared.RunCommand( "rbd", "--id", userName, "--clus...
go
func cephRBDCloneCreate(sourceClusterName string, sourcePoolName string, sourceVolumeName string, sourceVolumeType string, sourceSnapshotName string, targetPoolName string, targetVolumeName string, targetVolumeType string, userName string) error { _, err := shared.RunCommand( "rbd", "--id", userName, "--clus...
[ "func", "cephRBDCloneCreate", "(", "sourceClusterName", "string", ",", "sourcePoolName", "string", ",", "sourceVolumeName", "string", ",", "sourceVolumeType", "string", ",", "sourceSnapshotName", "string", ",", "targetPoolName", "string", ",", "targetVolumeName", "string"...
// cephRBDCloneCreate creates a clone from a protected RBD snapshot
[ "cephRBDCloneCreate", "creates", "a", "clone", "from", "a", "protected", "RBD", "snapshot" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage_ceph_utils.go#L343-L363
test
lxc/lxd
lxd/storage_ceph_utils.go
cephRBDSnapshotListClones
func cephRBDSnapshotListClones(clusterName string, poolName string, volumeName string, volumeType string, snapshotName string, userName string) ([]string, error) { msg, err := shared.RunCommand( "rbd", "--id", userName, "--cluster", clusterName, "--pool", poolName, "children", "--image", fmt.Sprintf("%s_...
go
func cephRBDSnapshotListClones(clusterName string, poolName string, volumeName string, volumeType string, snapshotName string, userName string) ([]string, error) { msg, err := shared.RunCommand( "rbd", "--id", userName, "--cluster", clusterName, "--pool", poolName, "children", "--image", fmt.Sprintf("%s_...
[ "func", "cephRBDSnapshotListClones", "(", "clusterName", "string", ",", "poolName", "string", ",", "volumeName", "string", ",", "volumeType", "string", ",", "snapshotName", "string", ",", "userName", "string", ")", "(", "[", "]", "string", ",", "error", ")", "...
// cephRBDSnapshotListClones list all clones of an RBD snapshot
[ "cephRBDSnapshotListClones", "list", "all", "clones", "of", "an", "RBD", "snapshot" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage_ceph_utils.go#L366-L388
test
lxc/lxd
lxd/storage_ceph_utils.go
cephRBDVolumeMarkDeleted
func cephRBDVolumeMarkDeleted(clusterName string, poolName string, volumeType string, oldVolumeName string, newVolumeName string, userName string, suffix string) error { deletedName := fmt.Sprintf("%s/zombie_%s_%s", poolName, volumeType, newVolumeName) if suffix != "" { deletedName = fmt.Sprintf("%s_%s", delete...
go
func cephRBDVolumeMarkDeleted(clusterName string, poolName string, volumeType string, oldVolumeName string, newVolumeName string, userName string, suffix string) error { deletedName := fmt.Sprintf("%s/zombie_%s_%s", poolName, volumeType, newVolumeName) if suffix != "" { deletedName = fmt.Sprintf("%s_%s", delete...
[ "func", "cephRBDVolumeMarkDeleted", "(", "clusterName", "string", ",", "poolName", "string", ",", "volumeType", "string", ",", "oldVolumeName", "string", ",", "newVolumeName", "string", ",", "userName", "string", ",", "suffix", "string", ")", "error", "{", "delete...
// cephRBDVolumeMarkDeleted marks an RBD storage volume as being in "zombie" // state // An RBD storage volume that is in zombie state is not tracked in LXD's // database anymore but still needs to be kept around for the sake of any // dependent storage entities in the storage pool. This usually happens when an // RBD ...
[ "cephRBDVolumeMarkDeleted", "marks", "an", "RBD", "storage", "volume", "as", "being", "in", "zombie", "state", "An", "RBD", "storage", "volume", "that", "is", "in", "zombie", "state", "is", "not", "tracked", "in", "LXD", "s", "database", "anymore", "but", "s...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage_ceph_utils.go#L398-L418
test
lxc/lxd
lxd/storage_ceph_utils.go
cephRBDVolumeUnmarkDeleted
func cephRBDVolumeUnmarkDeleted(clusterName string, poolName string, volumeName string, volumeType string, userName string, oldSuffix string, newSuffix string) error { oldName := fmt.Sprintf("%s/zombie_%s_%s", poolName, volumeType, volumeName) if oldSuffix != "" { oldName = fmt.Sprintf("%s_%s", oldName, oldSuffix...
go
func cephRBDVolumeUnmarkDeleted(clusterName string, poolName string, volumeName string, volumeType string, userName string, oldSuffix string, newSuffix string) error { oldName := fmt.Sprintf("%s/zombie_%s_%s", poolName, volumeType, volumeName) if oldSuffix != "" { oldName = fmt.Sprintf("%s_%s", oldName, oldSuffix...
[ "func", "cephRBDVolumeUnmarkDeleted", "(", "clusterName", "string", ",", "poolName", "string", ",", "volumeName", "string", ",", "volumeType", "string", ",", "userName", "string", ",", "oldSuffix", "string", ",", "newSuffix", "string", ")", "error", "{", "oldName"...
// cephRBDVolumeUnmarkDeleted unmarks an RBD storage volume as being in "zombie" // state // - An RBD storage volume that is in zombie is not tracked in LXD's database // anymore but still needs to be kept around for the sake of any dependent // storage entities in the storage pool. // - This function is mostly use...
[ "cephRBDVolumeUnmarkDeleted", "unmarks", "an", "RBD", "storage", "volume", "as", "being", "in", "zombie", "state", "-", "An", "RBD", "storage", "volume", "that", "is", "in", "zombie", "is", "not", "tracked", "in", "LXD", "s", "database", "anymore", "but", "s...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage_ceph_utils.go#L430-L455
test
lxc/lxd
lxd/storage_ceph_utils.go
cephRBDVolumeRename
func cephRBDVolumeRename(clusterName string, poolName string, volumeType string, oldVolumeName string, newVolumeName string, userName string) error { _, err := shared.RunCommand( "rbd", "--id", userName, "--cluster", clusterName, "mv", fmt.Sprintf("%s/%s_%s", poolName, volumeType, oldVolumeName), fmt.Spri...
go
func cephRBDVolumeRename(clusterName string, poolName string, volumeType string, oldVolumeName string, newVolumeName string, userName string) error { _, err := shared.RunCommand( "rbd", "--id", userName, "--cluster", clusterName, "mv", fmt.Sprintf("%s/%s_%s", poolName, volumeType, oldVolumeName), fmt.Spri...
[ "func", "cephRBDVolumeRename", "(", "clusterName", "string", ",", "poolName", "string", ",", "volumeType", "string", ",", "oldVolumeName", "string", ",", "newVolumeName", "string", ",", "userName", "string", ")", "error", "{", "_", ",", "err", ":=", "shared", ...
// cephRBDVolumeRename renames a given RBD storage volume // Note that this usually requires that the image be unmapped under its original // name, then renamed, and finally will be remapped again. If it is not unmapped // under its original name and the callers maps it under its new name the image // will be mapped tw...
[ "cephRBDVolumeRename", "renames", "a", "given", "RBD", "storage", "volume", "Note", "that", "this", "usually", "requires", "that", "the", "image", "be", "unmapped", "under", "its", "original", "name", "then", "renamed", "and", "finally", "will", "be", "remapped"...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage_ceph_utils.go#L462-L476
test
lxc/lxd
lxd/storage_ceph_utils.go
cephRBDVolumeSnapshotRename
func cephRBDVolumeSnapshotRename(clusterName string, poolName string, volumeName string, volumeType string, oldSnapshotName string, newSnapshotName string, userName string) error { _, err := shared.RunCommand( "rbd", "--id", userName, "--cluster", clusterName, "snap", "rename", fmt.Sprintf("%s/%s_%s@%s",...
go
func cephRBDVolumeSnapshotRename(clusterName string, poolName string, volumeName string, volumeType string, oldSnapshotName string, newSnapshotName string, userName string) error { _, err := shared.RunCommand( "rbd", "--id", userName, "--cluster", clusterName, "snap", "rename", fmt.Sprintf("%s/%s_%s@%s",...
[ "func", "cephRBDVolumeSnapshotRename", "(", "clusterName", "string", ",", "poolName", "string", ",", "volumeName", "string", ",", "volumeType", "string", ",", "oldSnapshotName", "string", ",", "newSnapshotName", "string", ",", "userName", "string", ")", "error", "{"...
// cephRBDVolumeRename renames a given RBD storage volume // Note that if the snapshot is mapped - which it usually shouldn't be - this // usually requires that the snapshot be unmapped under its original name, then // renamed, and finally will be remapped again. If it is not unmapped under its // original name and the...
[ "cephRBDVolumeRename", "renames", "a", "given", "RBD", "storage", "volume", "Note", "that", "if", "the", "snapshot", "is", "mapped", "-", "which", "it", "usually", "shouldn", "t", "be", "-", "this", "usually", "requires", "that", "the", "snapshot", "be", "un...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage_ceph_utils.go#L484-L502
test
lxc/lxd
lxd/storage_ceph_utils.go
cephRBDSnapshotDelete
func cephRBDSnapshotDelete(clusterName string, poolName string, volumeName string, volumeType string, snapshotName string, userName string) error { _, err := shared.RunCommand( "rbd", "--id", userName, "--cluster", clusterName, "--pool", poolName, "snap", "rm", fmt.Sprintf("%s_%s@%s", volumeType, volum...
go
func cephRBDSnapshotDelete(clusterName string, poolName string, volumeName string, volumeType string, snapshotName string, userName string) error { _, err := shared.RunCommand( "rbd", "--id", userName, "--cluster", clusterName, "--pool", poolName, "snap", "rm", fmt.Sprintf("%s_%s@%s", volumeType, volum...
[ "func", "cephRBDSnapshotDelete", "(", "clusterName", "string", ",", "poolName", "string", ",", "volumeName", "string", ",", "volumeType", "string", ",", "snapshotName", "string", ",", "userName", "string", ")", "error", "{", "_", ",", "err", ":=", "shared", "....
// cephRBDSnapshotDelete deletes an RBD snapshot // This requires that the snapshot does not have any clones and is unmapped and // unprotected.
[ "cephRBDSnapshotDelete", "deletes", "an", "RBD", "snapshot", "This", "requires", "that", "the", "snapshot", "does", "not", "have", "any", "clones", "and", "is", "unmapped", "and", "unprotected", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage_ceph_utils.go#L547-L563
test
lxc/lxd
lxd/storage_ceph_utils.go
cephRBDVolumeCopy
func cephRBDVolumeCopy(clusterName string, oldVolumeName string, newVolumeName string, userName string) error { _, err := shared.RunCommand( "rbd", "--id", userName, "--cluster", clusterName, "cp", oldVolumeName, newVolumeName) if err != nil { return err } return nil }
go
func cephRBDVolumeCopy(clusterName string, oldVolumeName string, newVolumeName string, userName string) error { _, err := shared.RunCommand( "rbd", "--id", userName, "--cluster", clusterName, "cp", oldVolumeName, newVolumeName) if err != nil { return err } return nil }
[ "func", "cephRBDVolumeCopy", "(", "clusterName", "string", ",", "oldVolumeName", "string", ",", "newVolumeName", "string", ",", "userName", "string", ")", "error", "{", "_", ",", "err", ":=", "shared", ".", "RunCommand", "(", "\"rbd\"", ",", "\"--id\"", ",", ...
// cephRBDVolumeCopy copies an RBD storage volume // This is a non-sparse copy which doesn't introduce any dependency relationship // between the source RBD storage volume and the target RBD storage volume. The // operations is similar to creating an empty RBD storage volume and rsyncing // the contents of the source R...
[ "cephRBDVolumeCopy", "copies", "an", "RBD", "storage", "volume", "This", "is", "a", "non", "-", "sparse", "copy", "which", "doesn", "t", "introduce", "any", "dependency", "relationship", "between", "the", "source", "RBD", "storage", "volume", "and", "the", "ta...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage_ceph_utils.go#L570-L584
test
lxc/lxd
lxd/storage_ceph_utils.go
cephRBDVolumeListSnapshots
func cephRBDVolumeListSnapshots(clusterName string, poolName string, volumeName string, volumeType string, userName string) ([]string, error) { msg, err := shared.RunCommand( "rbd", "--id", userName, "--format", "json", "--cluster", clusterName, "--pool", poolName, "snap", "ls", fmt.Sprintf("%s_%s", vo...
go
func cephRBDVolumeListSnapshots(clusterName string, poolName string, volumeName string, volumeType string, userName string) ([]string, error) { msg, err := shared.RunCommand( "rbd", "--id", userName, "--format", "json", "--cluster", clusterName, "--pool", poolName, "snap", "ls", fmt.Sprintf("%s_%s", vo...
[ "func", "cephRBDVolumeListSnapshots", "(", "clusterName", "string", ",", "poolName", "string", ",", "volumeName", "string", ",", "volumeType", "string", ",", "userName", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "msg", ",", "err", ":=",...
// cephRBDVolumeListSnapshots retrieves the snapshots of an RBD storage volume // The format of the snapshot names is simply the part after the @. So given a // valid RBD path relative to a pool // <osd-pool-name>/<rbd-storage-volume>@<rbd-snapshot-name> // this will only return // <rbd-snapshot-name>
[ "cephRBDVolumeListSnapshots", "retrieves", "the", "snapshots", "of", "an", "RBD", "storage", "volume", "The", "format", "of", "the", "snapshot", "names", "is", "simply", "the", "part", "after", "the" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage_ceph_utils.go#L592-L634
test
lxc/lxd
lxd/storage_ceph_utils.go
getRBDSize
func (s *storageCeph) getRBDSize() (string, error) { sz, err := shared.ParseByteSizeString(s.volume.Config["size"]) if err != nil { return "", err } // Safety net: Set to default value. if sz == 0 { sz, _ = shared.ParseByteSizeString("10GB") } return fmt.Sprintf("%dB", sz), nil }
go
func (s *storageCeph) getRBDSize() (string, error) { sz, err := shared.ParseByteSizeString(s.volume.Config["size"]) if err != nil { return "", err } // Safety net: Set to default value. if sz == 0 { sz, _ = shared.ParseByteSizeString("10GB") } return fmt.Sprintf("%dB", sz), nil }
[ "func", "(", "s", "*", "storageCeph", ")", "getRBDSize", "(", ")", "(", "string", ",", "error", ")", "{", "sz", ",", "err", ":=", "shared", ".", "ParseByteSizeString", "(", "s", ".", "volume", ".", "Config", "[", "\"size\"", "]", ")", "\n", "if", "...
// getRBDSize returns the size the RBD storage volume is supposed to be created // with
[ "getRBDSize", "returns", "the", "size", "the", "RBD", "storage", "volume", "is", "supposed", "to", "be", "created", "with" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage_ceph_utils.go#L658-L670
test
lxc/lxd
lxd/storage_ceph_utils.go
getRBDFilesystem
func (s *storageCeph) getRBDFilesystem() string { if s.volume.Config["block.filesystem"] != "" { return s.volume.Config["block.filesystem"] } if s.pool.Config["volume.block.filesystem"] != "" { return s.pool.Config["volume.block.filesystem"] } return "ext4" }
go
func (s *storageCeph) getRBDFilesystem() string { if s.volume.Config["block.filesystem"] != "" { return s.volume.Config["block.filesystem"] } if s.pool.Config["volume.block.filesystem"] != "" { return s.pool.Config["volume.block.filesystem"] } return "ext4" }
[ "func", "(", "s", "*", "storageCeph", ")", "getRBDFilesystem", "(", ")", "string", "{", "if", "s", ".", "volume", ".", "Config", "[", "\"block.filesystem\"", "]", "!=", "\"\"", "{", "return", "s", ".", "volume", ".", "Config", "[", "\"block.filesystem\"", ...
// getRBDFilesystem returns the filesystem the RBD storage volume is supposed to // be created with
[ "getRBDFilesystem", "returns", "the", "filesystem", "the", "RBD", "storage", "volume", "is", "supposed", "to", "be", "created", "with" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage_ceph_utils.go#L674-L684
test
lxc/lxd
lxd/storage_ceph_utils.go
copyWithoutSnapshotsFull
func (s *storageCeph) copyWithoutSnapshotsFull(target container, source container) error { logger.Debugf(`Creating non-sparse copy of RBD storage volume for container "%s" to "%s" without snapshots`, source.Name(), target.Name()) sourceIsSnapshot := source.IsSnapshot() sourceContainerName := projectPrefix(source.P...
go
func (s *storageCeph) copyWithoutSnapshotsFull(target container, source container) error { logger.Debugf(`Creating non-sparse copy of RBD storage volume for container "%s" to "%s" without snapshots`, source.Name(), target.Name()) sourceIsSnapshot := source.IsSnapshot() sourceContainerName := projectPrefix(source.P...
[ "func", "(", "s", "*", "storageCeph", ")", "copyWithoutSnapshotsFull", "(", "target", "container", ",", "source", "container", ")", "error", "{", "logger", ".", "Debugf", "(", "`Creating non-sparse copy of RBD storage volume for container \"%s\" to \"%s\" without snapshots`",...
// copyWithoutSnapshotsFull creates a non-sparse copy of a container // This does not introduce a dependency relation between the source RBD storage // volume and the target RBD storage volume.
[ "copyWithoutSnapshotsFull", "creates", "a", "non", "-", "sparse", "copy", "of", "a", "container", "This", "does", "not", "introduce", "a", "dependency", "relation", "between", "the", "source", "RBD", "storage", "volume", "and", "the", "target", "RBD", "storage",...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage_ceph_utils.go#L710-L767
test
lxc/lxd
lxd/storage_ceph_utils.go
copyWithoutSnapshotsSparse
func (s *storageCeph) copyWithoutSnapshotsSparse(target container, source container) error { logger.Debugf(`Creating sparse copy of RBD storage volume for container "%s" to "%s" without snapshots`, source.Name(), target.Name()) sourceIsSnapshot := source.IsSnapshot() sourceContainerName := projectPrefix(source.P...
go
func (s *storageCeph) copyWithoutSnapshotsSparse(target container, source container) error { logger.Debugf(`Creating sparse copy of RBD storage volume for container "%s" to "%s" without snapshots`, source.Name(), target.Name()) sourceIsSnapshot := source.IsSnapshot() sourceContainerName := projectPrefix(source.P...
[ "func", "(", "s", "*", "storageCeph", ")", "copyWithoutSnapshotsSparse", "(", "target", "container", ",", "source", "container", ")", "error", "{", "logger", ".", "Debugf", "(", "`Creating sparse copy of RBD storage volume for container \"%s\" to \"%s\" without snapshots`", ...
// copyWithoutSnapshotsFull creates a sparse copy of a container // This introduces a dependency relation between the source RBD storage volume // and the target RBD storage volume.
[ "copyWithoutSnapshotsFull", "creates", "a", "sparse", "copy", "of", "a", "container", "This", "introduces", "a", "dependency", "relation", "between", "the", "source", "RBD", "storage", "volume", "and", "the", "target", "RBD", "storage", "volume", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage_ceph_utils.go#L772-L848
test
pachyderm/pachyderm
src/server/auth/cmds/configure.go
GetConfigCmd
func GetConfigCmd(noPortForwarding *bool) *cobra.Command { var format string getConfig := &cobra.Command{ Short: "Retrieve Pachyderm's current auth configuration", Long: "Retrieve Pachyderm's current auth configuration", Run: cmdutil.RunFixedArgs(0, func(args []string) error { c, err := client.NewOnUserMach...
go
func GetConfigCmd(noPortForwarding *bool) *cobra.Command { var format string getConfig := &cobra.Command{ Short: "Retrieve Pachyderm's current auth configuration", Long: "Retrieve Pachyderm's current auth configuration", Run: cmdutil.RunFixedArgs(0, func(args []string) error { c, err := client.NewOnUserMach...
[ "func", "GetConfigCmd", "(", "noPortForwarding", "*", "bool", ")", "*", "cobra", ".", "Command", "{", "var", "format", "string", "\n", "getConfig", ":=", "&", "cobra", ".", "Command", "{", "Short", ":", "\"Retrieve Pachyderm's current auth configuration\"", ",", ...
// GetConfigCmd returns a cobra command that lets the caller see the configured // auth backends in Pachyderm
[ "GetConfigCmd", "returns", "a", "cobra", "command", "that", "lets", "the", "caller", "see", "the", "configured", "auth", "backends", "in", "Pachyderm" ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/auth/cmds/configure.go#L21-L62
test
pachyderm/pachyderm
src/server/auth/cmds/configure.go
SetConfigCmd
func SetConfigCmd(noPortForwarding *bool) *cobra.Command { var file string setConfig := &cobra.Command{ Short: "Set Pachyderm's current auth configuration", Long: "Set Pachyderm's current auth configuration", Run: cmdutil.RunFixedArgs(0, func(args []string) error { c, err := client.NewOnUserMachine(true, !*...
go
func SetConfigCmd(noPortForwarding *bool) *cobra.Command { var file string setConfig := &cobra.Command{ Short: "Set Pachyderm's current auth configuration", Long: "Set Pachyderm's current auth configuration", Run: cmdutil.RunFixedArgs(0, func(args []string) error { c, err := client.NewOnUserMachine(true, !*...
[ "func", "SetConfigCmd", "(", "noPortForwarding", "*", "bool", ")", "*", "cobra", ".", "Command", "{", "var", "file", "string", "\n", "setConfig", ":=", "&", "cobra", ".", "Command", "{", "Short", ":", "\"Set Pachyderm's current auth configuration\"", ",", "Long"...
// SetConfigCmd returns a cobra command that lets the caller configure auth // backends in Pachyderm
[ "SetConfigCmd", "returns", "a", "cobra", "command", "that", "lets", "the", "caller", "configure", "auth", "backends", "in", "Pachyderm" ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/auth/cmds/configure.go#L66-L109
test
pachyderm/pachyderm
src/client/pkg/shard/shard.go
NewSharder
func NewSharder(discoveryClient discovery.Client, numShards uint64, namespace string) Sharder { return newSharder(discoveryClient, numShards, namespace) }
go
func NewSharder(discoveryClient discovery.Client, numShards uint64, namespace string) Sharder { return newSharder(discoveryClient, numShards, namespace) }
[ "func", "NewSharder", "(", "discoveryClient", "discovery", ".", "Client", ",", "numShards", "uint64", ",", "namespace", "string", ")", "Sharder", "{", "return", "newSharder", "(", "discoveryClient", ",", "numShards", ",", "namespace", ")", "\n", "}" ]
// NewSharder creates a Sharder using a discovery client.
[ "NewSharder", "creates", "a", "Sharder", "using", "a", "discovery", "client", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pkg/shard/shard.go#L20-L22
test
pachyderm/pachyderm
src/client/pkg/shard/shard.go
NewRouter
func NewRouter( sharder Sharder, dialer grpcutil.Dialer, localAddress string, ) Router { return newRouter( sharder, dialer, localAddress, ) }
go
func NewRouter( sharder Sharder, dialer grpcutil.Dialer, localAddress string, ) Router { return newRouter( sharder, dialer, localAddress, ) }
[ "func", "NewRouter", "(", "sharder", "Sharder", ",", "dialer", "grpcutil", ".", "Dialer", ",", "localAddress", "string", ",", ")", "Router", "{", "return", "newRouter", "(", "sharder", ",", "dialer", ",", "localAddress", ",", ")", "\n", "}" ]
// NewRouter creates a Router.
[ "NewRouter", "creates", "a", "Router", "." ]
94fb2d536cb6852a77a49e8f777dc9c1bde2c723
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pkg/shard/shard.go#L53-L63
test