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
client/lxd_certificates.go
GetCertificate
func (r *ProtocolLXD) GetCertificate(fingerprint string) (*api.Certificate, string, error) { certificate := api.Certificate{} // Fetch the raw value etag, err := r.queryStruct("GET", fmt.Sprintf("/certificates/%s", url.QueryEscape(fingerprint)), nil, "", &certificate) if err != nil { return nil, "", err } ret...
go
func (r *ProtocolLXD) GetCertificate(fingerprint string) (*api.Certificate, string, error) { certificate := api.Certificate{} // Fetch the raw value etag, err := r.queryStruct("GET", fmt.Sprintf("/certificates/%s", url.QueryEscape(fingerprint)), nil, "", &certificate) if err != nil { return nil, "", err } ret...
[ "func", "(", "r", "*", "ProtocolLXD", ")", "GetCertificate", "(", "fingerprint", "string", ")", "(", "*", "api", ".", "Certificate", ",", "string", ",", "error", ")", "{", "certificate", ":=", "api", ".", "Certificate", "{", "}", "\n", "etag", ",", "er...
// GetCertificate returns the certificate entry for the provided fingerprint
[ "GetCertificate", "returns", "the", "certificate", "entry", "for", "the", "provided", "fingerprint" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_certificates.go#L47-L57
test
lxc/lxd
client/lxd_certificates.go
CreateCertificate
func (r *ProtocolLXD) CreateCertificate(certificate api.CertificatesPost) error { // Send the request _, _, err := r.query("POST", "/certificates", certificate, "") if err != nil { return err } return nil }
go
func (r *ProtocolLXD) CreateCertificate(certificate api.CertificatesPost) error { // Send the request _, _, err := r.query("POST", "/certificates", certificate, "") if err != nil { return err } return nil }
[ "func", "(", "r", "*", "ProtocolLXD", ")", "CreateCertificate", "(", "certificate", "api", ".", "CertificatesPost", ")", "error", "{", "_", ",", "_", ",", "err", ":=", "r", ".", "query", "(", "\"POST\"", ",", "\"/certificates\"", ",", "certificate", ",", ...
// CreateCertificate adds a new certificate to the LXD trust store
[ "CreateCertificate", "adds", "a", "new", "certificate", "to", "the", "LXD", "trust", "store" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_certificates.go#L60-L68
test
lxc/lxd
client/lxd_certificates.go
UpdateCertificate
func (r *ProtocolLXD) UpdateCertificate(fingerprint string, certificate api.CertificatePut, ETag string) error { if !r.HasExtension("certificate_update") { return fmt.Errorf("The server is missing the required \"certificate_update\" API extension") } // Send the request _, _, err := r.query("PUT", fmt.Sprintf("/...
go
func (r *ProtocolLXD) UpdateCertificate(fingerprint string, certificate api.CertificatePut, ETag string) error { if !r.HasExtension("certificate_update") { return fmt.Errorf("The server is missing the required \"certificate_update\" API extension") } // Send the request _, _, err := r.query("PUT", fmt.Sprintf("/...
[ "func", "(", "r", "*", "ProtocolLXD", ")", "UpdateCertificate", "(", "fingerprint", "string", ",", "certificate", "api", ".", "CertificatePut", ",", "ETag", "string", ")", "error", "{", "if", "!", "r", ".", "HasExtension", "(", "\"certificate_update\"", ")", ...
// UpdateCertificate updates the certificate definition
[ "UpdateCertificate", "updates", "the", "certificate", "definition" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_certificates.go#L71-L83
test
lxc/lxd
client/lxd_certificates.go
DeleteCertificate
func (r *ProtocolLXD) DeleteCertificate(fingerprint string) error { // Send the request _, _, err := r.query("DELETE", fmt.Sprintf("/certificates/%s", url.QueryEscape(fingerprint)), nil, "") if err != nil { return err } return nil }
go
func (r *ProtocolLXD) DeleteCertificate(fingerprint string) error { // Send the request _, _, err := r.query("DELETE", fmt.Sprintf("/certificates/%s", url.QueryEscape(fingerprint)), nil, "") if err != nil { return err } return nil }
[ "func", "(", "r", "*", "ProtocolLXD", ")", "DeleteCertificate", "(", "fingerprint", "string", ")", "error", "{", "_", ",", "_", ",", "err", ":=", "r", ".", "query", "(", "\"DELETE\"", ",", "fmt", ".", "Sprintf", "(", "\"/certificates/%s\"", ",", "url", ...
// DeleteCertificate removes a certificate from the LXD trust store
[ "DeleteCertificate", "removes", "a", "certificate", "from", "the", "LXD", "trust", "store" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_certificates.go#L86-L94
test
lxc/lxd
lxd/container_metadata.go
containerMetadataTemplatesGet
func containerMetadataTemplatesGet(d *Daemon, r *http.Request) Response { project := projectParam(r) name := mux.Vars(r)["name"] // Handle requests targeted to a container on a different node response, err := ForwardedResponseIfContainerIsRemote(d, r, project, name) if err != nil { return SmartError(err) } if...
go
func containerMetadataTemplatesGet(d *Daemon, r *http.Request) Response { project := projectParam(r) name := mux.Vars(r)["name"] // Handle requests targeted to a container on a different node response, err := ForwardedResponseIfContainerIsRemote(d, r, project, name) if err != nil { return SmartError(err) } if...
[ "func", "containerMetadataTemplatesGet", "(", "d", "*", "Daemon", ",", "r", "*", "http", ".", "Request", ")", "Response", "{", "project", ":=", "projectParam", "(", "r", ")", "\n", "name", ":=", "mux", ".", "Vars", "(", "r", ")", "[", "\"name\"", "]", ...
// Return a list of templates used in a container or the content of a template
[ "Return", "a", "list", "of", "templates", "used", "in", "a", "container", "or", "the", "content", "of", "a", "template" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/container_metadata.go#L121-L203
test
lxc/lxd
lxd/container_metadata.go
containerMetadataTemplatesPostPut
func containerMetadataTemplatesPostPut(d *Daemon, r *http.Request) Response { project := projectParam(r) name := mux.Vars(r)["name"] // Handle requests targeted to a container on a different node response, err := ForwardedResponseIfContainerIsRemote(d, r, project, name) if err != nil { return SmartError(err) }...
go
func containerMetadataTemplatesPostPut(d *Daemon, r *http.Request) Response { project := projectParam(r) name := mux.Vars(r)["name"] // Handle requests targeted to a container on a different node response, err := ForwardedResponseIfContainerIsRemote(d, r, project, name) if err != nil { return SmartError(err) }...
[ "func", "containerMetadataTemplatesPostPut", "(", "d", "*", "Daemon", ",", "r", "*", "http", ".", "Request", ")", "Response", "{", "project", ":=", "projectParam", "(", "r", ")", "\n", "name", ":=", "mux", ".", "Vars", "(", "r", ")", "[", "\"name\"", "...
// Add a container template file
[ "Add", "a", "container", "template", "file" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/container_metadata.go#L206-L263
test
lxc/lxd
lxd/container_metadata.go
containerMetadataTemplatesDelete
func containerMetadataTemplatesDelete(d *Daemon, r *http.Request) Response { project := projectParam(r) name := mux.Vars(r)["name"] // Handle requests targeted to a container on a different node response, err := ForwardedResponseIfContainerIsRemote(d, r, project, name) if err != nil { return SmartError(err) }...
go
func containerMetadataTemplatesDelete(d *Daemon, r *http.Request) Response { project := projectParam(r) name := mux.Vars(r)["name"] // Handle requests targeted to a container on a different node response, err := ForwardedResponseIfContainerIsRemote(d, r, project, name) if err != nil { return SmartError(err) }...
[ "func", "containerMetadataTemplatesDelete", "(", "d", "*", "Daemon", ",", "r", "*", "http", ".", "Request", ")", "Response", "{", "project", ":=", "projectParam", "(", "r", ")", "\n", "name", ":=", "mux", ".", "Vars", "(", "r", ")", "[", "\"name\"", "]...
// Delete a container template
[ "Delete", "a", "container", "template" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/container_metadata.go#L266-L317
test
lxc/lxd
lxd/container_metadata.go
getContainerTemplatePath
func getContainerTemplatePath(c container, filename string) (string, error) { if strings.Contains(filename, "/") { return "", fmt.Errorf("Invalid template filename") } return filepath.Join(c.Path(), "templates", filename), nil }
go
func getContainerTemplatePath(c container, filename string) (string, error) { if strings.Contains(filename, "/") { return "", fmt.Errorf("Invalid template filename") } return filepath.Join(c.Path(), "templates", filename), nil }
[ "func", "getContainerTemplatePath", "(", "c", "container", ",", "filename", "string", ")", "(", "string", ",", "error", ")", "{", "if", "strings", ".", "Contains", "(", "filename", ",", "\"/\"", ")", "{", "return", "\"\"", ",", "fmt", ".", "Errorf", "(",...
// Return the full path of a container template.
[ "Return", "the", "full", "path", "of", "a", "container", "template", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/container_metadata.go#L320-L326
test
lxc/lxd
lxd/config/errors.go
Error
func (e Error) Error() string { message := fmt.Sprintf("cannot set '%s'", e.Name) if e.Value != nil { message += fmt.Sprintf(" to '%v'", e.Value) } return message + fmt.Sprintf(": %s", e.Reason) }
go
func (e Error) Error() string { message := fmt.Sprintf("cannot set '%s'", e.Name) if e.Value != nil { message += fmt.Sprintf(" to '%v'", e.Value) } return message + fmt.Sprintf(": %s", e.Reason) }
[ "func", "(", "e", "Error", ")", "Error", "(", ")", "string", "{", "message", ":=", "fmt", ".", "Sprintf", "(", "\"cannot set '%s'\"", ",", "e", ".", "Name", ")", "\n", "if", "e", ".", "Value", "!=", "nil", "{", "message", "+=", "fmt", ".", "Sprintf...
// Error implements the error interface.
[ "Error", "implements", "the", "error", "interface", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/config/errors.go#L16-L22
test
lxc/lxd
lxd/config/errors.go
Error
func (l ErrorList) Error() string { switch len(l) { case 0: return "no errors" case 1: return l[0].Error() } return fmt.Sprintf("%s (and %d more errors)", l[0], len(l)-1) }
go
func (l ErrorList) Error() string { switch len(l) { case 0: return "no errors" case 1: return l[0].Error() } return fmt.Sprintf("%s (and %d more errors)", l[0], len(l)-1) }
[ "func", "(", "l", "ErrorList", ")", "Error", "(", ")", "string", "{", "switch", "len", "(", "l", ")", "{", "case", "0", ":", "return", "\"no errors\"", "\n", "case", "1", ":", "return", "l", "[", "0", "]", ".", "Error", "(", ")", "\n", "}", "\n...
// ErrorList implements the error interface.
[ "ErrorList", "implements", "the", "error", "interface", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/config/errors.go#L29-L37
test
lxc/lxd
lxd/config/errors.go
add
func (l *ErrorList) add(name string, value interface{}, reason string) { *l = append(*l, &Error{name, value, reason}) }
go
func (l *ErrorList) add(name string, value interface{}, reason string) { *l = append(*l, &Error{name, value, reason}) }
[ "func", "(", "l", "*", "ErrorList", ")", "add", "(", "name", "string", ",", "value", "interface", "{", "}", ",", "reason", "string", ")", "{", "*", "l", "=", "append", "(", "*", "l", ",", "&", "Error", "{", "name", ",", "value", ",", "reason", ...
// Add adds an Error with given key name, value and reason.
[ "Add", "adds", "an", "Error", "with", "given", "key", "name", "value", "and", "reason", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/config/errors.go#L48-L50
test
lxc/lxd
shared/generate/db/schema.go
UpdateSchema
func UpdateSchema() error { err := cluster.SchemaDotGo() if err != nil { return errors.Wrap(err, "Update cluster database schema") } err = node.SchemaDotGo() if err != nil { return errors.Wrap(err, "Update node database schema") } return nil }
go
func UpdateSchema() error { err := cluster.SchemaDotGo() if err != nil { return errors.Wrap(err, "Update cluster database schema") } err = node.SchemaDotGo() if err != nil { return errors.Wrap(err, "Update node database schema") } return nil }
[ "func", "UpdateSchema", "(", ")", "error", "{", "err", ":=", "cluster", ".", "SchemaDotGo", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrap", "(", "err", ",", "\"Update cluster database schema\"", ")", "\n", "}", "\n", "err"...
// UpdateSchema updates the schema.go file of the cluster and node databases.
[ "UpdateSchema", "updates", "the", "schema", ".", "go", "file", "of", "the", "cluster", "and", "node", "databases", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/db/schema.go#L11-L23
test
lxc/lxd
lxd/profiles_utils.go
doProfileUpdateCluster
func doProfileUpdateCluster(d *Daemon, project, name string, old api.ProfilePut) error { nodeName := "" err := d.cluster.Transaction(func(tx *db.ClusterTx) error { var err error nodeName, err = tx.NodeName() return err }) if err != nil { return errors.Wrap(err, "failed to query local node name") } contai...
go
func doProfileUpdateCluster(d *Daemon, project, name string, old api.ProfilePut) error { nodeName := "" err := d.cluster.Transaction(func(tx *db.ClusterTx) error { var err error nodeName, err = tx.NodeName() return err }) if err != nil { return errors.Wrap(err, "failed to query local node name") } contai...
[ "func", "doProfileUpdateCluster", "(", "d", "*", "Daemon", ",", "project", ",", "name", "string", ",", "old", "api", ".", "ProfilePut", ")", "error", "{", "nodeName", ":=", "\"\"", "\n", "err", ":=", "d", ".", "cluster", ".", "Transaction", "(", "func", ...
// Like doProfileUpdate but does not update the database, since it was already // updated by doProfileUpdate itself, called on the notifying node.
[ "Like", "doProfileUpdate", "but", "does", "not", "update", "the", "database", "since", "it", "was", "already", "updated", "by", "doProfileUpdate", "itself", "called", "on", "the", "notifying", "node", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/profiles_utils.go#L152-L185
test
lxc/lxd
lxd/profiles_utils.go
doProfileUpdateContainer
func doProfileUpdateContainer(d *Daemon, name string, old api.ProfilePut, nodeName string, args db.ContainerArgs) error { if args.Node != "" && args.Node != nodeName { // No-op, this container does not belong to this node. return nil } profiles, err := d.cluster.ProfilesGet(args.Project, args.Profiles) if err ...
go
func doProfileUpdateContainer(d *Daemon, name string, old api.ProfilePut, nodeName string, args db.ContainerArgs) error { if args.Node != "" && args.Node != nodeName { // No-op, this container does not belong to this node. return nil } profiles, err := d.cluster.ProfilesGet(args.Project, args.Profiles) if err ...
[ "func", "doProfileUpdateContainer", "(", "d", "*", "Daemon", ",", "name", "string", ",", "old", "api", ".", "ProfilePut", ",", "nodeName", "string", ",", "args", "db", ".", "ContainerArgs", ")", "error", "{", "if", "args", ".", "Node", "!=", "\"\"", "&&"...
// Profile update of a single container.
[ "Profile", "update", "of", "a", "single", "container", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/profiles_utils.go#L188-L221
test
lxc/lxd
lxd/profiles_utils.go
getProfileContainersInfo
func getProfileContainersInfo(cluster *db.Cluster, project, profile string) ([]db.ContainerArgs, error) { // Query the db for information about containers associated with the // given profile. names, err := cluster.ProfileContainersGet(project, profile) if err != nil { return nil, errors.Wrapf(err, "failed to que...
go
func getProfileContainersInfo(cluster *db.Cluster, project, profile string) ([]db.ContainerArgs, error) { // Query the db for information about containers associated with the // given profile. names, err := cluster.ProfileContainersGet(project, profile) if err != nil { return nil, errors.Wrapf(err, "failed to que...
[ "func", "getProfileContainersInfo", "(", "cluster", "*", "db", ".", "Cluster", ",", "project", ",", "profile", "string", ")", "(", "[", "]", "db", ".", "ContainerArgs", ",", "error", ")", "{", "names", ",", "err", ":=", "cluster", ".", "ProfileContainersGe...
// Query the db for information about containers associated with the given // profile.
[ "Query", "the", "db", "for", "information", "about", "containers", "associated", "with", "the", "given", "profile", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/profiles_utils.go#L225-L253
test
lxc/lxd
client/lxd_networks.go
GetNetworkNames
func (r *ProtocolLXD) GetNetworkNames() ([]string, error) { if !r.HasExtension("network") { return nil, fmt.Errorf("The server is missing the required \"network\" API extension") } urls := []string{} // Fetch the raw value _, err := r.queryStruct("GET", "/networks", nil, "", &urls) if err != nil { return ni...
go
func (r *ProtocolLXD) GetNetworkNames() ([]string, error) { if !r.HasExtension("network") { return nil, fmt.Errorf("The server is missing the required \"network\" API extension") } urls := []string{} // Fetch the raw value _, err := r.queryStruct("GET", "/networks", nil, "", &urls) if err != nil { return ni...
[ "func", "(", "r", "*", "ProtocolLXD", ")", "GetNetworkNames", "(", ")", "(", "[", "]", "string", ",", "error", ")", "{", "if", "!", "r", ".", "HasExtension", "(", "\"network\"", ")", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"The server...
// GetNetworkNames returns a list of network names
[ "GetNetworkNames", "returns", "a", "list", "of", "network", "names" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_networks.go#L12-L33
test
lxc/lxd
client/lxd_networks.go
GetNetworks
func (r *ProtocolLXD) GetNetworks() ([]api.Network, error) { if !r.HasExtension("network") { return nil, fmt.Errorf("The server is missing the required \"network\" API extension") } networks := []api.Network{} // Fetch the raw value _, err := r.queryStruct("GET", "/networks?recursion=1", nil, "", &networks) i...
go
func (r *ProtocolLXD) GetNetworks() ([]api.Network, error) { if !r.HasExtension("network") { return nil, fmt.Errorf("The server is missing the required \"network\" API extension") } networks := []api.Network{} // Fetch the raw value _, err := r.queryStruct("GET", "/networks?recursion=1", nil, "", &networks) i...
[ "func", "(", "r", "*", "ProtocolLXD", ")", "GetNetworks", "(", ")", "(", "[", "]", "api", ".", "Network", ",", "error", ")", "{", "if", "!", "r", ".", "HasExtension", "(", "\"network\"", ")", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", ...
// GetNetworks returns a list of Network struct
[ "GetNetworks", "returns", "a", "list", "of", "Network", "struct" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_networks.go#L36-L50
test
lxc/lxd
client/lxd_networks.go
GetNetwork
func (r *ProtocolLXD) GetNetwork(name string) (*api.Network, string, error) { if !r.HasExtension("network") { return nil, "", fmt.Errorf("The server is missing the required \"network\" API extension") } network := api.Network{} // Fetch the raw value etag, err := r.queryStruct("GET", fmt.Sprintf("/networks/%s"...
go
func (r *ProtocolLXD) GetNetwork(name string) (*api.Network, string, error) { if !r.HasExtension("network") { return nil, "", fmt.Errorf("The server is missing the required \"network\" API extension") } network := api.Network{} // Fetch the raw value etag, err := r.queryStruct("GET", fmt.Sprintf("/networks/%s"...
[ "func", "(", "r", "*", "ProtocolLXD", ")", "GetNetwork", "(", "name", "string", ")", "(", "*", "api", ".", "Network", ",", "string", ",", "error", ")", "{", "if", "!", "r", ".", "HasExtension", "(", "\"network\"", ")", "{", "return", "nil", ",", "\...
// GetNetwork returns a Network entry for the provided name
[ "GetNetwork", "returns", "a", "Network", "entry", "for", "the", "provided", "name" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_networks.go#L53-L67
test
lxc/lxd
client/lxd_networks.go
GetNetworkLeases
func (r *ProtocolLXD) GetNetworkLeases(name string) ([]api.NetworkLease, error) { if !r.HasExtension("network_leases") { return nil, fmt.Errorf("The server is missing the required \"network_leases\" API extension") } leases := []api.NetworkLease{} // Fetch the raw value _, err := r.queryStruct("GET", fmt.Sprin...
go
func (r *ProtocolLXD) GetNetworkLeases(name string) ([]api.NetworkLease, error) { if !r.HasExtension("network_leases") { return nil, fmt.Errorf("The server is missing the required \"network_leases\" API extension") } leases := []api.NetworkLease{} // Fetch the raw value _, err := r.queryStruct("GET", fmt.Sprin...
[ "func", "(", "r", "*", "ProtocolLXD", ")", "GetNetworkLeases", "(", "name", "string", ")", "(", "[", "]", "api", ".", "NetworkLease", ",", "error", ")", "{", "if", "!", "r", ".", "HasExtension", "(", "\"network_leases\"", ")", "{", "return", "nil", ","...
// GetNetworkLeases returns a list of Network struct
[ "GetNetworkLeases", "returns", "a", "list", "of", "Network", "struct" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_networks.go#L70-L84
test
lxc/lxd
client/lxd_networks.go
GetNetworkState
func (r *ProtocolLXD) GetNetworkState(name string) (*api.NetworkState, error) { if !r.HasExtension("network_state") { return nil, fmt.Errorf("The server is missing the required \"network_state\" API extension") } state := api.NetworkState{} // Fetch the raw value _, err := r.queryStruct("GET", fmt.Sprintf("/ne...
go
func (r *ProtocolLXD) GetNetworkState(name string) (*api.NetworkState, error) { if !r.HasExtension("network_state") { return nil, fmt.Errorf("The server is missing the required \"network_state\" API extension") } state := api.NetworkState{} // Fetch the raw value _, err := r.queryStruct("GET", fmt.Sprintf("/ne...
[ "func", "(", "r", "*", "ProtocolLXD", ")", "GetNetworkState", "(", "name", "string", ")", "(", "*", "api", ".", "NetworkState", ",", "error", ")", "{", "if", "!", "r", ".", "HasExtension", "(", "\"network_state\"", ")", "{", "return", "nil", ",", "fmt"...
// GetNetworkState returns metrics and information on the running network
[ "GetNetworkState", "returns", "metrics", "and", "information", "on", "the", "running", "network" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_networks.go#L87-L101
test
lxc/lxd
client/lxd_networks.go
CreateNetwork
func (r *ProtocolLXD) CreateNetwork(network api.NetworksPost) error { if !r.HasExtension("network") { return fmt.Errorf("The server is missing the required \"network\" API extension") } // Send the request _, _, err := r.query("POST", "/networks", network, "") if err != nil { return err } return nil }
go
func (r *ProtocolLXD) CreateNetwork(network api.NetworksPost) error { if !r.HasExtension("network") { return fmt.Errorf("The server is missing the required \"network\" API extension") } // Send the request _, _, err := r.query("POST", "/networks", network, "") if err != nil { return err } return nil }
[ "func", "(", "r", "*", "ProtocolLXD", ")", "CreateNetwork", "(", "network", "api", ".", "NetworksPost", ")", "error", "{", "if", "!", "r", ".", "HasExtension", "(", "\"network\"", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"The server is missing the re...
// CreateNetwork defines a new network using the provided Network struct
[ "CreateNetwork", "defines", "a", "new", "network", "using", "the", "provided", "Network", "struct" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_networks.go#L104-L116
test
lxc/lxd
client/lxd_networks.go
UpdateNetwork
func (r *ProtocolLXD) UpdateNetwork(name string, network api.NetworkPut, ETag string) error { if !r.HasExtension("network") { return fmt.Errorf("The server is missing the required \"network\" API extension") } // Send the request _, _, err := r.query("PUT", fmt.Sprintf("/networks/%s", url.QueryEscape(name)), net...
go
func (r *ProtocolLXD) UpdateNetwork(name string, network api.NetworkPut, ETag string) error { if !r.HasExtension("network") { return fmt.Errorf("The server is missing the required \"network\" API extension") } // Send the request _, _, err := r.query("PUT", fmt.Sprintf("/networks/%s", url.QueryEscape(name)), net...
[ "func", "(", "r", "*", "ProtocolLXD", ")", "UpdateNetwork", "(", "name", "string", ",", "network", "api", ".", "NetworkPut", ",", "ETag", "string", ")", "error", "{", "if", "!", "r", ".", "HasExtension", "(", "\"network\"", ")", "{", "return", "fmt", "...
// UpdateNetwork updates the network to match the provided Network struct
[ "UpdateNetwork", "updates", "the", "network", "to", "match", "the", "provided", "Network", "struct" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_networks.go#L119-L131
test
lxc/lxd
client/lxd_networks.go
RenameNetwork
func (r *ProtocolLXD) RenameNetwork(name string, network api.NetworkPost) error { if !r.HasExtension("network") { return fmt.Errorf("The server is missing the required \"network\" API extension") } // Send the request _, _, err := r.query("POST", fmt.Sprintf("/networks/%s", url.QueryEscape(name)), network, "") ...
go
func (r *ProtocolLXD) RenameNetwork(name string, network api.NetworkPost) error { if !r.HasExtension("network") { return fmt.Errorf("The server is missing the required \"network\" API extension") } // Send the request _, _, err := r.query("POST", fmt.Sprintf("/networks/%s", url.QueryEscape(name)), network, "") ...
[ "func", "(", "r", "*", "ProtocolLXD", ")", "RenameNetwork", "(", "name", "string", ",", "network", "api", ".", "NetworkPost", ")", "error", "{", "if", "!", "r", ".", "HasExtension", "(", "\"network\"", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"...
// RenameNetwork renames an existing network entry
[ "RenameNetwork", "renames", "an", "existing", "network", "entry" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_networks.go#L134-L146
test
lxc/lxd
lxd/db/cluster/open.go
Open
func Open(name string, store dqlite.ServerStore, options ...dqlite.DriverOption) (*sql.DB, error) { driver, err := dqlite.NewDriver(store, options...) if err != nil { return nil, errors.Wrap(err, "Failed to create dqlite driver") } driverName := dqliteDriverName() sql.Register(driverName, driver) // Create th...
go
func Open(name string, store dqlite.ServerStore, options ...dqlite.DriverOption) (*sql.DB, error) { driver, err := dqlite.NewDriver(store, options...) if err != nil { return nil, errors.Wrap(err, "Failed to create dqlite driver") } driverName := dqliteDriverName() sql.Register(driverName, driver) // Create th...
[ "func", "Open", "(", "name", "string", ",", "store", "dqlite", ".", "ServerStore", ",", "options", "...", "dqlite", ".", "DriverOption", ")", "(", "*", "sql", ".", "DB", ",", "error", ")", "{", "driver", ",", "err", ":=", "dqlite", ".", "NewDriver", ...
// Open the cluster database object. // // The name argument is the name of the cluster database. It defaults to // 'db.bin', but can be overwritten for testing. // // The dialer argument is a function that returns a gRPC dialer that can be // used to connect to a database node using the gRPC SQL package.
[ "Open", "the", "cluster", "database", "object", ".", "The", "name", "argument", "is", "the", "name", "of", "the", "cluster", "database", ".", "It", "defaults", "to", "db", ".", "bin", "but", "can", "be", "overwritten", "for", "testing", ".", "The", "dial...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/cluster/open.go#L26-L47
test
lxc/lxd
shared/util.go
URLEncode
func URLEncode(path string, query map[string]string) (string, error) { u, err := url.Parse(path) if err != nil { return "", err } params := url.Values{} for key, value := range query { params.Add(key, value) } u.RawQuery = params.Encode() return u.String(), nil }
go
func URLEncode(path string, query map[string]string) (string, error) { u, err := url.Parse(path) if err != nil { return "", err } params := url.Values{} for key, value := range query { params.Add(key, value) } u.RawQuery = params.Encode() return u.String(), nil }
[ "func", "URLEncode", "(", "path", "string", ",", "query", "map", "[", "string", "]", "string", ")", "(", "string", ",", "error", ")", "{", "u", ",", "err", ":=", "url", ".", "Parse", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return"...
// URLEncode encodes a path and query parameters to a URL.
[ "URLEncode", "encodes", "a", "path", "and", "query", "parameters", "to", "a", "URL", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/util.go#L38-L50
test
lxc/lxd
shared/util.go
IsUnixSocket
func IsUnixSocket(path string) bool { stat, err := os.Stat(path) if err != nil { return false } return (stat.Mode() & os.ModeSocket) == os.ModeSocket }
go
func IsUnixSocket(path string) bool { stat, err := os.Stat(path) if err != nil { return false } return (stat.Mode() & os.ModeSocket) == os.ModeSocket }
[ "func", "IsUnixSocket", "(", "path", "string", ")", "bool", "{", "stat", ",", "err", ":=", "os", ".", "Stat", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", "\n", "}", "\n", "return", "(", "stat", ".", "Mode", "(", ")",...
// IsUnixSocket returns true if the given path is either a Unix socket // or a symbolic link pointing at a Unix socket.
[ "IsUnixSocket", "returns", "true", "if", "the", "given", "path", "is", "either", "a", "Unix", "socket", "or", "a", "symbolic", "link", "pointing", "at", "a", "Unix", "socket", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/util.go#L100-L106
test
lxc/lxd
shared/util.go
HostPath
func HostPath(path string) string { // Ignore empty paths if len(path) == 0 { return path } // Don't prefix stdin/stdout if path == "-" { return path } // Check if we're running in a snap package snap := os.Getenv("SNAP") snapName := os.Getenv("SNAP_NAME") if snap == "" || snapName != "lxd" { return p...
go
func HostPath(path string) string { // Ignore empty paths if len(path) == 0 { return path } // Don't prefix stdin/stdout if path == "-" { return path } // Check if we're running in a snap package snap := os.Getenv("SNAP") snapName := os.Getenv("SNAP_NAME") if snap == "" || snapName != "lxd" { return p...
[ "func", "HostPath", "(", "path", "string", ")", "string", "{", "if", "len", "(", "path", ")", "==", "0", "{", "return", "path", "\n", "}", "\n", "if", "path", "==", "\"-\"", "{", "return", "path", "\n", "}", "\n", "snap", ":=", "os", ".", "Getenv...
// HostPath returns the host path for the provided path // On a normal system, this does nothing // When inside of a snap environment, returns the real path
[ "HostPath", "returns", "the", "host", "path", "for", "the", "provided", "path", "On", "a", "normal", "system", "this", "does", "nothing", "When", "inside", "of", "a", "snap", "environment", "returns", "the", "real", "path" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/util.go#L111-L153
test
lxc/lxd
shared/util.go
FileMove
func FileMove(oldPath string, newPath string) error { err := os.Rename(oldPath, newPath) if err == nil { return nil } err = FileCopy(oldPath, newPath) if err != nil { return err } os.Remove(oldPath) return nil }
go
func FileMove(oldPath string, newPath string) error { err := os.Rename(oldPath, newPath) if err == nil { return nil } err = FileCopy(oldPath, newPath) if err != nil { return err } os.Remove(oldPath) return nil }
[ "func", "FileMove", "(", "oldPath", "string", ",", "newPath", "string", ")", "error", "{", "err", ":=", "os", ".", "Rename", "(", "oldPath", ",", "newPath", ")", "\n", "if", "err", "==", "nil", "{", "return", "nil", "\n", "}", "\n", "err", "=", "Fi...
// FileMove tries to move a file by using os.Rename, // if that fails it tries to copy the file and remove the source.
[ "FileMove", "tries", "to", "move", "a", "file", "by", "using", "os", ".", "Rename", "if", "that", "fails", "it", "tries", "to", "copy", "the", "file", "and", "remove", "the", "source", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/util.go#L332-L346
test
lxc/lxd
shared/util.go
DirCopy
func DirCopy(source string, dest string) error { // Get info about source. info, err := os.Stat(source) if err != nil { return errors.Wrapf(err, "failed to get source directory info") } if !info.IsDir() { return fmt.Errorf("source is not a directory") } // Remove dest if it already exists. if PathExists(d...
go
func DirCopy(source string, dest string) error { // Get info about source. info, err := os.Stat(source) if err != nil { return errors.Wrapf(err, "failed to get source directory info") } if !info.IsDir() { return fmt.Errorf("source is not a directory") } // Remove dest if it already exists. if PathExists(d...
[ "func", "DirCopy", "(", "source", "string", ",", "dest", "string", ")", "error", "{", "info", ",", "err", ":=", "os", ".", "Stat", "(", "source", ")", "\n", "if", "err", "!=", "nil", "{", "return", "errors", ".", "Wrapf", "(", "err", ",", "\"failed...
// DirCopy copies a directory recursively, overwriting the target if it exists.
[ "DirCopy", "copies", "a", "directory", "recursively", "overwriting", "the", "target", "if", "it", "exists", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/util.go#L389-L440
test
lxc/lxd
shared/util.go
StringMapHasStringKey
func StringMapHasStringKey(m map[string]string, keys ...string) bool { for _, k := range keys { if _, ok := m[k]; ok { return true } } return false }
go
func StringMapHasStringKey(m map[string]string, keys ...string) bool { for _, k := range keys { if _, ok := m[k]; ok { return true } } return false }
[ "func", "StringMapHasStringKey", "(", "m", "map", "[", "string", "]", "string", ",", "keys", "...", "string", ")", "bool", "{", "for", "_", ",", "k", ":=", "range", "keys", "{", "if", "_", ",", "ok", ":=", "m", "[", "k", "]", ";", "ok", "{", "r...
// StringMapHasStringKey returns true if any of the supplied keys are present in the map.
[ "StringMapHasStringKey", "returns", "true", "if", "any", "of", "the", "supplied", "keys", "are", "present", "in", "the", "map", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/util.go#L551-L559
test
lxc/lxd
shared/util.go
TextEditor
func TextEditor(inPath string, inContent []byte) ([]byte, error) { var f *os.File var err error var path string // Detect the text editor to use editor := os.Getenv("VISUAL") if editor == "" { editor = os.Getenv("EDITOR") if editor == "" { for _, p := range []string{"editor", "vi", "emacs", "nano"} { ...
go
func TextEditor(inPath string, inContent []byte) ([]byte, error) { var f *os.File var err error var path string // Detect the text editor to use editor := os.Getenv("VISUAL") if editor == "" { editor = os.Getenv("EDITOR") if editor == "" { for _, p := range []string{"editor", "vi", "emacs", "nano"} { ...
[ "func", "TextEditor", "(", "inPath", "string", ",", "inContent", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "f", "*", "os", ".", "File", "\n", "var", "err", "error", "\n", "var", "path", "string", "\n", "editor", ...
// Spawn the editor with a temporary YAML file for editing configs
[ "Spawn", "the", "editor", "with", "a", "temporary", "YAML", "file", "for", "editing", "configs" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/util.go#L666-L729
test
lxc/lxd
shared/util.go
WriteTempFile
func WriteTempFile(dir string, prefix string, content string) (string, error) { f, err := ioutil.TempFile(dir, prefix) if err != nil { return "", err } defer f.Close() _, err = f.WriteString(content) return f.Name(), err }
go
func WriteTempFile(dir string, prefix string, content string) (string, error) { f, err := ioutil.TempFile(dir, prefix) if err != nil { return "", err } defer f.Close() _, err = f.WriteString(content) return f.Name(), err }
[ "func", "WriteTempFile", "(", "dir", "string", ",", "prefix", "string", ",", "content", "string", ")", "(", "string", ",", "error", ")", "{", "f", ",", "err", ":=", "ioutil", ".", "TempFile", "(", "dir", ",", "prefix", ")", "\n", "if", "err", "!=", ...
// WriteTempFile creates a temp file with the specified content
[ "WriteTempFile", "creates", "a", "temp", "file", "with", "the", "specified", "content" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/util.go#L999-L1008
test
lxc/lxd
shared/util.go
RenderTemplate
func RenderTemplate(template string, ctx pongo2.Context) (string, error) { // Load template from string tpl, err := pongo2.FromString("{% autoescape off %}" + template + "{% endautoescape %}") if err != nil { return "", err } // Get rendered template ret, err := tpl.Execute(ctx) if err != nil { return ret, ...
go
func RenderTemplate(template string, ctx pongo2.Context) (string, error) { // Load template from string tpl, err := pongo2.FromString("{% autoescape off %}" + template + "{% endautoescape %}") if err != nil { return "", err } // Get rendered template ret, err := tpl.Execute(ctx) if err != nil { return ret, ...
[ "func", "RenderTemplate", "(", "template", "string", ",", "ctx", "pongo2", ".", "Context", ")", "(", "string", ",", "error", ")", "{", "tpl", ",", "err", ":=", "pongo2", ".", "FromString", "(", "\"{% autoescape off %}\"", "+", "template", "+", "\"{% endautoe...
// RenderTemplate renders a pongo2 template.
[ "RenderTemplate", "renders", "a", "pongo2", "template", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/util.go#L1153-L1172
test
lxc/lxd
lxd/task/schedule.go
Every
func Every(interval time.Duration, options ...EveryOption) Schedule { every := &every{} for _, option := range options { option(every) } first := true return func() (time.Duration, error) { var err error if first && every.skipFirst { err = ErrSkip } first = false return interval, err } }
go
func Every(interval time.Duration, options ...EveryOption) Schedule { every := &every{} for _, option := range options { option(every) } first := true return func() (time.Duration, error) { var err error if first && every.skipFirst { err = ErrSkip } first = false return interval, err } }
[ "func", "Every", "(", "interval", "time", ".", "Duration", ",", "options", "...", "EveryOption", ")", "Schedule", "{", "every", ":=", "&", "every", "{", "}", "\n", "for", "_", ",", "option", ":=", "range", "options", "{", "option", "(", "every", ")", ...
// Every returns a Schedule that always returns the given time interval.
[ "Every", "returns", "a", "Schedule", "that", "always", "returns", "the", "given", "time", "interval", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/task/schedule.go#L33-L47
test
lxc/lxd
lxd/storage_lvm.go
StoragePoolMount
func (s *storageLvm) StoragePoolMount() (bool, error) { source := s.pool.Config["source"] if source == "" { return false, fmt.Errorf("no \"source\" property found for the storage pool") } if !filepath.IsAbs(source) { return true, nil } poolMountLockID := getPoolMountLockID(s.pool.Name) lxdStorageMapLock.Lo...
go
func (s *storageLvm) StoragePoolMount() (bool, error) { source := s.pool.Config["source"] if source == "" { return false, fmt.Errorf("no \"source\" property found for the storage pool") } if !filepath.IsAbs(source) { return true, nil } poolMountLockID := getPoolMountLockID(s.pool.Name) lxdStorageMapLock.Lo...
[ "func", "(", "s", "*", "storageLvm", ")", "StoragePoolMount", "(", ")", "(", "bool", ",", "error", ")", "{", "source", ":=", "s", ".", "pool", ".", "Config", "[", "\"source\"", "]", "\n", "if", "source", "==", "\"\"", "{", "return", "false", ",", "...
// Currently only used for loop-backed LVM storage pools. Can be called without // overhead since it is essentially a noop for non-loop-backed LVM storage // pools.
[ "Currently", "only", "used", "for", "loop", "-", "backed", "LVM", "storage", "pools", ".", "Can", "be", "called", "without", "overhead", "since", "it", "is", "essentially", "a", "noop", "for", "non", "-", "loop", "-", "backed", "LVM", "storage", "pools", ...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage_lvm.go#L423-L474
test
lxc/lxd
lxd/db/query/dump.go
Dump
func Dump(tx *sql.Tx, schema string, schemaOnly bool) (string, error) { schemas := dumpParseSchema(schema) // Begin dump := `PRAGMA foreign_keys=OFF; BEGIN TRANSACTION; ` // Schema table tableDump, err := dumpTable(tx, "schema", dumpSchemaTable) if err != nil { return "", errors.Wrapf(err, "failed to dump tabl...
go
func Dump(tx *sql.Tx, schema string, schemaOnly bool) (string, error) { schemas := dumpParseSchema(schema) // Begin dump := `PRAGMA foreign_keys=OFF; BEGIN TRANSACTION; ` // Schema table tableDump, err := dumpTable(tx, "schema", dumpSchemaTable) if err != nil { return "", errors.Wrapf(err, "failed to dump tabl...
[ "func", "Dump", "(", "tx", "*", "sql", ".", "Tx", ",", "schema", "string", ",", "schemaOnly", "bool", ")", "(", "string", ",", "error", ")", "{", "schemas", ":=", "dumpParseSchema", "(", "schema", ")", "\n", "dump", ":=", "`PRAGMA foreign_keys=OFF;BEGIN TR...
// Dump returns a SQL text dump of all rows across all tables, similar to // sqlite3's dump feature
[ "Dump", "returns", "a", "SQL", "text", "dump", "of", "all", "rows", "across", "all", "tables", "similar", "to", "sqlite3", "s", "dump", "feature" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/query/dump.go#L16-L62
test
lxc/lxd
lxd/db/query/dump.go
dumpTable
func dumpTable(tx *sql.Tx, table, schema string) (string, error) { statements := []string{schema} // Query all rows. rows, err := tx.Query(fmt.Sprintf("SELECT * FROM %s ORDER BY rowid", table)) if err != nil { return "", errors.Wrap(err, "failed to fetch rows") } defer rows.Close() // Figure column names co...
go
func dumpTable(tx *sql.Tx, table, schema string) (string, error) { statements := []string{schema} // Query all rows. rows, err := tx.Query(fmt.Sprintf("SELECT * FROM %s ORDER BY rowid", table)) if err != nil { return "", errors.Wrap(err, "failed to fetch rows") } defer rows.Close() // Figure column names co...
[ "func", "dumpTable", "(", "tx", "*", "sql", ".", "Tx", ",", "table", ",", "schema", "string", ")", "(", "string", ",", "error", ")", "{", "statements", ":=", "[", "]", "string", "{", "schema", "}", "\n", "rows", ",", "err", ":=", "tx", ".", "Quer...
// Dump a single table, returning a SQL text containing statements for its // schema and data.
[ "Dump", "a", "single", "table", "returning", "a", "SQL", "text", "containing", "statements", "for", "its", "schema", "and", "data", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/query/dump.go#L81-L130
test
lxc/lxd
lxd/db/projects.go
ProjectHasProfiles
func (c *ClusterTx) ProjectHasProfiles(name string) (bool, error) { return projectHasProfiles(c.tx, name) }
go
func (c *ClusterTx) ProjectHasProfiles(name string) (bool, error) { return projectHasProfiles(c.tx, name) }
[ "func", "(", "c", "*", "ClusterTx", ")", "ProjectHasProfiles", "(", "name", "string", ")", "(", "bool", ",", "error", ")", "{", "return", "projectHasProfiles", "(", "c", ".", "tx", ",", "name", ")", "\n", "}" ]
// ProjectHasProfiles is a helper to check if a project has the profiles // feature enabled.
[ "ProjectHasProfiles", "is", "a", "helper", "to", "check", "if", "a", "project", "has", "the", "profiles", "feature", "enabled", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/projects.go#L50-L52
test
lxc/lxd
lxd/db/projects.go
ProjectNames
func (c *ClusterTx) ProjectNames() ([]string, error) { stmt := "SELECT name FROM projects" names, err := query.SelectStrings(c.tx, stmt) if err != nil { return nil, errors.Wrap(err, "Fetch project names") } return names, nil }
go
func (c *ClusterTx) ProjectNames() ([]string, error) { stmt := "SELECT name FROM projects" names, err := query.SelectStrings(c.tx, stmt) if err != nil { return nil, errors.Wrap(err, "Fetch project names") } return names, nil }
[ "func", "(", "c", "*", "ClusterTx", ")", "ProjectNames", "(", ")", "(", "[", "]", "string", ",", "error", ")", "{", "stmt", ":=", "\"SELECT name FROM projects\"", "\n", "names", ",", "err", ":=", "query", ".", "SelectStrings", "(", "c", ".", "tx", ",",...
// ProjectNames returns the names of all available projects.
[ "ProjectNames", "returns", "the", "names", "of", "all", "available", "projects", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/projects.go#L55-L64
test
lxc/lxd
lxd/db/projects.go
ProjectMap
func (c *ClusterTx) ProjectMap() (map[int64]string, error) { stmt := "SELECT id, name FROM projects" rows, err := c.tx.Query(stmt) if err != nil { return nil, err } defer rows.Close() result := map[int64]string{} for i := 0; rows.Next(); i++ { var id int64 var name string err := rows.Scan(&id, &name) ...
go
func (c *ClusterTx) ProjectMap() (map[int64]string, error) { stmt := "SELECT id, name FROM projects" rows, err := c.tx.Query(stmt) if err != nil { return nil, err } defer rows.Close() result := map[int64]string{} for i := 0; rows.Next(); i++ { var id int64 var name string err := rows.Scan(&id, &name) ...
[ "func", "(", "c", "*", "ClusterTx", ")", "ProjectMap", "(", ")", "(", "map", "[", "int64", "]", "string", ",", "error", ")", "{", "stmt", ":=", "\"SELECT id, name FROM projects\"", "\n", "rows", ",", "err", ":=", "c", ".", "tx", ".", "Query", "(", "s...
// ProjectMap returns the names and ids of all available projects.
[ "ProjectMap", "returns", "the", "names", "and", "ids", "of", "all", "available", "projects", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/projects.go#L67-L95
test
lxc/lxd
lxd/db/projects.go
ProjectHasImages
func (c *ClusterTx) ProjectHasImages(name string) (bool, error) { project, err := c.ProjectGet(name) if err != nil { return false, errors.Wrap(err, "fetch project") } enabled := project.Config["features.images"] == "true" return enabled, nil }
go
func (c *ClusterTx) ProjectHasImages(name string) (bool, error) { project, err := c.ProjectGet(name) if err != nil { return false, errors.Wrap(err, "fetch project") } enabled := project.Config["features.images"] == "true" return enabled, nil }
[ "func", "(", "c", "*", "ClusterTx", ")", "ProjectHasImages", "(", "name", "string", ")", "(", "bool", ",", "error", ")", "{", "project", ",", "err", ":=", "c", ".", "ProjectGet", "(", "name", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fal...
// ProjectHasImages is a helper to check if a project has the images // feature enabled.
[ "ProjectHasImages", "is", "a", "helper", "to", "check", "if", "a", "project", "has", "the", "images", "feature", "enabled", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/projects.go#L118-L127
test
lxc/lxd
lxd/db/projects.go
ProjectUpdate
func (c *ClusterTx) ProjectUpdate(name string, object api.ProjectPut) error { stmt := c.stmt(projectUpdate) result, err := stmt.Exec(object.Description, name) if err != nil { return errors.Wrap(err, "Update project") } n, err := result.RowsAffected() if err != nil { return errors.Wrap(err, "Fetch affected ro...
go
func (c *ClusterTx) ProjectUpdate(name string, object api.ProjectPut) error { stmt := c.stmt(projectUpdate) result, err := stmt.Exec(object.Description, name) if err != nil { return errors.Wrap(err, "Update project") } n, err := result.RowsAffected() if err != nil { return errors.Wrap(err, "Fetch affected ro...
[ "func", "(", "c", "*", "ClusterTx", ")", "ProjectUpdate", "(", "name", "string", ",", "object", "api", ".", "ProjectPut", ")", "error", "{", "stmt", ":=", "c", ".", "stmt", "(", "projectUpdate", ")", "\n", "result", ",", "err", ":=", "stmt", ".", "Ex...
// ProjectUpdate updates the project matching the given key parameters.
[ "ProjectUpdate", "updates", "the", "project", "matching", "the", "given", "key", "parameters", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/projects.go#L130-L168
test
lxc/lxd
client/lxd_cluster.go
GetCluster
func (r *ProtocolLXD) GetCluster() (*api.Cluster, string, error) { if !r.HasExtension("clustering") { return nil, "", fmt.Errorf("The server is missing the required \"clustering\" API extension") } cluster := &api.Cluster{} etag, err := r.queryStruct("GET", "/cluster", nil, "", &cluster) if err != nil { retur...
go
func (r *ProtocolLXD) GetCluster() (*api.Cluster, string, error) { if !r.HasExtension("clustering") { return nil, "", fmt.Errorf("The server is missing the required \"clustering\" API extension") } cluster := &api.Cluster{} etag, err := r.queryStruct("GET", "/cluster", nil, "", &cluster) if err != nil { retur...
[ "func", "(", "r", "*", "ProtocolLXD", ")", "GetCluster", "(", ")", "(", "*", "api", ".", "Cluster", ",", "string", ",", "error", ")", "{", "if", "!", "r", ".", "HasExtension", "(", "\"clustering\"", ")", "{", "return", "nil", ",", "\"\"", ",", "fmt...
// GetCluster returns information about a cluster // // If this client is not trusted, the password must be supplied
[ "GetCluster", "returns", "information", "about", "a", "cluster", "If", "this", "client", "is", "not", "trusted", "the", "password", "must", "be", "supplied" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_cluster.go#L12-L24
test
lxc/lxd
client/lxd_cluster.go
UpdateCluster
func (r *ProtocolLXD) UpdateCluster(cluster api.ClusterPut, ETag string) (Operation, error) { if !r.HasExtension("clustering") { return nil, fmt.Errorf("The server is missing the required \"clustering\" API extension") } if cluster.ServerAddress != "" || cluster.ClusterPassword != "" || len(cluster.MemberConfig) ...
go
func (r *ProtocolLXD) UpdateCluster(cluster api.ClusterPut, ETag string) (Operation, error) { if !r.HasExtension("clustering") { return nil, fmt.Errorf("The server is missing the required \"clustering\" API extension") } if cluster.ServerAddress != "" || cluster.ClusterPassword != "" || len(cluster.MemberConfig) ...
[ "func", "(", "r", "*", "ProtocolLXD", ")", "UpdateCluster", "(", "cluster", "api", ".", "ClusterPut", ",", "ETag", "string", ")", "(", "Operation", ",", "error", ")", "{", "if", "!", "r", ".", "HasExtension", "(", "\"clustering\"", ")", "{", "return", ...
// UpdateCluster requests to bootstrap a new cluster or join an existing one.
[ "UpdateCluster", "requests", "to", "bootstrap", "a", "new", "cluster", "or", "join", "an", "existing", "one", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_cluster.go#L27-L44
test
lxc/lxd
client/lxd_cluster.go
GetClusterMemberNames
func (r *ProtocolLXD) GetClusterMemberNames() ([]string, error) { if !r.HasExtension("clustering") { return nil, fmt.Errorf("The server is missing the required \"clustering\" API extension") } urls := []string{} _, err := r.queryStruct("GET", "/cluster/members", nil, "", &urls) if err != nil { return nil, err...
go
func (r *ProtocolLXD) GetClusterMemberNames() ([]string, error) { if !r.HasExtension("clustering") { return nil, fmt.Errorf("The server is missing the required \"clustering\" API extension") } urls := []string{} _, err := r.queryStruct("GET", "/cluster/members", nil, "", &urls) if err != nil { return nil, err...
[ "func", "(", "r", "*", "ProtocolLXD", ")", "GetClusterMemberNames", "(", ")", "(", "[", "]", "string", ",", "error", ")", "{", "if", "!", "r", ".", "HasExtension", "(", "\"clustering\"", ")", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"T...
// GetClusterMemberNames returns the URLs of the current members in the cluster
[ "GetClusterMemberNames", "returns", "the", "URLs", "of", "the", "current", "members", "in", "the", "cluster" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_cluster.go#L67-L79
test
lxc/lxd
client/lxd_cluster.go
GetClusterMembers
func (r *ProtocolLXD) GetClusterMembers() ([]api.ClusterMember, error) { if !r.HasExtension("clustering") { return nil, fmt.Errorf("The server is missing the required \"clustering\" API extension") } members := []api.ClusterMember{} _, err := r.queryStruct("GET", "/cluster/members?recursion=1", nil, "", &members...
go
func (r *ProtocolLXD) GetClusterMembers() ([]api.ClusterMember, error) { if !r.HasExtension("clustering") { return nil, fmt.Errorf("The server is missing the required \"clustering\" API extension") } members := []api.ClusterMember{} _, err := r.queryStruct("GET", "/cluster/members?recursion=1", nil, "", &members...
[ "func", "(", "r", "*", "ProtocolLXD", ")", "GetClusterMembers", "(", ")", "(", "[", "]", "api", ".", "ClusterMember", ",", "error", ")", "{", "if", "!", "r", ".", "HasExtension", "(", "\"clustering\"", ")", "{", "return", "nil", ",", "fmt", ".", "Err...
// GetClusterMembers returns the current members of the cluster
[ "GetClusterMembers", "returns", "the", "current", "members", "of", "the", "cluster" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_cluster.go#L82-L94
test
lxc/lxd
client/lxd_cluster.go
GetClusterMember
func (r *ProtocolLXD) GetClusterMember(name string) (*api.ClusterMember, string, error) { if !r.HasExtension("clustering") { return nil, "", fmt.Errorf("The server is missing the required \"clustering\" API extension") } member := api.ClusterMember{} etag, err := r.queryStruct("GET", fmt.Sprintf("/cluster/member...
go
func (r *ProtocolLXD) GetClusterMember(name string) (*api.ClusterMember, string, error) { if !r.HasExtension("clustering") { return nil, "", fmt.Errorf("The server is missing the required \"clustering\" API extension") } member := api.ClusterMember{} etag, err := r.queryStruct("GET", fmt.Sprintf("/cluster/member...
[ "func", "(", "r", "*", "ProtocolLXD", ")", "GetClusterMember", "(", "name", "string", ")", "(", "*", "api", ".", "ClusterMember", ",", "string", ",", "error", ")", "{", "if", "!", "r", ".", "HasExtension", "(", "\"clustering\"", ")", "{", "return", "ni...
// GetClusterMember returns information about the given member
[ "GetClusterMember", "returns", "information", "about", "the", "given", "member" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_cluster.go#L97-L109
test
lxc/lxd
client/lxd_cluster.go
RenameClusterMember
func (r *ProtocolLXD) RenameClusterMember(name string, member api.ClusterMemberPost) error { if !r.HasExtension("clustering") { return fmt.Errorf("The server is missing the required \"clustering\" API extension") } _, _, err := r.query("POST", fmt.Sprintf("/cluster/members/%s", name), member, "") if err != nil {...
go
func (r *ProtocolLXD) RenameClusterMember(name string, member api.ClusterMemberPost) error { if !r.HasExtension("clustering") { return fmt.Errorf("The server is missing the required \"clustering\" API extension") } _, _, err := r.query("POST", fmt.Sprintf("/cluster/members/%s", name), member, "") if err != nil {...
[ "func", "(", "r", "*", "ProtocolLXD", ")", "RenameClusterMember", "(", "name", "string", ",", "member", "api", ".", "ClusterMemberPost", ")", "error", "{", "if", "!", "r", ".", "HasExtension", "(", "\"clustering\"", ")", "{", "return", "fmt", ".", "Errorf"...
// RenameClusterMember changes the name of an existing member
[ "RenameClusterMember", "changes", "the", "name", "of", "an", "existing", "member" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_cluster.go#L112-L123
test
lxc/lxd
client/events.go
Disconnect
func (e *EventListener) Disconnect() { if e.disconnected { return } // Handle locking e.r.eventListenersLock.Lock() defer e.r.eventListenersLock.Unlock() // Locate and remove it from the global list for i, listener := range e.r.eventListeners { if listener == e { copy(e.r.eventListeners[i:], e.r.eventLi...
go
func (e *EventListener) Disconnect() { if e.disconnected { return } // Handle locking e.r.eventListenersLock.Lock() defer e.r.eventListenersLock.Unlock() // Locate and remove it from the global list for i, listener := range e.r.eventListeners { if listener == e { copy(e.r.eventListeners[i:], e.r.eventLi...
[ "func", "(", "e", "*", "EventListener", ")", "Disconnect", "(", ")", "{", "if", "e", ".", "disconnected", "{", "return", "\n", "}", "\n", "e", ".", "r", ".", "eventListenersLock", ".", "Lock", "(", ")", "\n", "defer", "e", ".", "r", ".", "eventList...
// Disconnect must be used once done listening for events
[ "Disconnect", "must", "be", "used", "once", "done", "listening", "for", "events" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/events.go#L73-L96
test
lxc/lxd
lxd/util/version.go
CompareVersions
func CompareVersions(version1, version2 [2]int) (int, error) { schema1, extensions1 := version1[0], version1[1] schema2, extensions2 := version2[0], version2[1] if schema1 == schema2 && extensions1 == extensions2 { return 0, nil } if schema1 >= schema2 && extensions1 >= extensions2 { return 1, nil } if sche...
go
func CompareVersions(version1, version2 [2]int) (int, error) { schema1, extensions1 := version1[0], version1[1] schema2, extensions2 := version2[0], version2[1] if schema1 == schema2 && extensions1 == extensions2 { return 0, nil } if schema1 >= schema2 && extensions1 >= extensions2 { return 1, nil } if sche...
[ "func", "CompareVersions", "(", "version1", ",", "version2", "[", "2", "]", "int", ")", "(", "int", ",", "error", ")", "{", "schema1", ",", "extensions1", ":=", "version1", "[", "0", "]", ",", "version1", "[", "1", "]", "\n", "schema2", ",", "extensi...
// CompareVersions the versions of two LXD nodes. // // A version consists of the version the node's schema and the number of API // extensions it supports. // // Return 0 if they equal, 1 if the first version is greater than the second // and 2 if the second is greater than the first. // // Return an error if inconsis...
[ "CompareVersions", "the", "versions", "of", "two", "LXD", "nodes", ".", "A", "version", "consists", "of", "the", "version", "the", "node", "s", "schema", "and", "the", "number", "of", "API", "extensions", "it", "supports", ".", "Return", "0", "if", "they",...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/util/version.go#L16-L31
test
lxc/lxd
lxc/config/cert.go
HasClientCertificate
func (c *Config) HasClientCertificate() bool { certf := c.ConfigPath("client.crt") keyf := c.ConfigPath("client.key") if !shared.PathExists(certf) || !shared.PathExists(keyf) { return false } return true }
go
func (c *Config) HasClientCertificate() bool { certf := c.ConfigPath("client.crt") keyf := c.ConfigPath("client.key") if !shared.PathExists(certf) || !shared.PathExists(keyf) { return false } return true }
[ "func", "(", "c", "*", "Config", ")", "HasClientCertificate", "(", ")", "bool", "{", "certf", ":=", "c", ".", "ConfigPath", "(", "\"client.crt\"", ")", "\n", "keyf", ":=", "c", ".", "ConfigPath", "(", "\"client.key\"", ")", "\n", "if", "!", "shared", "...
// HasClientCertificate will return true if a client certificate has already been generated
[ "HasClientCertificate", "will", "return", "true", "if", "a", "client", "certificate", "has", "already", "been", "generated" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxc/config/cert.go#L8-L16
test
lxc/lxd
lxc/config/cert.go
GenerateClientCertificate
func (c *Config) GenerateClientCertificate() error { if c.HasClientCertificate() { return nil } certf := c.ConfigPath("client.crt") keyf := c.ConfigPath("client.key") return shared.FindOrGenCert(certf, keyf, true) }
go
func (c *Config) GenerateClientCertificate() error { if c.HasClientCertificate() { return nil } certf := c.ConfigPath("client.crt") keyf := c.ConfigPath("client.key") return shared.FindOrGenCert(certf, keyf, true) }
[ "func", "(", "c", "*", "Config", ")", "GenerateClientCertificate", "(", ")", "error", "{", "if", "c", ".", "HasClientCertificate", "(", ")", "{", "return", "nil", "\n", "}", "\n", "certf", ":=", "c", ".", "ConfigPath", "(", "\"client.crt\"", ")", "\n", ...
// GenerateClientCertificate will generate the needed client.crt and client.key if needed
[ "GenerateClientCertificate", "will", "generate", "the", "needed", "client", ".", "crt", "and", "client", ".", "key", "if", "needed" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxc/config/cert.go#L19-L28
test
lxc/lxd
lxd/util/kernel.go
LoadModule
func LoadModule(module string) error { if shared.PathExists(fmt.Sprintf("/sys/module/%s", module)) { return nil } _, err := shared.RunCommand("modprobe", module) return err }
go
func LoadModule(module string) error { if shared.PathExists(fmt.Sprintf("/sys/module/%s", module)) { return nil } _, err := shared.RunCommand("modprobe", module) return err }
[ "func", "LoadModule", "(", "module", "string", ")", "error", "{", "if", "shared", ".", "PathExists", "(", "fmt", ".", "Sprintf", "(", "\"/sys/module/%s\"", ",", "module", ")", ")", "{", "return", "nil", "\n", "}", "\n", "_", ",", "err", ":=", "shared",...
// LoadModule loads the kernel module with the given name, by invoking // modprobe.
[ "LoadModule", "loads", "the", "kernel", "module", "with", "the", "given", "name", "by", "invoking", "modprobe", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/util/kernel.go#L11-L18
test
lxc/lxd
shared/generate/lex/parse.go
Parse
func Parse(name string) (*ast.Package, error) { base := os.Getenv("GOPATH") if base == "" { base = "~/go" } dir := filepath.Join(base, "src", name) fset := token.NewFileSet() paths, err := filepath.Glob(filepath.Join(dir, "*.go")) if err != nil { return nil, errors.Wrap(err, "Search source file") } file...
go
func Parse(name string) (*ast.Package, error) { base := os.Getenv("GOPATH") if base == "" { base = "~/go" } dir := filepath.Join(base, "src", name) fset := token.NewFileSet() paths, err := filepath.Glob(filepath.Join(dir, "*.go")) if err != nil { return nil, errors.Wrap(err, "Search source file") } file...
[ "func", "Parse", "(", "name", "string", ")", "(", "*", "ast", ".", "Package", ",", "error", ")", "{", "base", ":=", "os", ".", "Getenv", "(", "\"GOPATH\"", ")", "\n", "if", "base", "==", "\"\"", "{", "base", "=", "\"~/go\"", "\n", "}", "\n", "dir...
// Parse runs the Go parser against the given package name.
[ "Parse", "runs", "the", "Go", "parser", "against", "the", "given", "package", "name", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/lex/parse.go#L16-L49
test
lxc/lxd
lxd/endpoints/pprof.go
PprofAddress
func (e *Endpoints) PprofAddress() string { e.mu.RLock() defer e.mu.RUnlock() listener := e.listeners[pprof] if listener == nil { return "" } return listener.Addr().String() }
go
func (e *Endpoints) PprofAddress() string { e.mu.RLock() defer e.mu.RUnlock() listener := e.listeners[pprof] if listener == nil { return "" } return listener.Addr().String() }
[ "func", "(", "e", "*", "Endpoints", ")", "PprofAddress", "(", ")", "string", "{", "e", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "e", ".", "mu", ".", "RUnlock", "(", ")", "\n", "listener", ":=", "e", ".", "listeners", "[", "pprof", "]", ...
// PprofAddress returns the network addresss of the pprof endpoint, or an empty string if there's no pprof endpoint
[ "PprofAddress", "returns", "the", "network", "addresss", "of", "the", "pprof", "endpoint", "or", "an", "empty", "string", "if", "there", "s", "no", "pprof", "endpoint" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/endpoints/pprof.go#L33-L43
test
lxc/lxd
lxd/endpoints/pprof.go
PprofUpdateAddress
func (e *Endpoints) PprofUpdateAddress(address string) error { if address != "" { address = util.CanonicalNetworkAddress(address) } oldAddress := e.NetworkAddress() if address == oldAddress { return nil } logger.Infof("Update pprof address") e.mu.Lock() defer e.mu.Unlock() // Close the previous socket ...
go
func (e *Endpoints) PprofUpdateAddress(address string) error { if address != "" { address = util.CanonicalNetworkAddress(address) } oldAddress := e.NetworkAddress() if address == oldAddress { return nil } logger.Infof("Update pprof address") e.mu.Lock() defer e.mu.Unlock() // Close the previous socket ...
[ "func", "(", "e", "*", "Endpoints", ")", "PprofUpdateAddress", "(", "address", "string", ")", "error", "{", "if", "address", "!=", "\"\"", "{", "address", "=", "util", ".", "CanonicalNetworkAddress", "(", "address", ")", "\n", "}", "\n", "oldAddress", ":="...
// PprofUpdateAddress updates the address for the pprof endpoint, shutting it down and restarting it.
[ "PprofUpdateAddress", "updates", "the", "address", "for", "the", "pprof", "endpoint", "shutting", "it", "down", "and", "restarting", "it", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/endpoints/pprof.go#L46-L109
test
lxc/lxd
shared/generate/db/method.go
NewMethod
func NewMethod(database, pkg, entity, kind string, config map[string]string) (*Method, error) { packages, err := Packages() if err != nil { return nil, err } method := &Method{ db: database, pkg: pkg, entity: entity, kind: kind, config: config, packages: packages, } return metho...
go
func NewMethod(database, pkg, entity, kind string, config map[string]string) (*Method, error) { packages, err := Packages() if err != nil { return nil, err } method := &Method{ db: database, pkg: pkg, entity: entity, kind: kind, config: config, packages: packages, } return metho...
[ "func", "NewMethod", "(", "database", ",", "pkg", ",", "entity", ",", "kind", "string", ",", "config", "map", "[", "string", "]", "string", ")", "(", "*", "Method", ",", "error", ")", "{", "packages", ",", "err", ":=", "Packages", "(", ")", "\n", "...
// NewMethod return a new method code snippet for executing a certain mapping.
[ "NewMethod", "return", "a", "new", "method", "code", "snippet", "for", "executing", "a", "certain", "mapping", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/db/method.go#L24-L40
test
lxc/lxd
shared/generate/db/method.go
Generate
func (m *Method) Generate(buf *file.Buffer) error { if strings.HasSuffix(m.kind, "Ref") { return m.ref(buf) } switch m.kind { case "URIs": return m.uris(buf) case "List": return m.list(buf) case "Get": return m.get(buf) case "ID": return m.id(buf) case "Exists": return m.exists(buf) case "Create": ...
go
func (m *Method) Generate(buf *file.Buffer) error { if strings.HasSuffix(m.kind, "Ref") { return m.ref(buf) } switch m.kind { case "URIs": return m.uris(buf) case "List": return m.list(buf) case "Get": return m.get(buf) case "ID": return m.id(buf) case "Exists": return m.exists(buf) case "Create": ...
[ "func", "(", "m", "*", "Method", ")", "Generate", "(", "buf", "*", "file", ".", "Buffer", ")", "error", "{", "if", "strings", ".", "HasSuffix", "(", "m", ".", "kind", ",", "\"Ref\"", ")", "{", "return", "m", ".", "ref", "(", "buf", ")", "\n", "...
// Generate the desired method.
[ "Generate", "the", "desired", "method", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/db/method.go#L43-L69
test
lxc/lxd
shared/generate/db/method.go
fillSliceReferenceField
func (m *Method) fillSliceReferenceField(buf *file.Buffer, nk []*Field, field *Field) error { objectsVar := fmt.Sprintf("%sObjects", lex.Minuscule(field.Name)) methodName := fmt.Sprintf("%s%sRef", lex.Capital(m.entity), field.Name) buf.L("// Fill field %s.", field.Name) buf.L("%s, err := c.%s(filter)", objectsVar,...
go
func (m *Method) fillSliceReferenceField(buf *file.Buffer, nk []*Field, field *Field) error { objectsVar := fmt.Sprintf("%sObjects", lex.Minuscule(field.Name)) methodName := fmt.Sprintf("%s%sRef", lex.Capital(m.entity), field.Name) buf.L("// Fill field %s.", field.Name) buf.L("%s, err := c.%s(filter)", objectsVar,...
[ "func", "(", "m", "*", "Method", ")", "fillSliceReferenceField", "(", "buf", "*", "file", ".", "Buffer", ",", "nk", "[", "]", "*", "Field", ",", "field", "*", "Field", ")", "error", "{", "objectsVar", ":=", "fmt", ".", "Sprintf", "(", "\"%sObjects\"", ...
// Populate a field consisting of a slice of objects referencing the // entity. This information is available by joining a the view or table // associated with the type of the referenced objects, which must contain the // natural key of the entity.
[ "Populate", "a", "field", "consisting", "of", "a", "slice", "of", "objects", "referencing", "the", "entity", ".", "This", "information", "is", "available", "by", "joining", "a", "the", "view", "or", "table", "associated", "with", "the", "type", "of", "the", ...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/db/method.go#L506-L539
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolID
func (c *ClusterTx) StoragePoolID(name string) (int64, error) { stmt := "SELECT id FROM storage_pools WHERE name=?" ids, err := query.SelectIntegers(c.tx, stmt, name) if err != nil { return -1, err } switch len(ids) { case 0: return -1, ErrNoSuchObject case 1: return int64(ids[0]), nil default: return -...
go
func (c *ClusterTx) StoragePoolID(name string) (int64, error) { stmt := "SELECT id FROM storage_pools WHERE name=?" ids, err := query.SelectIntegers(c.tx, stmt, name) if err != nil { return -1, err } switch len(ids) { case 0: return -1, ErrNoSuchObject case 1: return int64(ids[0]), nil default: return -...
[ "func", "(", "c", "*", "ClusterTx", ")", "StoragePoolID", "(", "name", "string", ")", "(", "int64", ",", "error", ")", "{", "stmt", ":=", "\"SELECT id FROM storage_pools WHERE name=?\"", "\n", "ids", ",", "err", ":=", "query", ".", "SelectIntegers", "(", "c"...
// StoragePoolID returns the ID of the pool with the given name.
[ "StoragePoolID", "returns", "the", "ID", "of", "the", "pool", "with", "the", "given", "name", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L39-L53
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolIDsNotPending
func (c *ClusterTx) StoragePoolIDsNotPending() (map[string]int64, error) { pools := []struct { id int64 name string }{} dest := func(i int) []interface{} { pools = append(pools, struct { id int64 name string }{}) return []interface{}{&pools[i].id, &pools[i].name} } stmt, err := c.tx.Prepare("S...
go
func (c *ClusterTx) StoragePoolIDsNotPending() (map[string]int64, error) { pools := []struct { id int64 name string }{} dest := func(i int) []interface{} { pools = append(pools, struct { id int64 name string }{}) return []interface{}{&pools[i].id, &pools[i].name} } stmt, err := c.tx.Prepare("S...
[ "func", "(", "c", "*", "ClusterTx", ")", "StoragePoolIDsNotPending", "(", ")", "(", "map", "[", "string", "]", "int64", ",", "error", ")", "{", "pools", ":=", "[", "]", "struct", "{", "id", "int64", "\n", "name", "string", "\n", "}", "{", "}", "\n"...
// StoragePoolIDsNotPending returns a map associating each storage pool name to its ID. // // Pending storage pools are skipped.
[ "StoragePoolIDsNotPending", "returns", "a", "map", "associating", "each", "storage", "pool", "name", "to", "its", "ID", ".", "Pending", "storage", "pools", "are", "skipped", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L75-L102
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolNodeJoin
func (c *ClusterTx) StoragePoolNodeJoin(poolID, nodeID int64) error { columns := []string{"storage_pool_id", "node_id"} values := []interface{}{poolID, nodeID} _, err := query.UpsertObject(c.tx, "storage_pools_nodes", columns, values) if err != nil { return errors.Wrap(err, "failed to add storage pools node entry...
go
func (c *ClusterTx) StoragePoolNodeJoin(poolID, nodeID int64) error { columns := []string{"storage_pool_id", "node_id"} values := []interface{}{poolID, nodeID} _, err := query.UpsertObject(c.tx, "storage_pools_nodes", columns, values) if err != nil { return errors.Wrap(err, "failed to add storage pools node entry...
[ "func", "(", "c", "*", "ClusterTx", ")", "StoragePoolNodeJoin", "(", "poolID", ",", "nodeID", "int64", ")", "error", "{", "columns", ":=", "[", "]", "string", "{", "\"storage_pool_id\"", ",", "\"node_id\"", "}", "\n", "values", ":=", "[", "]", "interface",...
// StoragePoolNodeJoin adds a new entry in the storage_pools_nodes table. // // It should only be used when a new node joins the cluster, when it's safe to // assume that the relevant pool has already been created on the joining node, // and we just need to track it.
[ "StoragePoolNodeJoin", "adds", "a", "new", "entry", "in", "the", "storage_pools_nodes", "table", ".", "It", "should", "only", "be", "used", "when", "a", "new", "node", "joins", "the", "cluster", "when", "it", "s", "safe", "to", "assume", "that", "the", "re...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L109-L118
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolNodeJoinCeph
func (c *ClusterTx) StoragePoolNodeJoinCeph(poolID, nodeID int64) error { // Get the IDs of the other nodes (they should be all linked to // the pool). stmt := "SELECT node_id FROM storage_pools_nodes WHERE storage_pool_id=?" nodeIDs, err := query.SelectIntegers(c.tx, stmt, poolID) if err != nil { return errors....
go
func (c *ClusterTx) StoragePoolNodeJoinCeph(poolID, nodeID int64) error { // Get the IDs of the other nodes (they should be all linked to // the pool). stmt := "SELECT node_id FROM storage_pools_nodes WHERE storage_pool_id=?" nodeIDs, err := query.SelectIntegers(c.tx, stmt, poolID) if err != nil { return errors....
[ "func", "(", "c", "*", "ClusterTx", ")", "StoragePoolNodeJoinCeph", "(", "poolID", ",", "nodeID", "int64", ")", "error", "{", "stmt", ":=", "\"SELECT node_id FROM storage_pools_nodes WHERE storage_pool_id=?\"", "\n", "nodeIDs", ",", "err", ":=", "query", ".", "Selec...
// StoragePoolNodeJoinCeph updates internal state to reflect that nodeID is // joining a cluster where poolID is a ceph pool.
[ "StoragePoolNodeJoinCeph", "updates", "internal", "state", "to", "reflect", "that", "nodeID", "is", "joining", "a", "cluster", "where", "poolID", "is", "a", "ceph", "pool", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L122-L178
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolConfigAdd
func (c *ClusterTx) StoragePoolConfigAdd(poolID, nodeID int64, config map[string]string) error { return storagePoolConfigAdd(c.tx, poolID, nodeID, config) }
go
func (c *ClusterTx) StoragePoolConfigAdd(poolID, nodeID int64, config map[string]string) error { return storagePoolConfigAdd(c.tx, poolID, nodeID, config) }
[ "func", "(", "c", "*", "ClusterTx", ")", "StoragePoolConfigAdd", "(", "poolID", ",", "nodeID", "int64", ",", "config", "map", "[", "string", "]", "string", ")", "error", "{", "return", "storagePoolConfigAdd", "(", "c", ".", "tx", ",", "poolID", ",", "nod...
// StoragePoolConfigAdd adds a new entry in the storage_pools_config table
[ "StoragePoolConfigAdd", "adds", "a", "new", "entry", "in", "the", "storage_pools_config", "table" ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L181-L183
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolCreatePending
func (c *ClusterTx) StoragePoolCreatePending(node, name, driver string, conf map[string]string) error { // First check if a storage pool with the given name exists, and, if // so, that it has a matching driver and it's in the pending state. pool := struct { id int64 driver string state int }{} var errC...
go
func (c *ClusterTx) StoragePoolCreatePending(node, name, driver string, conf map[string]string) error { // First check if a storage pool with the given name exists, and, if // so, that it has a matching driver and it's in the pending state. pool := struct { id int64 driver string state int }{} var errC...
[ "func", "(", "c", "*", "ClusterTx", ")", "StoragePoolCreatePending", "(", "node", ",", "name", ",", "driver", "string", ",", "conf", "map", "[", "string", "]", "string", ")", "error", "{", "pool", ":=", "struct", "{", "id", "int64", "\n", "driver", "st...
// StoragePoolCreatePending creates a new pending storage pool on the node with // the given name.
[ "StoragePoolCreatePending", "creates", "a", "new", "pending", "storage", "pool", "on", "the", "node", "with", "the", "given", "name", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L194-L274
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolCreated
func (c *ClusterTx) StoragePoolCreated(name string) error { return c.storagePoolState(name, storagePoolCreated) }
go
func (c *ClusterTx) StoragePoolCreated(name string) error { return c.storagePoolState(name, storagePoolCreated) }
[ "func", "(", "c", "*", "ClusterTx", ")", "StoragePoolCreated", "(", "name", "string", ")", "error", "{", "return", "c", ".", "storagePoolState", "(", "name", ",", "storagePoolCreated", ")", "\n", "}" ]
// StoragePoolCreated sets the state of the given pool to "Created".
[ "StoragePoolCreated", "sets", "the", "state", "of", "the", "given", "pool", "to", "Created", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L277-L279
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolErrored
func (c *ClusterTx) StoragePoolErrored(name string) error { return c.storagePoolState(name, storagePoolErrored) }
go
func (c *ClusterTx) StoragePoolErrored(name string) error { return c.storagePoolState(name, storagePoolErrored) }
[ "func", "(", "c", "*", "ClusterTx", ")", "StoragePoolErrored", "(", "name", "string", ")", "error", "{", "return", "c", ".", "storagePoolState", "(", "name", ",", "storagePoolErrored", ")", "\n", "}" ]
// StoragePoolErrored sets the state of the given pool to "Errored".
[ "StoragePoolErrored", "sets", "the", "state", "of", "the", "given", "pool", "to", "Errored", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L282-L284
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolNodeConfigs
func (c *ClusterTx) StoragePoolNodeConfigs(poolID int64) (map[string]map[string]string, error) { // Fetch all nodes. nodes, err := c.Nodes() if err != nil { return nil, err } // Fetch the names of the nodes where the storage pool is defined. stmt := ` SELECT nodes.name FROM nodes LEFT JOIN storage_pools_node...
go
func (c *ClusterTx) StoragePoolNodeConfigs(poolID int64) (map[string]map[string]string, error) { // Fetch all nodes. nodes, err := c.Nodes() if err != nil { return nil, err } // Fetch the names of the nodes where the storage pool is defined. stmt := ` SELECT nodes.name FROM nodes LEFT JOIN storage_pools_node...
[ "func", "(", "c", "*", "ClusterTx", ")", "StoragePoolNodeConfigs", "(", "poolID", "int64", ")", "(", "map", "[", "string", "]", "map", "[", "string", "]", "string", ",", "error", ")", "{", "nodes", ",", "err", ":=", "c", ".", "Nodes", "(", ")", "\n...
// StoragePoolNodeConfigs returns the node-specific configuration of all // nodes grouped by node name, for the given poolID. // // If the storage pool is not defined on all nodes, an error is returned.
[ "StoragePoolNodeConfigs", "returns", "the", "node", "-", "specific", "configuration", "of", "all", "nodes", "grouped", "by", "node", "name", "for", "the", "given", "poolID", ".", "If", "the", "storage", "pool", "is", "not", "defined", "on", "all", "nodes", "...
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L306-L348
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolsGetDrivers
func (c *Cluster) StoragePoolsGetDrivers() ([]string, error) { var poolDriver string query := "SELECT DISTINCT driver FROM storage_pools" inargs := []interface{}{} outargs := []interface{}{poolDriver} result, err := queryScan(c.db, query, inargs, outargs) if err != nil { return []string{}, err } if len(resu...
go
func (c *Cluster) StoragePoolsGetDrivers() ([]string, error) { var poolDriver string query := "SELECT DISTINCT driver FROM storage_pools" inargs := []interface{}{} outargs := []interface{}{poolDriver} result, err := queryScan(c.db, query, inargs, outargs) if err != nil { return []string{}, err } if len(resu...
[ "func", "(", "c", "*", "Cluster", ")", "StoragePoolsGetDrivers", "(", ")", "(", "[", "]", "string", ",", "error", ")", "{", "var", "poolDriver", "string", "\n", "query", ":=", "\"SELECT DISTINCT driver FROM storage_pools\"", "\n", "inargs", ":=", "[", "]", "...
// StoragePoolsGetDrivers returns the names of all storage volumes attached to // a given storage pool.
[ "StoragePoolsGetDrivers", "returns", "the", "names", "of", "all", "storage", "volumes", "attached", "to", "a", "given", "storage", "pool", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L394-L415
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolGetID
func (c *Cluster) StoragePoolGetID(poolName string) (int64, error) { poolID := int64(-1) query := "SELECT id FROM storage_pools WHERE name=?" inargs := []interface{}{poolName} outargs := []interface{}{&poolID} err := dbQueryRowScan(c.db, query, inargs, outargs) if err != nil { if err == sql.ErrNoRows { retu...
go
func (c *Cluster) StoragePoolGetID(poolName string) (int64, error) { poolID := int64(-1) query := "SELECT id FROM storage_pools WHERE name=?" inargs := []interface{}{poolName} outargs := []interface{}{&poolID} err := dbQueryRowScan(c.db, query, inargs, outargs) if err != nil { if err == sql.ErrNoRows { retu...
[ "func", "(", "c", "*", "Cluster", ")", "StoragePoolGetID", "(", "poolName", "string", ")", "(", "int64", ",", "error", ")", "{", "poolID", ":=", "int64", "(", "-", "1", ")", "\n", "query", ":=", "\"SELECT id FROM storage_pools WHERE name=?\"", "\n", "inargs"...
// StoragePoolGetID returns the id of a single storage pool.
[ "StoragePoolGetID", "returns", "the", "id", "of", "a", "single", "storage", "pool", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L418-L432
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolGet
func (c *Cluster) StoragePoolGet(poolName string) (int64, *api.StoragePool, error) { var poolDriver string poolID := int64(-1) description := sql.NullString{} var state int query := "SELECT id, driver, description, state FROM storage_pools WHERE name=?" inargs := []interface{}{poolName} outargs := []interface{}...
go
func (c *Cluster) StoragePoolGet(poolName string) (int64, *api.StoragePool, error) { var poolDriver string poolID := int64(-1) description := sql.NullString{} var state int query := "SELECT id, driver, description, state FROM storage_pools WHERE name=?" inargs := []interface{}{poolName} outargs := []interface{}...
[ "func", "(", "c", "*", "Cluster", ")", "StoragePoolGet", "(", "poolName", "string", ")", "(", "int64", ",", "*", "api", ".", "StoragePool", ",", "error", ")", "{", "var", "poolDriver", "string", "\n", "poolID", ":=", "int64", "(", "-", "1", ")", "\n"...
// StoragePoolGet returns a single storage pool.
[ "StoragePoolGet", "returns", "a", "single", "storage", "pool", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L435-L481
test
lxc/lxd
lxd/db/storage_pools.go
storagePoolNodes
func (c *Cluster) storagePoolNodes(poolID int64) ([]string, error) { stmt := ` SELECT nodes.name FROM nodes JOIN storage_pools_nodes ON storage_pools_nodes.node_id = nodes.id WHERE storage_pools_nodes.storage_pool_id = ? ` var nodes []string err := c.Transaction(func(tx *ClusterTx) error { var err error node...
go
func (c *Cluster) storagePoolNodes(poolID int64) ([]string, error) { stmt := ` SELECT nodes.name FROM nodes JOIN storage_pools_nodes ON storage_pools_nodes.node_id = nodes.id WHERE storage_pools_nodes.storage_pool_id = ? ` var nodes []string err := c.Transaction(func(tx *ClusterTx) error { var err error node...
[ "func", "(", "c", "*", "Cluster", ")", "storagePoolNodes", "(", "poolID", "int64", ")", "(", "[", "]", "string", ",", "error", ")", "{", "stmt", ":=", "`SELECT nodes.name FROM nodes JOIN storage_pools_nodes ON storage_pools_nodes.node_id = nodes.id WHERE storage_pools_nod...
// Return the names of the nodes the given pool is defined on.
[ "Return", "the", "names", "of", "the", "nodes", "the", "given", "pool", "is", "defined", "on", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L484-L500
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolConfigGet
func (c *Cluster) StoragePoolConfigGet(poolID int64) (map[string]string, error) { var key, value string query := "SELECT key, value FROM storage_pools_config WHERE storage_pool_id=? AND (node_id=? OR node_id IS NULL)" inargs := []interface{}{poolID, c.nodeID} outargs := []interface{}{key, value} results, err := q...
go
func (c *Cluster) StoragePoolConfigGet(poolID int64) (map[string]string, error) { var key, value string query := "SELECT key, value FROM storage_pools_config WHERE storage_pool_id=? AND (node_id=? OR node_id IS NULL)" inargs := []interface{}{poolID, c.nodeID} outargs := []interface{}{key, value} results, err := q...
[ "func", "(", "c", "*", "Cluster", ")", "StoragePoolConfigGet", "(", "poolID", "int64", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "var", "key", ",", "value", "string", "\n", "query", ":=", "\"SELECT key, value FROM storage_pools_c...
// StoragePoolConfigGet returns the config of a storage pool.
[ "StoragePoolConfigGet", "returns", "the", "config", "of", "a", "storage", "pool", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L503-L524
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolCreate
func (c *Cluster) StoragePoolCreate(poolName string, poolDescription string, poolDriver string, poolConfig map[string]string) (int64, error) { var id int64 err := c.Transaction(func(tx *ClusterTx) error { result, err := tx.tx.Exec("INSERT INTO storage_pools (name, description, driver, state) VALUES (?, ?, ?, ?)", p...
go
func (c *Cluster) StoragePoolCreate(poolName string, poolDescription string, poolDriver string, poolConfig map[string]string) (int64, error) { var id int64 err := c.Transaction(func(tx *ClusterTx) error { result, err := tx.tx.Exec("INSERT INTO storage_pools (name, description, driver, state) VALUES (?, ?, ?, ?)", p...
[ "func", "(", "c", "*", "Cluster", ")", "StoragePoolCreate", "(", "poolName", "string", ",", "poolDescription", "string", ",", "poolDriver", "string", ",", "poolConfig", "map", "[", "string", "]", "string", ")", "(", "int64", ",", "error", ")", "{", "var", ...
// StoragePoolCreate creates new storage pool.
[ "StoragePoolCreate", "creates", "new", "storage", "pool", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L527-L559
test
lxc/lxd
lxd/db/storage_pools.go
storagePoolConfigAdd
func storagePoolConfigAdd(tx *sql.Tx, poolID, nodeID int64, poolConfig map[string]string) error { str := "INSERT INTO storage_pools_config (storage_pool_id, node_id, key, value) VALUES(?, ?, ?, ?)" stmt, err := tx.Prepare(str) defer stmt.Close() if err != nil { return err } for k, v := range poolConfig { if ...
go
func storagePoolConfigAdd(tx *sql.Tx, poolID, nodeID int64, poolConfig map[string]string) error { str := "INSERT INTO storage_pools_config (storage_pool_id, node_id, key, value) VALUES(?, ?, ?, ?)" stmt, err := tx.Prepare(str) defer stmt.Close() if err != nil { return err } for k, v := range poolConfig { if ...
[ "func", "storagePoolConfigAdd", "(", "tx", "*", "sql", ".", "Tx", ",", "poolID", ",", "nodeID", "int64", ",", "poolConfig", "map", "[", "string", "]", "string", ")", "error", "{", "str", ":=", "\"INSERT INTO storage_pools_config (storage_pool_id, node_id, key, value...
// Add new storage pool config.
[ "Add", "new", "storage", "pool", "config", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L562-L588
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolUpdate
func (c *Cluster) StoragePoolUpdate(poolName, description string, poolConfig map[string]string) error { poolID, _, err := c.StoragePoolGet(poolName) if err != nil { return err } err = c.Transaction(func(tx *ClusterTx) error { err = StoragePoolUpdateDescription(tx.tx, poolID, description) if err != nil { r...
go
func (c *Cluster) StoragePoolUpdate(poolName, description string, poolConfig map[string]string) error { poolID, _, err := c.StoragePoolGet(poolName) if err != nil { return err } err = c.Transaction(func(tx *ClusterTx) error { err = StoragePoolUpdateDescription(tx.tx, poolID, description) if err != nil { r...
[ "func", "(", "c", "*", "Cluster", ")", "StoragePoolUpdate", "(", "poolName", ",", "description", "string", ",", "poolConfig", "map", "[", "string", "]", "string", ")", "error", "{", "poolID", ",", "_", ",", "err", ":=", "c", ".", "StoragePoolGet", "(", ...
// StoragePoolUpdate updates a storage pool.
[ "StoragePoolUpdate", "updates", "a", "storage", "pool", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L608-L633
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolConfigClear
func StoragePoolConfigClear(tx *sql.Tx, poolID, nodeID int64) error { _, err := tx.Exec("DELETE FROM storage_pools_config WHERE storage_pool_id=? AND (node_id=? OR node_id IS NULL)", poolID, nodeID) if err != nil { return err } return nil }
go
func StoragePoolConfigClear(tx *sql.Tx, poolID, nodeID int64) error { _, err := tx.Exec("DELETE FROM storage_pools_config WHERE storage_pool_id=? AND (node_id=? OR node_id IS NULL)", poolID, nodeID) if err != nil { return err } return nil }
[ "func", "StoragePoolConfigClear", "(", "tx", "*", "sql", ".", "Tx", ",", "poolID", ",", "nodeID", "int64", ")", "error", "{", "_", ",", "err", ":=", "tx", ".", "Exec", "(", "\"DELETE FROM storage_pools_config WHERE storage_pool_id=? AND (node_id=? OR node_id IS NULL)\...
// StoragePoolConfigClear deletes the storage pool config.
[ "StoragePoolConfigClear", "deletes", "the", "storage", "pool", "config", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L642-L649
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolDelete
func (c *Cluster) StoragePoolDelete(poolName string) (*api.StoragePool, error) { poolID, pool, err := c.StoragePoolGet(poolName) if err != nil { return nil, err } err = exec(c.db, "DELETE FROM storage_pools WHERE id=?", poolID) if err != nil { return nil, err } return pool, nil }
go
func (c *Cluster) StoragePoolDelete(poolName string) (*api.StoragePool, error) { poolID, pool, err := c.StoragePoolGet(poolName) if err != nil { return nil, err } err = exec(c.db, "DELETE FROM storage_pools WHERE id=?", poolID) if err != nil { return nil, err } return pool, nil }
[ "func", "(", "c", "*", "Cluster", ")", "StoragePoolDelete", "(", "poolName", "string", ")", "(", "*", "api", ".", "StoragePool", ",", "error", ")", "{", "poolID", ",", "pool", ",", "err", ":=", "c", ".", "StoragePoolGet", "(", "poolName", ")", "\n", ...
// StoragePoolDelete deletes storage pool.
[ "StoragePoolDelete", "deletes", "storage", "pool", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L652-L664
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolVolumesGetNames
func (c *Cluster) StoragePoolVolumesGetNames(poolID int64) ([]string, error) { var volumeName string query := "SELECT name FROM storage_volumes WHERE storage_pool_id=? AND node_id=?" inargs := []interface{}{poolID, c.nodeID} outargs := []interface{}{volumeName} result, err := queryScan(c.db, query, inargs, outarg...
go
func (c *Cluster) StoragePoolVolumesGetNames(poolID int64) ([]string, error) { var volumeName string query := "SELECT name FROM storage_volumes WHERE storage_pool_id=? AND node_id=?" inargs := []interface{}{poolID, c.nodeID} outargs := []interface{}{volumeName} result, err := queryScan(c.db, query, inargs, outarg...
[ "func", "(", "c", "*", "Cluster", ")", "StoragePoolVolumesGetNames", "(", "poolID", "int64", ")", "(", "[", "]", "string", ",", "error", ")", "{", "var", "volumeName", "string", "\n", "query", ":=", "\"SELECT name FROM storage_volumes WHERE storage_pool_id=? AND nod...
// StoragePoolVolumesGetNames gets the names of all storage volumes attached to // a given storage pool.
[ "StoragePoolVolumesGetNames", "gets", "the", "names", "of", "all", "storage", "volumes", "attached", "to", "a", "given", "storage", "pool", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L668-L686
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolVolumesGet
func (c *Cluster) StoragePoolVolumesGet(project string, poolID int64, volumeTypes []int) ([]*api.StorageVolume, error) { var nodeIDs []int err := c.Transaction(func(tx *ClusterTx) error { var err error nodeIDs, err = query.SelectIntegers(tx.tx, ` SELECT DISTINCT node_id FROM storage_volumes JOIN projects ON ...
go
func (c *Cluster) StoragePoolVolumesGet(project string, poolID int64, volumeTypes []int) ([]*api.StorageVolume, error) { var nodeIDs []int err := c.Transaction(func(tx *ClusterTx) error { var err error nodeIDs, err = query.SelectIntegers(tx.tx, ` SELECT DISTINCT node_id FROM storage_volumes JOIN projects ON ...
[ "func", "(", "c", "*", "Cluster", ")", "StoragePoolVolumesGet", "(", "project", "string", ",", "poolID", "int64", ",", "volumeTypes", "[", "]", "int", ")", "(", "[", "]", "*", "api", ".", "StorageVolume", ",", "error", ")", "{", "var", "nodeIDs", "[", ...
// StoragePoolVolumesGet returns all storage volumes attached to a given // storage pool on any node.
[ "StoragePoolVolumesGet", "returns", "all", "storage", "volumes", "attached", "to", "a", "given", "storage", "pool", "on", "any", "node", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L690-L716
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolNodeVolumesGet
func (c *Cluster) StoragePoolNodeVolumesGet(poolID int64, volumeTypes []int) ([]*api.StorageVolume, error) { return c.storagePoolVolumesGet("default", poolID, c.nodeID, volumeTypes) }
go
func (c *Cluster) StoragePoolNodeVolumesGet(poolID int64, volumeTypes []int) ([]*api.StorageVolume, error) { return c.storagePoolVolumesGet("default", poolID, c.nodeID, volumeTypes) }
[ "func", "(", "c", "*", "Cluster", ")", "StoragePoolNodeVolumesGet", "(", "poolID", "int64", ",", "volumeTypes", "[", "]", "int", ")", "(", "[", "]", "*", "api", ".", "StorageVolume", ",", "error", ")", "{", "return", "c", ".", "storagePoolVolumesGet", "(...
// StoragePoolNodeVolumesGet returns all storage volumes attached to a given // storage pool on the current node.
[ "StoragePoolNodeVolumesGet", "returns", "all", "storage", "volumes", "attached", "to", "a", "given", "storage", "pool", "on", "the", "current", "node", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L720-L722
test
lxc/lxd
lxd/db/storage_pools.go
storagePoolVolumesGet
func (c *Cluster) storagePoolVolumesGet(project string, poolID, nodeID int64, volumeTypes []int) ([]*api.StorageVolume, error) { // Get all storage volumes of all types attached to a given storage // pool. result := []*api.StorageVolume{} for _, volumeType := range volumeTypes { volumeNames, err := c.StoragePoolV...
go
func (c *Cluster) storagePoolVolumesGet(project string, poolID, nodeID int64, volumeTypes []int) ([]*api.StorageVolume, error) { // Get all storage volumes of all types attached to a given storage // pool. result := []*api.StorageVolume{} for _, volumeType := range volumeTypes { volumeNames, err := c.StoragePoolV...
[ "func", "(", "c", "*", "Cluster", ")", "storagePoolVolumesGet", "(", "project", "string", ",", "poolID", ",", "nodeID", "int64", ",", "volumeTypes", "[", "]", "int", ")", "(", "[", "]", "*", "api", ".", "StorageVolume", ",", "error", ")", "{", "result"...
// Returns all storage volumes attached to a given storage pool on the given // node.
[ "Returns", "all", "storage", "volumes", "attached", "to", "a", "given", "storage", "pool", "on", "the", "given", "node", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L726-L749
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolVolumesGetType
func (c *Cluster) StoragePoolVolumesGetType(project string, volumeType int, poolID, nodeID int64) ([]string, error) { var poolName string query := ` SELECT storage_volumes.name FROM storage_volumes JOIN projects ON projects.id=storage_volumes.project_id WHERE (projects.name=? OR storage_volumes.type=?) AND stora...
go
func (c *Cluster) StoragePoolVolumesGetType(project string, volumeType int, poolID, nodeID int64) ([]string, error) { var poolName string query := ` SELECT storage_volumes.name FROM storage_volumes JOIN projects ON projects.id=storage_volumes.project_id WHERE (projects.name=? OR storage_volumes.type=?) AND stora...
[ "func", "(", "c", "*", "Cluster", ")", "StoragePoolVolumesGetType", "(", "project", "string", ",", "volumeType", "int", ",", "poolID", ",", "nodeID", "int64", ")", "(", "[", "]", "string", ",", "error", ")", "{", "var", "poolName", "string", "\n", "query...
// StoragePoolVolumesGetType get all storage volumes attached to a given // storage pool of a given volume type, on the given node.
[ "StoragePoolVolumesGetType", "get", "all", "storage", "volumes", "attached", "to", "a", "given", "storage", "pool", "of", "a", "given", "volume", "type", "on", "the", "given", "node", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L753-L775
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolVolumeSnapshotsGetType
func (c *Cluster) StoragePoolVolumeSnapshotsGetType(volumeName string, volumeType int, poolID int64) ([]string, error) { result := []string{} regexp := volumeName + shared.SnapshotDelimiter length := len(regexp) query := "SELECT name FROM storage_volumes WHERE storage_pool_id=? AND node_id=? AND type=? AND snapsho...
go
func (c *Cluster) StoragePoolVolumeSnapshotsGetType(volumeName string, volumeType int, poolID int64) ([]string, error) { result := []string{} regexp := volumeName + shared.SnapshotDelimiter length := len(regexp) query := "SELECT name FROM storage_volumes WHERE storage_pool_id=? AND node_id=? AND type=? AND snapsho...
[ "func", "(", "c", "*", "Cluster", ")", "StoragePoolVolumeSnapshotsGetType", "(", "volumeName", "string", ",", "volumeType", "int", ",", "poolID", "int64", ")", "(", "[", "]", "string", ",", "error", ")", "{", "result", ":=", "[", "]", "string", "{", "}",...
// StoragePoolVolumeSnapshotsGetType get all snapshots of a storage volume // attached to a given storage pool of a given volume type, on the given node.
[ "StoragePoolVolumeSnapshotsGetType", "get", "all", "snapshots", "of", "a", "storage", "volume", "attached", "to", "a", "given", "storage", "pool", "of", "a", "given", "volume", "type", "on", "the", "given", "node", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L779-L798
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolNodeVolumesGetType
func (c *Cluster) StoragePoolNodeVolumesGetType(volumeType int, poolID int64) ([]string, error) { return c.StoragePoolVolumesGetType("default", volumeType, poolID, c.nodeID) }
go
func (c *Cluster) StoragePoolNodeVolumesGetType(volumeType int, poolID int64) ([]string, error) { return c.StoragePoolVolumesGetType("default", volumeType, poolID, c.nodeID) }
[ "func", "(", "c", "*", "Cluster", ")", "StoragePoolNodeVolumesGetType", "(", "volumeType", "int", ",", "poolID", "int64", ")", "(", "[", "]", "string", ",", "error", ")", "{", "return", "c", ".", "StoragePoolVolumesGetType", "(", "\"default\"", ",", "volumeT...
// StoragePoolNodeVolumesGetType returns all storage volumes attached to a // given storage pool of a given volume type, on the current node.
[ "StoragePoolNodeVolumesGetType", "returns", "all", "storage", "volumes", "attached", "to", "a", "given", "storage", "pool", "of", "a", "given", "volume", "type", "on", "the", "current", "node", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L802-L804
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolVolumeGetType
func (c *Cluster) StoragePoolVolumeGetType(project string, volumeName string, volumeType int, poolID, nodeID int64) (int64, *api.StorageVolume, error) { // Custom volumes are "global", i.e. they are associated with the // default project. if volumeType == StoragePoolVolumeTypeCustom { project = "default" } volu...
go
func (c *Cluster) StoragePoolVolumeGetType(project string, volumeName string, volumeType int, poolID, nodeID int64) (int64, *api.StorageVolume, error) { // Custom volumes are "global", i.e. they are associated with the // default project. if volumeType == StoragePoolVolumeTypeCustom { project = "default" } volu...
[ "func", "(", "c", "*", "Cluster", ")", "StoragePoolVolumeGetType", "(", "project", "string", ",", "volumeName", "string", ",", "volumeType", "int", ",", "poolID", ",", "nodeID", "int64", ")", "(", "int64", ",", "*", "api", ".", "StorageVolume", ",", "error...
// StoragePoolVolumeGetType returns a single storage volume attached to a // given storage pool of a given type, on the node with the given ID.
[ "StoragePoolVolumeGetType", "returns", "a", "single", "storage", "volume", "attached", "to", "a", "given", "storage", "pool", "of", "a", "given", "type", "on", "the", "node", "with", "the", "given", "ID", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L808-L849
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolNodeVolumeGetType
func (c *Cluster) StoragePoolNodeVolumeGetType(volumeName string, volumeType int, poolID int64) (int64, *api.StorageVolume, error) { return c.StoragePoolNodeVolumeGetTypeByProject("default", volumeName, volumeType, poolID) }
go
func (c *Cluster) StoragePoolNodeVolumeGetType(volumeName string, volumeType int, poolID int64) (int64, *api.StorageVolume, error) { return c.StoragePoolNodeVolumeGetTypeByProject("default", volumeName, volumeType, poolID) }
[ "func", "(", "c", "*", "Cluster", ")", "StoragePoolNodeVolumeGetType", "(", "volumeName", "string", ",", "volumeType", "int", ",", "poolID", "int64", ")", "(", "int64", ",", "*", "api", ".", "StorageVolume", ",", "error", ")", "{", "return", "c", ".", "S...
// StoragePoolNodeVolumeGetType gets a single storage volume attached to a // given storage pool of a given type, on the current node.
[ "StoragePoolNodeVolumeGetType", "gets", "a", "single", "storage", "volume", "attached", "to", "a", "given", "storage", "pool", "of", "a", "given", "type", "on", "the", "current", "node", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L853-L855
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolNodeVolumeGetTypeByProject
func (c *Cluster) StoragePoolNodeVolumeGetTypeByProject(project, volumeName string, volumeType int, poolID int64) (int64, *api.StorageVolume, error) { return c.StoragePoolVolumeGetType(project, volumeName, volumeType, poolID, c.nodeID) }
go
func (c *Cluster) StoragePoolNodeVolumeGetTypeByProject(project, volumeName string, volumeType int, poolID int64) (int64, *api.StorageVolume, error) { return c.StoragePoolVolumeGetType(project, volumeName, volumeType, poolID, c.nodeID) }
[ "func", "(", "c", "*", "Cluster", ")", "StoragePoolNodeVolumeGetTypeByProject", "(", "project", ",", "volumeName", "string", ",", "volumeType", "int", ",", "poolID", "int64", ")", "(", "int64", ",", "*", "api", ".", "StorageVolume", ",", "error", ")", "{", ...
// StoragePoolNodeVolumeGetTypeByProject gets a single storage volume attached to a // given storage pool of a given type, on the current node in the given project.
[ "StoragePoolNodeVolumeGetTypeByProject", "gets", "a", "single", "storage", "volume", "attached", "to", "a", "given", "storage", "pool", "of", "a", "given", "type", "on", "the", "current", "node", "in", "the", "given", "project", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L859-L861
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolVolumeUpdate
func (c *Cluster) StoragePoolVolumeUpdate(volumeName string, volumeType int, poolID int64, volumeDescription string, volumeConfig map[string]string) error { volumeID, _, err := c.StoragePoolNodeVolumeGetType(volumeName, volumeType, poolID) if err != nil { return err } err = c.Transaction(func(tx *ClusterTx) erro...
go
func (c *Cluster) StoragePoolVolumeUpdate(volumeName string, volumeType int, poolID int64, volumeDescription string, volumeConfig map[string]string) error { volumeID, _, err := c.StoragePoolNodeVolumeGetType(volumeName, volumeType, poolID) if err != nil { return err } err = c.Transaction(func(tx *ClusterTx) erro...
[ "func", "(", "c", "*", "Cluster", ")", "StoragePoolVolumeUpdate", "(", "volumeName", "string", ",", "volumeType", "int", ",", "poolID", "int64", ",", "volumeDescription", "string", ",", "volumeConfig", "map", "[", "string", "]", "string", ")", "error", "{", ...
// StoragePoolVolumeUpdate updates the storage volume attached to a given storage // pool.
[ "StoragePoolVolumeUpdate", "updates", "the", "storage", "volume", "attached", "to", "a", "given", "storage", "pool", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L865-L892
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolVolumeDelete
func (c *Cluster) StoragePoolVolumeDelete(project, volumeName string, volumeType int, poolID int64) error { volumeID, _, err := c.StoragePoolNodeVolumeGetTypeByProject(project, volumeName, volumeType, poolID) if err != nil { return err } err = c.Transaction(func(tx *ClusterTx) error { err := storagePoolVolumeR...
go
func (c *Cluster) StoragePoolVolumeDelete(project, volumeName string, volumeType int, poolID int64) error { volumeID, _, err := c.StoragePoolNodeVolumeGetTypeByProject(project, volumeName, volumeType, poolID) if err != nil { return err } err = c.Transaction(func(tx *ClusterTx) error { err := storagePoolVolumeR...
[ "func", "(", "c", "*", "Cluster", ")", "StoragePoolVolumeDelete", "(", "project", ",", "volumeName", "string", ",", "volumeType", "int", ",", "poolID", "int64", ")", "error", "{", "volumeID", ",", "_", ",", "err", ":=", "c", ".", "StoragePoolNodeVolumeGetTyp...
// StoragePoolVolumeDelete deletes the storage volume attached to a given storage // pool.
[ "StoragePoolVolumeDelete", "deletes", "the", "storage", "volume", "attached", "to", "a", "given", "storage", "pool", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L896-L911
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolVolumeRename
func (c *Cluster) StoragePoolVolumeRename(project, oldVolumeName string, newVolumeName string, volumeType int, poolID int64) error { volumeID, _, err := c.StoragePoolNodeVolumeGetTypeByProject(project, oldVolumeName, volumeType, poolID) if err != nil { return err } err = c.Transaction(func(tx *ClusterTx) error {...
go
func (c *Cluster) StoragePoolVolumeRename(project, oldVolumeName string, newVolumeName string, volumeType int, poolID int64) error { volumeID, _, err := c.StoragePoolNodeVolumeGetTypeByProject(project, oldVolumeName, volumeType, poolID) if err != nil { return err } err = c.Transaction(func(tx *ClusterTx) error {...
[ "func", "(", "c", "*", "Cluster", ")", "StoragePoolVolumeRename", "(", "project", ",", "oldVolumeName", "string", ",", "newVolumeName", "string", ",", "volumeType", "int", ",", "poolID", "int64", ")", "error", "{", "volumeID", ",", "_", ",", "err", ":=", "...
// StoragePoolVolumeRename renames the storage volume attached to a given storage pool.
[ "StoragePoolVolumeRename", "renames", "the", "storage", "volume", "attached", "to", "a", "given", "storage", "pool", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L914-L929
test
lxc/lxd
lxd/db/storage_pools.go
storagePoolVolumeReplicateIfCeph
func storagePoolVolumeReplicateIfCeph(tx *sql.Tx, volumeID int64, project, volumeName string, volumeType int, poolID int64, f func(int64) error) error { driver, err := storagePoolDriverGet(tx, poolID) if err != nil { return err } volumeIDs := []int64{volumeID} // If this is a ceph volume, we want to duplicate t...
go
func storagePoolVolumeReplicateIfCeph(tx *sql.Tx, volumeID int64, project, volumeName string, volumeType int, poolID int64, f func(int64) error) error { driver, err := storagePoolDriverGet(tx, poolID) if err != nil { return err } volumeIDs := []int64{volumeID} // If this is a ceph volume, we want to duplicate t...
[ "func", "storagePoolVolumeReplicateIfCeph", "(", "tx", "*", "sql", ".", "Tx", ",", "volumeID", "int64", ",", "project", ",", "volumeName", "string", ",", "volumeType", "int", ",", "poolID", "int64", ",", "f", "func", "(", "int64", ")", "error", ")", "error...
// This a convenience to replicate a certain volume change to all nodes if the // underlying driver is ceph.
[ "This", "a", "convenience", "to", "replicate", "a", "certain", "volume", "change", "to", "all", "nodes", "if", "the", "underlying", "driver", "is", "ceph", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L933-L957
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolVolumeCreate
func (c *Cluster) StoragePoolVolumeCreate(project, volumeName, volumeDescription string, volumeType int, snapshot bool, poolID int64, volumeConfig map[string]string) (int64, error) { var thisVolumeID int64 err := c.Transaction(func(tx *ClusterTx) error { nodeIDs := []int{int(c.nodeID)} driver, err := storagePool...
go
func (c *Cluster) StoragePoolVolumeCreate(project, volumeName, volumeDescription string, volumeType int, snapshot bool, poolID int64, volumeConfig map[string]string) (int64, error) { var thisVolumeID int64 err := c.Transaction(func(tx *ClusterTx) error { nodeIDs := []int{int(c.nodeID)} driver, err := storagePool...
[ "func", "(", "c", "*", "Cluster", ")", "StoragePoolVolumeCreate", "(", "project", ",", "volumeName", ",", "volumeDescription", "string", ",", "volumeType", "int", ",", "snapshot", "bool", ",", "poolID", "int64", ",", "volumeConfig", "map", "[", "string", "]", ...
// StoragePoolVolumeCreate creates a new storage volume attached to a given // storage pool.
[ "StoragePoolVolumeCreate", "creates", "a", "new", "storage", "volume", "attached", "to", "a", "given", "storage", "pool", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L961-L1009
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolVolumeGetTypeID
func (c *Cluster) StoragePoolVolumeGetTypeID(project string, volumeName string, volumeType int, poolID, nodeID int64) (int64, error) { volumeID := int64(-1) query := `SELECT storage_volumes.id FROM storage_volumes JOIN storage_pools ON storage_volumes.storage_pool_id = storage_pools.id JOIN projects ON storage_volume...
go
func (c *Cluster) StoragePoolVolumeGetTypeID(project string, volumeName string, volumeType int, poolID, nodeID int64) (int64, error) { volumeID := int64(-1) query := `SELECT storage_volumes.id FROM storage_volumes JOIN storage_pools ON storage_volumes.storage_pool_id = storage_pools.id JOIN projects ON storage_volume...
[ "func", "(", "c", "*", "Cluster", ")", "StoragePoolVolumeGetTypeID", "(", "project", "string", ",", "volumeName", "string", ",", "volumeType", "int", ",", "poolID", ",", "nodeID", "int64", ")", "(", "int64", ",", "error", ")", "{", "volumeID", ":=", "int64...
// StoragePoolVolumeGetTypeID returns the ID of a storage volume on a given // storage pool of a given storage volume type, on the given node.
[ "StoragePoolVolumeGetTypeID", "returns", "the", "ID", "of", "a", "storage", "volume", "on", "a", "given", "storage", "pool", "of", "a", "given", "storage", "volume", "type", "on", "the", "given", "node", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L1013-L1033
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolNodeVolumeGetTypeID
func (c *Cluster) StoragePoolNodeVolumeGetTypeID(volumeName string, volumeType int, poolID int64) (int64, error) { return c.StoragePoolVolumeGetTypeID("default", volumeName, volumeType, poolID, c.nodeID) }
go
func (c *Cluster) StoragePoolNodeVolumeGetTypeID(volumeName string, volumeType int, poolID int64) (int64, error) { return c.StoragePoolVolumeGetTypeID("default", volumeName, volumeType, poolID, c.nodeID) }
[ "func", "(", "c", "*", "Cluster", ")", "StoragePoolNodeVolumeGetTypeID", "(", "volumeName", "string", ",", "volumeType", "int", ",", "poolID", "int64", ")", "(", "int64", ",", "error", ")", "{", "return", "c", ".", "StoragePoolVolumeGetTypeID", "(", "\"default...
// StoragePoolNodeVolumeGetTypeID get the ID of a storage volume on a given // storage pool of a given storage volume type, on the current node.
[ "StoragePoolNodeVolumeGetTypeID", "get", "the", "ID", "of", "a", "storage", "volume", "on", "a", "given", "storage", "pool", "of", "a", "given", "storage", "volume", "type", "on", "the", "current", "node", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L1037-L1039
test
lxc/lxd
lxd/db/storage_pools.go
StoragePoolVolumeTypeToName
func StoragePoolVolumeTypeToName(volumeType int) (string, error) { switch volumeType { case StoragePoolVolumeTypeContainer: return StoragePoolVolumeTypeNameContainer, nil case StoragePoolVolumeTypeImage: return StoragePoolVolumeTypeNameImage, nil case StoragePoolVolumeTypeCustom: return StoragePoolVolumeTypeN...
go
func StoragePoolVolumeTypeToName(volumeType int) (string, error) { switch volumeType { case StoragePoolVolumeTypeContainer: return StoragePoolVolumeTypeNameContainer, nil case StoragePoolVolumeTypeImage: return StoragePoolVolumeTypeNameImage, nil case StoragePoolVolumeTypeCustom: return StoragePoolVolumeTypeN...
[ "func", "StoragePoolVolumeTypeToName", "(", "volumeType", "int", ")", "(", "string", ",", "error", ")", "{", "switch", "volumeType", "{", "case", "StoragePoolVolumeTypeContainer", ":", "return", "StoragePoolVolumeTypeNameContainer", ",", "nil", "\n", "case", "StorageP...
// StoragePoolVolumeTypeToName converts a volume integer type code to its // human-readable name.
[ "StoragePoolVolumeTypeToName", "converts", "a", "volume", "integer", "type", "code", "to", "its", "human", "-", "readable", "name", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L1071-L1082
test
lxc/lxd
lxd/db/devices.go
DevicesAdd
func DevicesAdd(tx *sql.Tx, w string, cID int64, devices types.Devices) error { // Prepare the devices entry SQL str1 := fmt.Sprintf("INSERT INTO %ss_devices (%s_id, name, type) VALUES (?, ?, ?)", w, w) stmt1, err := tx.Prepare(str1) if err != nil { return err } defer stmt1.Close() // Prepare the devices conf...
go
func DevicesAdd(tx *sql.Tx, w string, cID int64, devices types.Devices) error { // Prepare the devices entry SQL str1 := fmt.Sprintf("INSERT INTO %ss_devices (%s_id, name, type) VALUES (?, ?, ?)", w, w) stmt1, err := tx.Prepare(str1) if err != nil { return err } defer stmt1.Close() // Prepare the devices conf...
[ "func", "DevicesAdd", "(", "tx", "*", "sql", ".", "Tx", ",", "w", "string", ",", "cID", "int64", ",", "devices", "types", ".", "Devices", ")", "error", "{", "str1", ":=", "fmt", ".", "Sprintf", "(", "\"INSERT INTO %ss_devices (%s_id, name, type) VALUES (?, ?, ...
// DevicesAdd adds a new device.
[ "DevicesAdd", "adds", "a", "new", "device", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/devices.go#L61-L110
test
lxc/lxd
lxd/db/devices.go
Devices
func (c *Cluster) Devices(project, qName string, isprofile bool) (types.Devices, error) { err := c.Transaction(func(tx *ClusterTx) error { enabled, err := tx.ProjectHasProfiles(project) if err != nil { return err } if !enabled { project = "default" } return nil }) if err != nil { return nil, err ...
go
func (c *Cluster) Devices(project, qName string, isprofile bool) (types.Devices, error) { err := c.Transaction(func(tx *ClusterTx) error { enabled, err := tx.ProjectHasProfiles(project) if err != nil { return err } if !enabled { project = "default" } return nil }) if err != nil { return nil, err ...
[ "func", "(", "c", "*", "Cluster", ")", "Devices", "(", "project", ",", "qName", "string", ",", "isprofile", "bool", ")", "(", "types", ".", "Devices", ",", "error", ")", "{", "err", ":=", "c", ".", "Transaction", "(", "func", "(", "tx", "*", "Clust...
// Devices returns the devices matching the given filters.
[ "Devices", "returns", "the", "devices", "matching", "the", "given", "filters", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/devices.go#L141-L196
test
lxc/lxd
lxd/db/patches.go
Patches
func (n *Node) Patches() ([]string, error) { inargs := []interface{}{} outfmt := []interface{}{""} query := fmt.Sprintf("SELECT name FROM patches") result, err := queryScan(n.db, query, inargs, outfmt) if err != nil { return []string{}, err } response := []string{} for _, r := range result { response = ap...
go
func (n *Node) Patches() ([]string, error) { inargs := []interface{}{} outfmt := []interface{}{""} query := fmt.Sprintf("SELECT name FROM patches") result, err := queryScan(n.db, query, inargs, outfmt) if err != nil { return []string{}, err } response := []string{} for _, r := range result { response = ap...
[ "func", "(", "n", "*", "Node", ")", "Patches", "(", ")", "(", "[", "]", "string", ",", "error", ")", "{", "inargs", ":=", "[", "]", "interface", "{", "}", "{", "}", "\n", "outfmt", ":=", "[", "]", "interface", "{", "}", "{", "\"\"", "}", "\n"...
// Patches returns the names of all patches currently applied on this node.
[ "Patches", "returns", "the", "names", "of", "all", "patches", "currently", "applied", "on", "this", "node", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/patches.go#L8-L24
test
lxc/lxd
lxd/db/patches.go
PatchesMarkApplied
func (n *Node) PatchesMarkApplied(patch string) error { stmt := `INSERT INTO patches (name, applied_at) VALUES (?, strftime("%s"));` _, err := n.db.Exec(stmt, patch) return err }
go
func (n *Node) PatchesMarkApplied(patch string) error { stmt := `INSERT INTO patches (name, applied_at) VALUES (?, strftime("%s"));` _, err := n.db.Exec(stmt, patch) return err }
[ "func", "(", "n", "*", "Node", ")", "PatchesMarkApplied", "(", "patch", "string", ")", "error", "{", "stmt", ":=", "`INSERT INTO patches (name, applied_at) VALUES (?, strftime(\"%s\"));`", "\n", "_", ",", "err", ":=", "n", ".", "db", ".", "Exec", "(", "stmt", ...
// PatchesMarkApplied marks the patch with the given name as applied on this node.
[ "PatchesMarkApplied", "marks", "the", "patch", "with", "the", "given", "name", "as", "applied", "on", "this", "node", "." ]
7a41d14e4c1a6bc25918aca91004d594774dcdd3
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/patches.go#L27-L31
test