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 | shared/generate/db/lex.go | entityType | func entityType(pkg string, entity string) string {
typ := lex.Capital(entity)
if pkg != "db" {
typ = pkg + "." + typ
}
return typ
} | go | func entityType(pkg string, entity string) string {
typ := lex.Capital(entity)
if pkg != "db" {
typ = pkg + "." + typ
}
return typ
} | [
"func",
"entityType",
"(",
"pkg",
"string",
",",
"entity",
"string",
")",
"string",
"{",
"typ",
":=",
"lex",
".",
"Capital",
"(",
"entity",
")",
"\n",
"if",
"pkg",
"!=",
"\"db\"",
"{",
"typ",
"=",
"pkg",
"+",
"\".\"",
"+",
"typ",
"\n",
"}",
"\n",
... | // Return Go type of the given database entity. | [
"Return",
"Go",
"type",
"of",
"the",
"given",
"database",
"entity",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/db/lex.go#L16-L22 | test |
lxc/lxd | shared/generate/db/lex.go | entityPost | func entityPost(entity string) string {
return fmt.Sprintf("%sPost", lex.Capital(lex.Plural(entity)))
} | go | func entityPost(entity string) string {
return fmt.Sprintf("%sPost", lex.Capital(lex.Plural(entity)))
} | [
"func",
"entityPost",
"(",
"entity",
"string",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"%sPost\"",
",",
"lex",
".",
"Capital",
"(",
"lex",
".",
"Plural",
"(",
"entity",
")",
")",
")",
"\n",
"}"
] | // Return the name of the Post struct for the given entity. | [
"Return",
"the",
"name",
"of",
"the",
"Post",
"struct",
"for",
"the",
"given",
"entity",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/db/lex.go#L30-L32 | test |
lxc/lxd | shared/generate/db/lex.go | stmtCodeVar | func stmtCodeVar(entity string, kind string, filters ...string) string {
name := fmt.Sprintf("%s%s", entity, lex.Camel(kind))
if len(filters) > 0 {
name += "By"
name += strings.Join(filters, "And")
}
return name
} | go | func stmtCodeVar(entity string, kind string, filters ...string) string {
name := fmt.Sprintf("%s%s", entity, lex.Camel(kind))
if len(filters) > 0 {
name += "By"
name += strings.Join(filters, "And")
}
return name
} | [
"func",
"stmtCodeVar",
"(",
"entity",
"string",
",",
"kind",
"string",
",",
"filters",
"...",
"string",
")",
"string",
"{",
"name",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"%s%s\"",
",",
"entity",
",",
"lex",
".",
"Camel",
"(",
"kind",
")",
")",
"\n",
"i... | // Return the name of the global variable holding the registration code for
// the given kind of statement aganst the given entity. | [
"Return",
"the",
"name",
"of",
"the",
"global",
"variable",
"holding",
"the",
"registration",
"code",
"for",
"the",
"given",
"kind",
"of",
"statement",
"aganst",
"the",
"given",
"entity",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/db/lex.go#L41-L50 | test |
lxc/lxd | shared/generate/db/lex.go | destFunc | func destFunc(slice string, typ string, fields []*Field) string {
f := fmt.Sprintf(`func(i int) []interface{} {
%s = append(%s, %s{})
return []interface{}{
`, slice, slice, typ)
for _, field := range fields {
f += fmt.Sprintf("&%s[i].%s,\n", slice, field.Name)
}
f += ... | go | func destFunc(slice string, typ string, fields []*Field) string {
f := fmt.Sprintf(`func(i int) []interface{} {
%s = append(%s, %s{})
return []interface{}{
`, slice, slice, typ)
for _, field := range fields {
f += fmt.Sprintf("&%s[i].%s,\n", slice, field.Name)
}
f += ... | [
"func",
"destFunc",
"(",
"slice",
"string",
",",
"typ",
"string",
",",
"fields",
"[",
"]",
"*",
"Field",
")",
"string",
"{",
"f",
":=",
"fmt",
".",
"Sprintf",
"(",
"`func(i int) []interface{} { %s = append(%s, %s{}) return []int... | // Return the code for a "dest" function, to be passed as parameter to
// query.SelectObjects in order to scan a single row. | [
"Return",
"the",
"code",
"for",
"a",
"dest",
"function",
"to",
"be",
"passed",
"as",
"parameter",
"to",
"query",
".",
"SelectObjects",
"in",
"order",
"to",
"scan",
"a",
"single",
"row",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/db/lex.go#L73-L87 | test |
lxc/lxd | lxd/util/config.go | CompareConfigs | func CompareConfigs(config1, config2 map[string]string, exclude []string) error {
if exclude == nil {
exclude = []string{}
}
delta := []string{}
for key, value := range config1 {
if shared.StringInSlice(key, exclude) {
continue
}
if config2[key] != value {
delta = append(delta, key)
}
}
for key, ... | go | func CompareConfigs(config1, config2 map[string]string, exclude []string) error {
if exclude == nil {
exclude = []string{}
}
delta := []string{}
for key, value := range config1 {
if shared.StringInSlice(key, exclude) {
continue
}
if config2[key] != value {
delta = append(delta, key)
}
}
for key, ... | [
"func",
"CompareConfigs",
"(",
"config1",
",",
"config2",
"map",
"[",
"string",
"]",
"string",
",",
"exclude",
"[",
"]",
"string",
")",
"error",
"{",
"if",
"exclude",
"==",
"nil",
"{",
"exclude",
"=",
"[",
"]",
"string",
"{",
"}",
"\n",
"}",
"\n",
... | // CompareConfigs compares two config maps and returns an error if they differ. | [
"CompareConfigs",
"compares",
"two",
"config",
"maps",
"and",
"returns",
"an",
"error",
"if",
"they",
"differ",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/util/config.go#L12-L49 | test |
lxc/lxd | lxd/util/config.go | CopyConfig | func CopyConfig(config map[string]string) map[string]string {
copy := map[string]string{}
for key, value := range config {
copy[key] = value
}
return copy
} | go | func CopyConfig(config map[string]string) map[string]string {
copy := map[string]string{}
for key, value := range config {
copy[key] = value
}
return copy
} | [
"func",
"CopyConfig",
"(",
"config",
"map",
"[",
"string",
"]",
"string",
")",
"map",
"[",
"string",
"]",
"string",
"{",
"copy",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"}",
"\n",
"for",
"key",
",",
"value",
":=",
"range",
"config",
"{",
"c... | // CopyConfig creates a new map with a copy of the given config. | [
"CopyConfig",
"creates",
"a",
"new",
"map",
"with",
"a",
"copy",
"of",
"the",
"given",
"config",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/util/config.go#L52-L58 | test |
lxc/lxd | lxd/cluster/notify.go | NewNotifier | func NewNotifier(state *state.State, cert *shared.CertInfo, policy NotifierPolicy) (Notifier, error) {
address, err := node.ClusterAddress(state.Node)
if err != nil {
return nil, errors.Wrap(err, "failed to fetch node address")
}
// Fast-track the case where we're not clustered at all.
if address == "" {
null... | go | func NewNotifier(state *state.State, cert *shared.CertInfo, policy NotifierPolicy) (Notifier, error) {
address, err := node.ClusterAddress(state.Node)
if err != nil {
return nil, errors.Wrap(err, "failed to fetch node address")
}
// Fast-track the case where we're not clustered at all.
if address == "" {
null... | [
"func",
"NewNotifier",
"(",
"state",
"*",
"state",
".",
"State",
",",
"cert",
"*",
"shared",
".",
"CertInfo",
",",
"policy",
"NotifierPolicy",
")",
"(",
"Notifier",
",",
"error",
")",
"{",
"address",
",",
"err",
":=",
"node",
".",
"ClusterAddress",
"(",
... | // NewNotifier builds a Notifier that can be used to notify other peers using
// the given policy. | [
"NewNotifier",
"builds",
"a",
"Notifier",
"that",
"can",
"be",
"used",
"to",
"notify",
"other",
"peers",
"using",
"the",
"given",
"policy",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/notify.go#L33-L112 | test |
lxc/lxd | lxd/cluster/events.go | Events | func Events(endpoints *endpoints.Endpoints, cluster *db.Cluster, f func(int64, api.Event)) (task.Func, task.Schedule) {
listeners := map[int64]*lxd.EventListener{}
// Update our pool of event listeners. Since database queries are
// blocking, we spawn the actual logic in a goroutine, to abort
// immediately when w... | go | func Events(endpoints *endpoints.Endpoints, cluster *db.Cluster, f func(int64, api.Event)) (task.Func, task.Schedule) {
listeners := map[int64]*lxd.EventListener{}
// Update our pool of event listeners. Since database queries are
// blocking, we spawn the actual logic in a goroutine, to abort
// immediately when w... | [
"func",
"Events",
"(",
"endpoints",
"*",
"endpoints",
".",
"Endpoints",
",",
"cluster",
"*",
"db",
".",
"Cluster",
",",
"f",
"func",
"(",
"int64",
",",
"api",
".",
"Event",
")",
")",
"(",
"task",
".",
"Func",
",",
"task",
".",
"Schedule",
")",
"{",... | // Events starts a task that continuously monitors the list of cluster nodes and
// maintains a pool of websocket connections against all of them, in order to
// get notified about events.
//
// Whenever an event is received the given callback is invoked. | [
"Events",
"starts",
"a",
"task",
"that",
"continuously",
"monitors",
"the",
"list",
"of",
"cluster",
"nodes",
"and",
"maintains",
"a",
"pool",
"of",
"websocket",
"connections",
"against",
"all",
"of",
"them",
"in",
"order",
"to",
"get",
"notified",
"about",
... | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/events.go#L21-L43 | test |
lxc/lxd | lxd/cluster/events.go | eventsConnect | func eventsConnect(address string, cert *shared.CertInfo) (*lxd.EventListener, error) {
client, err := Connect(address, cert, true)
if err != nil {
return nil, err
}
// Set the project to the special wildcard in order to get notified
// about all events across all projects.
client = client.UseProject("*")
re... | go | func eventsConnect(address string, cert *shared.CertInfo) (*lxd.EventListener, error) {
client, err := Connect(address, cert, true)
if err != nil {
return nil, err
}
// Set the project to the special wildcard in order to get notified
// about all events across all projects.
client = client.UseProject("*")
re... | [
"func",
"eventsConnect",
"(",
"address",
"string",
",",
"cert",
"*",
"shared",
".",
"CertInfo",
")",
"(",
"*",
"lxd",
".",
"EventListener",
",",
"error",
")",
"{",
"client",
",",
"err",
":=",
"Connect",
"(",
"address",
",",
"cert",
",",
"true",
")",
... | // Establish a client connection to get events from the given node. | [
"Establish",
"a",
"client",
"connection",
"to",
"get",
"events",
"from",
"the",
"given",
"node",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/events.go#L115-L126 | test |
lxc/lxd | lxd/storage_dir.go | StoragePoolInit | func (s *storageDir) StoragePoolInit() error {
err := s.StorageCoreInit()
if err != nil {
return err
}
return nil
} | go | func (s *storageDir) StoragePoolInit() error {
err := s.StorageCoreInit()
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"s",
"*",
"storageDir",
")",
"StoragePoolInit",
"(",
")",
"error",
"{",
"err",
":=",
"s",
".",
"StorageCoreInit",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] | // Initialize a full storage interface. | [
"Initialize",
"a",
"full",
"storage",
"interface",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage_dir.go#L44-L51 | test |
lxc/lxd | lxd/apparmor.go | getAAProfileContent | func getAAProfileContent(c container) string {
profile := strings.TrimLeft(AA_PROFILE_BASE, "\n")
// Apply new features
if aaParserSupports("unix") {
profile += `
### Feature: unix
# Allow receive via unix sockets from anywhere
unix (receive),
# Allow all unix in the container
unix peer=(label=@{profil... | go | func getAAProfileContent(c container) string {
profile := strings.TrimLeft(AA_PROFILE_BASE, "\n")
// Apply new features
if aaParserSupports("unix") {
profile += `
### Feature: unix
# Allow receive via unix sockets from anywhere
unix (receive),
# Allow all unix in the container
unix peer=(label=@{profil... | [
"func",
"getAAProfileContent",
"(",
"c",
"container",
")",
"string",
"{",
"profile",
":=",
"strings",
".",
"TrimLeft",
"(",
"AA_PROFILE_BASE",
",",
"\"\\n\"",
")",
"\n",
"\\n",
"\n",
"if",
"aaParserSupports",
"(",
"\"unix\"",
")",
"{",
"profile",
"+=",
"` #... | // getProfileContent generates the apparmor profile template from the given
// container. This includes the stock lxc includes as well as stuff from
// raw.apparmor. | [
"getProfileContent",
"generates",
"the",
"apparmor",
"profile",
"template",
"from",
"the",
"given",
"container",
".",
"This",
"includes",
"the",
"stock",
"lxc",
"includes",
"as",
"well",
"as",
"stuff",
"from",
"raw",
".",
"apparmor",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/apparmor.go#L517-L604 | test |
lxc/lxd | lxd/apparmor.go | AALoadProfile | func AALoadProfile(c container) error {
state := c.DaemonState()
if !state.OS.AppArmorAdmin {
return nil
}
if err := mkApparmorNamespace(c, AANamespace(c)); err != nil {
return err
}
/* In order to avoid forcing a profile parse (potentially slow) on
* every container start, let's use apparmor's binary pol... | go | func AALoadProfile(c container) error {
state := c.DaemonState()
if !state.OS.AppArmorAdmin {
return nil
}
if err := mkApparmorNamespace(c, AANamespace(c)); err != nil {
return err
}
/* In order to avoid forcing a profile parse (potentially slow) on
* every container start, let's use apparmor's binary pol... | [
"func",
"AALoadProfile",
"(",
"c",
"container",
")",
"error",
"{",
"state",
":=",
"c",
".",
"DaemonState",
"(",
")",
"\n",
"if",
"!",
"state",
".",
"OS",
".",
"AppArmorAdmin",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"err",
":=",
"mkApparmorNamespa... | // Ensure that the container's policy is loaded into the kernel so the
// container can boot. | [
"Ensure",
"that",
"the",
"container",
"s",
"policy",
"is",
"loaded",
"into",
"the",
"kernel",
"so",
"the",
"container",
"can",
"boot",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/apparmor.go#L663-L707 | test |
lxc/lxd | lxd/apparmor.go | AADestroy | func AADestroy(c container) error {
state := c.DaemonState()
if !state.OS.AppArmorAdmin {
return nil
}
if state.OS.AppArmorStacking && !state.OS.AppArmorStacked {
p := path.Join("/sys/kernel/security/apparmor/policy/namespaces", AANamespace(c))
if err := os.Remove(p); err != nil {
logger.Error("Error remo... | go | func AADestroy(c container) error {
state := c.DaemonState()
if !state.OS.AppArmorAdmin {
return nil
}
if state.OS.AppArmorStacking && !state.OS.AppArmorStacked {
p := path.Join("/sys/kernel/security/apparmor/policy/namespaces", AANamespace(c))
if err := os.Remove(p); err != nil {
logger.Error("Error remo... | [
"func",
"AADestroy",
"(",
"c",
"container",
")",
"error",
"{",
"state",
":=",
"c",
".",
"DaemonState",
"(",
")",
"\n",
"if",
"!",
"state",
".",
"OS",
".",
"AppArmorAdmin",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"if",
"state",
".",
"OS",
".",
"AppAr... | // Ensure that the container's policy namespace is unloaded to free kernel
// memory. This does not delete the policy from disk or cache. | [
"Ensure",
"that",
"the",
"container",
"s",
"policy",
"namespace",
"is",
"unloaded",
"to",
"free",
"kernel",
"memory",
".",
"This",
"does",
"not",
"delete",
"the",
"policy",
"from",
"disk",
"or",
"cache",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/apparmor.go#L711-L725 | test |
lxc/lxd | lxd/apparmor.go | AAParseProfile | func AAParseProfile(c container) error {
state := c.DaemonState()
if !state.OS.AppArmorAvailable {
return nil
}
return runApparmor(APPARMOR_CMD_PARSE, c)
} | go | func AAParseProfile(c container) error {
state := c.DaemonState()
if !state.OS.AppArmorAvailable {
return nil
}
return runApparmor(APPARMOR_CMD_PARSE, c)
} | [
"func",
"AAParseProfile",
"(",
"c",
"container",
")",
"error",
"{",
"state",
":=",
"c",
".",
"DaemonState",
"(",
")",
"\n",
"if",
"!",
"state",
".",
"OS",
".",
"AppArmorAvailable",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"runApparmor",
"(",
"A... | // Parse the profile without loading it into the kernel. | [
"Parse",
"the",
"profile",
"without",
"loading",
"it",
"into",
"the",
"kernel",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/apparmor.go#L728-L735 | test |
lxc/lxd | shared/logging/log_windows.go | getSystemHandler | func getSystemHandler(syslog string, debug bool, format log.Format) log.Handler {
return nil
} | go | func getSystemHandler(syslog string, debug bool, format log.Format) log.Handler {
return nil
} | [
"func",
"getSystemHandler",
"(",
"syslog",
"string",
",",
"debug",
"bool",
",",
"format",
"log",
".",
"Format",
")",
"log",
".",
"Handler",
"{",
"return",
"nil",
"\n",
"}"
] | // getSystemHandler on Windows does nothing. | [
"getSystemHandler",
"on",
"Windows",
"does",
"nothing",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/logging/log_windows.go#L10-L12 | test |
lxc/lxd | lxd/cluster/upgrade.go | NotifyUpgradeCompleted | func NotifyUpgradeCompleted(state *state.State, cert *shared.CertInfo) error {
notifier, err := NewNotifier(state, cert, NotifyAll)
if err != nil {
return err
}
return notifier(func(client lxd.ContainerServer) error {
info, err := client.GetConnectionInfo()
if err != nil {
return errors.Wrap(err, "failed t... | go | func NotifyUpgradeCompleted(state *state.State, cert *shared.CertInfo) error {
notifier, err := NewNotifier(state, cert, NotifyAll)
if err != nil {
return err
}
return notifier(func(client lxd.ContainerServer) error {
info, err := client.GetConnectionInfo()
if err != nil {
return errors.Wrap(err, "failed t... | [
"func",
"NotifyUpgradeCompleted",
"(",
"state",
"*",
"state",
".",
"State",
",",
"cert",
"*",
"shared",
".",
"CertInfo",
")",
"error",
"{",
"notifier",
",",
"err",
":=",
"NewNotifier",
"(",
"state",
",",
"cert",
",",
"NotifyAll",
")",
"\n",
"if",
"err",
... | // NotifyUpgradeCompleted sends a notification to all other nodes in the
// cluster that any possible pending database update has been applied, and any
// nodes which was waiting for this node to be upgraded should re-check if it's
// okay to move forward. | [
"NotifyUpgradeCompleted",
"sends",
"a",
"notification",
"to",
"all",
"other",
"nodes",
"in",
"the",
"cluster",
"that",
"any",
"possible",
"pending",
"database",
"update",
"has",
"been",
"applied",
"and",
"any",
"nodes",
"which",
"was",
"waiting",
"for",
"this",
... | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/upgrade.go#L23-L56 | test |
lxc/lxd | lxd/cluster/upgrade.go | KeepUpdated | func KeepUpdated(state *state.State) (task.Func, task.Schedule) {
f := func(ctx context.Context) {
ch := make(chan struct{})
go func() {
maybeUpdate(state)
close(ch)
}()
select {
case <-ctx.Done():
case <-ch:
}
}
schedule := task.Every(5 * time.Minute)
return f, schedule
} | go | func KeepUpdated(state *state.State) (task.Func, task.Schedule) {
f := func(ctx context.Context) {
ch := make(chan struct{})
go func() {
maybeUpdate(state)
close(ch)
}()
select {
case <-ctx.Done():
case <-ch:
}
}
schedule := task.Every(5 * time.Minute)
return f, schedule
} | [
"func",
"KeepUpdated",
"(",
"state",
"*",
"state",
".",
"State",
")",
"(",
"task",
".",
"Func",
",",
"task",
".",
"Schedule",
")",
"{",
"f",
":=",
"func",
"(",
"ctx",
"context",
".",
"Context",
")",
"{",
"ch",
":=",
"make",
"(",
"chan",
"struct",
... | // KeepUpdated is a task that continuously monitor this node's version to see it
// it's out of date with respect to other nodes. In the node is out of date,
// and the LXD_CLUSTER_UPDATE environment variable is set, then the task
// executes the executable that the variable is pointing at. | [
"KeepUpdated",
"is",
"a",
"task",
"that",
"continuously",
"monitor",
"this",
"node",
"s",
"version",
"to",
"see",
"it",
"it",
"s",
"out",
"of",
"date",
"with",
"respect",
"to",
"other",
"nodes",
".",
"In",
"the",
"node",
"is",
"out",
"of",
"date",
"and... | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/upgrade.go#L62-L78 | test |
lxc/lxd | lxd/cluster/upgrade.go | maybeUpdate | func maybeUpdate(state *state.State) {
shouldUpdate := false
enabled, err := Enabled(state.Node)
if err != nil {
logger.Errorf("Failed to check clustering is enabled: %v", err)
return
}
if !enabled {
return
}
err = state.Cluster.Transaction(func(tx *db.ClusterTx) error {
outdated, err := tx.NodeIsOutda... | go | func maybeUpdate(state *state.State) {
shouldUpdate := false
enabled, err := Enabled(state.Node)
if err != nil {
logger.Errorf("Failed to check clustering is enabled: %v", err)
return
}
if !enabled {
return
}
err = state.Cluster.Transaction(func(tx *db.ClusterTx) error {
outdated, err := tx.NodeIsOutda... | [
"func",
"maybeUpdate",
"(",
"state",
"*",
"state",
".",
"State",
")",
"{",
"shouldUpdate",
":=",
"false",
"\n",
"enabled",
",",
"err",
":=",
"Enabled",
"(",
"state",
".",
"Node",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"logger",
".",
"Errorf",
"(",... | // Check this node's version and possibly run LXD_CLUSTER_UPDATE. | [
"Check",
"this",
"node",
"s",
"version",
"and",
"possibly",
"run",
"LXD_CLUSTER_UPDATE",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/upgrade.go#L81-L128 | test |
lxc/lxd | lxd/rbac/server.go | NewServer | func NewServer(apiURL string, apiKey string, agentAuthURL string, agentUsername string, agentPrivateKey string, agentPublicKey string) (*Server, error) {
r := Server{
apiURL: apiURL,
apiKey: apiKey,
lastSyncID: "",
lastChange: time.Time{},
resources: make(map[string]string),... | go | func NewServer(apiURL string, apiKey string, agentAuthURL string, agentUsername string, agentPrivateKey string, agentPublicKey string) (*Server, error) {
r := Server{
apiURL: apiURL,
apiKey: apiKey,
lastSyncID: "",
lastChange: time.Time{},
resources: make(map[string]string),... | [
"func",
"NewServer",
"(",
"apiURL",
"string",
",",
"apiKey",
"string",
",",
"agentAuthURL",
"string",
",",
"agentUsername",
"string",
",",
"agentPrivateKey",
"string",
",",
"agentPublicKey",
"string",
")",
"(",
"*",
"Server",
",",
"error",
")",
"{",
"r",
":=... | // NewServer returns a new RBAC server instance. | [
"NewServer",
"returns",
"a",
"new",
"RBAC",
"server",
"instance",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/rbac/server.go#L64-L102 | test |
lxc/lxd | lxd/rbac/server.go | StartStatusCheck | func (r *Server) StartStatusCheck() {
// Initialize the last changed timestamp
r.hasStatusChanged()
r.statusDone = make(chan int)
go func() {
for {
select {
case <-r.statusDone:
return
case <-time.After(time.Minute):
if r.hasStatusChanged() {
r.flushCache()
}
}
}
}()
} | go | func (r *Server) StartStatusCheck() {
// Initialize the last changed timestamp
r.hasStatusChanged()
r.statusDone = make(chan int)
go func() {
for {
select {
case <-r.statusDone:
return
case <-time.After(time.Minute):
if r.hasStatusChanged() {
r.flushCache()
}
}
}
}()
} | [
"func",
"(",
"r",
"*",
"Server",
")",
"StartStatusCheck",
"(",
")",
"{",
"r",
".",
"hasStatusChanged",
"(",
")",
"\n",
"r",
".",
"statusDone",
"=",
"make",
"(",
"chan",
"int",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"for",
"{",
"select",
"{",
"ca... | // StartStatusCheck starts a periodic status checker. | [
"StartStatusCheck",
"starts",
"a",
"periodic",
"status",
"checker",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/rbac/server.go#L105-L122 | test |
lxc/lxd | lxd/rbac/server.go | SyncProjects | func (r *Server) SyncProjects() error {
if r.ProjectsFunc == nil {
return fmt.Errorf("ProjectsFunc isn't configured yet, cannot sync")
}
resources := []rbacResource{}
resourcesMap := map[string]string{}
// Get all projects
projects, err := r.ProjectsFunc()
if err != nil {
return err
}
// Convert to RBAC... | go | func (r *Server) SyncProjects() error {
if r.ProjectsFunc == nil {
return fmt.Errorf("ProjectsFunc isn't configured yet, cannot sync")
}
resources := []rbacResource{}
resourcesMap := map[string]string{}
// Get all projects
projects, err := r.ProjectsFunc()
if err != nil {
return err
}
// Convert to RBAC... | [
"func",
"(",
"r",
"*",
"Server",
")",
"SyncProjects",
"(",
")",
"error",
"{",
"if",
"r",
".",
"ProjectsFunc",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"ProjectsFunc isn't configured yet, cannot sync\"",
")",
"\n",
"}",
"\n",
"resources",
":="... | // SyncProjects updates the list of projects in RBAC | [
"SyncProjects",
"updates",
"the",
"list",
"of",
"projects",
"in",
"RBAC"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/rbac/server.go#L130-L166 | test |
lxc/lxd | lxd/rbac/server.go | AddProject | func (r *Server) AddProject(id int64, name string) error {
resource := rbacResource{
Name: name,
Identifier: strconv.FormatInt(id, 10),
}
// Update RBAC
err := r.postResources([]rbacResource{resource}, nil, false)
if err != nil {
return err
}
// Update project map
r.resourcesLock.Lock()
r.resourc... | go | func (r *Server) AddProject(id int64, name string) error {
resource := rbacResource{
Name: name,
Identifier: strconv.FormatInt(id, 10),
}
// Update RBAC
err := r.postResources([]rbacResource{resource}, nil, false)
if err != nil {
return err
}
// Update project map
r.resourcesLock.Lock()
r.resourc... | [
"func",
"(",
"r",
"*",
"Server",
")",
"AddProject",
"(",
"id",
"int64",
",",
"name",
"string",
")",
"error",
"{",
"resource",
":=",
"rbacResource",
"{",
"Name",
":",
"name",
",",
"Identifier",
":",
"strconv",
".",
"FormatInt",
"(",
"id",
",",
"10",
"... | // AddProject adds a new project resource to RBAC. | [
"AddProject",
"adds",
"a",
"new",
"project",
"resource",
"to",
"RBAC",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/rbac/server.go#L169-L187 | test |
lxc/lxd | lxd/rbac/server.go | DeleteProject | func (r *Server) DeleteProject(id int64) error {
// Update RBAC
err := r.postResources(nil, []string{strconv.FormatInt(id, 10)}, false)
if err != nil {
return err
}
// Update project map
r.resourcesLock.Lock()
for k, v := range r.resources {
if v == strconv.FormatInt(id, 10) {
delete(r.resources, k)
b... | go | func (r *Server) DeleteProject(id int64) error {
// Update RBAC
err := r.postResources(nil, []string{strconv.FormatInt(id, 10)}, false)
if err != nil {
return err
}
// Update project map
r.resourcesLock.Lock()
for k, v := range r.resources {
if v == strconv.FormatInt(id, 10) {
delete(r.resources, k)
b... | [
"func",
"(",
"r",
"*",
"Server",
")",
"DeleteProject",
"(",
"id",
"int64",
")",
"error",
"{",
"err",
":=",
"r",
".",
"postResources",
"(",
"nil",
",",
"[",
"]",
"string",
"{",
"strconv",
".",
"FormatInt",
"(",
"id",
",",
"10",
")",
"}",
",",
"fal... | // DeleteProject adds a new project resource to RBAC. | [
"DeleteProject",
"adds",
"a",
"new",
"project",
"resource",
"to",
"RBAC",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/rbac/server.go#L190-L208 | test |
lxc/lxd | lxd/rbac/server.go | RenameProject | func (r *Server) RenameProject(id int64, name string) error {
return r.AddProject(id, name)
} | go | func (r *Server) RenameProject(id int64, name string) error {
return r.AddProject(id, name)
} | [
"func",
"(",
"r",
"*",
"Server",
")",
"RenameProject",
"(",
"id",
"int64",
",",
"name",
"string",
")",
"error",
"{",
"return",
"r",
".",
"AddProject",
"(",
"id",
",",
"name",
")",
"\n",
"}"
] | // RenameProject renames an existing project resource in RBAC. | [
"RenameProject",
"renames",
"an",
"existing",
"project",
"resource",
"in",
"RBAC",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/rbac/server.go#L211-L213 | test |
lxc/lxd | lxd/rbac/server.go | IsAdmin | func (r *Server) IsAdmin(username string) bool {
r.permissionsLock.Lock()
defer r.permissionsLock.Unlock()
// Check whether the permissions are cached
_, cached := r.permissions[username]
if !cached {
r.syncPermissions(username)
}
return shared.StringInSlice("admin", r.permissions[username][""])
} | go | func (r *Server) IsAdmin(username string) bool {
r.permissionsLock.Lock()
defer r.permissionsLock.Unlock()
// Check whether the permissions are cached
_, cached := r.permissions[username]
if !cached {
r.syncPermissions(username)
}
return shared.StringInSlice("admin", r.permissions[username][""])
} | [
"func",
"(",
"r",
"*",
"Server",
")",
"IsAdmin",
"(",
"username",
"string",
")",
"bool",
"{",
"r",
".",
"permissionsLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"r",
".",
"permissionsLock",
".",
"Unlock",
"(",
")",
"\n",
"_",
",",
"cached",
":=",
"... | // IsAdmin returns whether or not the provided user is an admin. | [
"IsAdmin",
"returns",
"whether",
"or",
"not",
"the",
"provided",
"user",
"is",
"an",
"admin",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/rbac/server.go#L216-L228 | test |
lxc/lxd | lxd/rbac/server.go | HasPermission | func (r *Server) HasPermission(username, project, permission string) bool {
r.permissionsLock.Lock()
defer r.permissionsLock.Unlock()
// Check whether the permissions are cached
_, cached := r.permissions[username]
if !cached {
r.syncPermissions(username)
}
r.resourcesLock.Lock()
permissions := r.permissio... | go | func (r *Server) HasPermission(username, project, permission string) bool {
r.permissionsLock.Lock()
defer r.permissionsLock.Unlock()
// Check whether the permissions are cached
_, cached := r.permissions[username]
if !cached {
r.syncPermissions(username)
}
r.resourcesLock.Lock()
permissions := r.permissio... | [
"func",
"(",
"r",
"*",
"Server",
")",
"HasPermission",
"(",
"username",
",",
"project",
",",
"permission",
"string",
")",
"bool",
"{",
"r",
".",
"permissionsLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"r",
".",
"permissionsLock",
".",
"Unlock",
"(",
"... | // HasPermission returns whether or not the user has the permission to perform a certain task. | [
"HasPermission",
"returns",
"whether",
"or",
"not",
"the",
"user",
"has",
"the",
"permission",
"to",
"perform",
"a",
"certain",
"task",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/rbac/server.go#L231-L247 | test |
lxc/lxd | lxd-p2c/transfer.go | rsyncSend | func rsyncSend(conn *websocket.Conn, path string, rsyncArgs string) error {
cmd, dataSocket, stderr, err := rsyncSendSetup(path, rsyncArgs)
if err != nil {
return err
}
if dataSocket != nil {
defer dataSocket.Close()
}
readDone, writeDone := shared.WebsocketMirror(conn, dataSocket, io.ReadCloser(dataSocket)... | go | func rsyncSend(conn *websocket.Conn, path string, rsyncArgs string) error {
cmd, dataSocket, stderr, err := rsyncSendSetup(path, rsyncArgs)
if err != nil {
return err
}
if dataSocket != nil {
defer dataSocket.Close()
}
readDone, writeDone := shared.WebsocketMirror(conn, dataSocket, io.ReadCloser(dataSocket)... | [
"func",
"rsyncSend",
"(",
"conn",
"*",
"websocket",
".",
"Conn",
",",
"path",
"string",
",",
"rsyncArgs",
"string",
")",
"error",
"{",
"cmd",
",",
"dataSocket",
",",
"stderr",
",",
"err",
":=",
"rsyncSendSetup",
"(",
"path",
",",
"rsyncArgs",
")",
"\n",
... | // Send an rsync stream of a path over a websocket | [
"Send",
"an",
"rsync",
"stream",
"of",
"a",
"path",
"over",
"a",
"websocket"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd-p2c/transfer.go#L21-L49 | test |
lxc/lxd | lxd-p2c/transfer.go | rsyncSendSetup | func rsyncSendSetup(path string, rsyncArgs string) (*exec.Cmd, net.Conn, io.ReadCloser, error) {
auds := fmt.Sprintf("@lxd-p2c/%s", uuid.NewRandom().String())
if len(auds) > shared.ABSTRACT_UNIX_SOCK_LEN-1 {
auds = auds[:shared.ABSTRACT_UNIX_SOCK_LEN-1]
}
l, err := net.Listen("unix", auds)
if err != nil {
ret... | go | func rsyncSendSetup(path string, rsyncArgs string) (*exec.Cmd, net.Conn, io.ReadCloser, error) {
auds := fmt.Sprintf("@lxd-p2c/%s", uuid.NewRandom().String())
if len(auds) > shared.ABSTRACT_UNIX_SOCK_LEN-1 {
auds = auds[:shared.ABSTRACT_UNIX_SOCK_LEN-1]
}
l, err := net.Listen("unix", auds)
if err != nil {
ret... | [
"func",
"rsyncSendSetup",
"(",
"path",
"string",
",",
"rsyncArgs",
"string",
")",
"(",
"*",
"exec",
".",
"Cmd",
",",
"net",
".",
"Conn",
",",
"io",
".",
"ReadCloser",
",",
"error",
")",
"{",
"auds",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"@lxd-p2c/%s\"",
... | // Spawn the rsync process | [
"Spawn",
"the",
"rsync",
"process"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd-p2c/transfer.go#L52-L139 | test |
lxc/lxd | lxd/cluster/tls.go | tlsClientConfig | func tlsClientConfig(info *shared.CertInfo) (*tls.Config, error) {
keypair := info.KeyPair()
ca := info.CA()
config := shared.InitTLSConfig()
config.Certificates = []tls.Certificate{keypair}
config.RootCAs = x509.NewCertPool()
if ca != nil {
config.RootCAs.AddCert(ca)
}
// Since the same cluster keypair is us... | go | func tlsClientConfig(info *shared.CertInfo) (*tls.Config, error) {
keypair := info.KeyPair()
ca := info.CA()
config := shared.InitTLSConfig()
config.Certificates = []tls.Certificate{keypair}
config.RootCAs = x509.NewCertPool()
if ca != nil {
config.RootCAs.AddCert(ca)
}
// Since the same cluster keypair is us... | [
"func",
"tlsClientConfig",
"(",
"info",
"*",
"shared",
".",
"CertInfo",
")",
"(",
"*",
"tls",
".",
"Config",
",",
"error",
")",
"{",
"keypair",
":=",
"info",
".",
"KeyPair",
"(",
")",
"\n",
"ca",
":=",
"info",
".",
"CA",
"(",
")",
"\n",
"config",
... | // Return a TLS configuration suitable for establishing inter-node network
// connections using the cluster certificate. | [
"Return",
"a",
"TLS",
"configuration",
"suitable",
"for",
"establishing",
"inter",
"-",
"node",
"network",
"connections",
"using",
"the",
"cluster",
"certificate",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/tls.go#L15-L38 | test |
lxc/lxd | lxd/cluster/tls.go | tlsCheckCert | func tlsCheckCert(r *http.Request, info *shared.CertInfo) bool {
cert, err := x509.ParseCertificate(info.KeyPair().Certificate[0])
if err != nil {
// Since we have already loaded this certificate, typically
// using LoadX509KeyPair, an error should never happen, but
// check for good measure.
panic(fmt.Sprint... | go | func tlsCheckCert(r *http.Request, info *shared.CertInfo) bool {
cert, err := x509.ParseCertificate(info.KeyPair().Certificate[0])
if err != nil {
// Since we have already loaded this certificate, typically
// using LoadX509KeyPair, an error should never happen, but
// check for good measure.
panic(fmt.Sprint... | [
"func",
"tlsCheckCert",
"(",
"r",
"*",
"http",
".",
"Request",
",",
"info",
"*",
"shared",
".",
"CertInfo",
")",
"bool",
"{",
"cert",
",",
"err",
":=",
"x509",
".",
"ParseCertificate",
"(",
"info",
".",
"KeyPair",
"(",
")",
".",
"Certificate",
"[",
"... | // Return true if the given request is presenting the given cluster certificate. | [
"Return",
"true",
"if",
"the",
"given",
"request",
"is",
"presenting",
"the",
"given",
"cluster",
"certificate",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/tls.go#L41-L54 | test |
lxc/lxd | lxd/container_post.go | internalClusterContainerMovedPost | func internalClusterContainerMovedPost(d *Daemon, r *http.Request) Response {
project := projectParam(r)
containerName := mux.Vars(r)["name"]
err := containerPostCreateContainerMountPoint(d, project, containerName)
if err != nil {
return SmartError(err)
}
return EmptySyncResponse
} | go | func internalClusterContainerMovedPost(d *Daemon, r *http.Request) Response {
project := projectParam(r)
containerName := mux.Vars(r)["name"]
err := containerPostCreateContainerMountPoint(d, project, containerName)
if err != nil {
return SmartError(err)
}
return EmptySyncResponse
} | [
"func",
"internalClusterContainerMovedPost",
"(",
"d",
"*",
"Daemon",
",",
"r",
"*",
"http",
".",
"Request",
")",
"Response",
"{",
"project",
":=",
"projectParam",
"(",
"r",
")",
"\n",
"containerName",
":=",
"mux",
".",
"Vars",
"(",
"r",
")",
"[",
"\"nam... | // Notification that a container was moved.
//
// At the moment it's used for ceph-based containers, where the target node needs
// to create the appropriate mount points. | [
"Notification",
"that",
"a",
"container",
"was",
"moved",
".",
"At",
"the",
"moment",
"it",
"s",
"used",
"for",
"ceph",
"-",
"based",
"containers",
"where",
"the",
"target",
"node",
"needs",
"to",
"create",
"the",
"appropriate",
"mount",
"points",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/container_post.go#L505-L513 | test |
lxc/lxd | lxd/container_post.go | containerPostCreateContainerMountPoint | func containerPostCreateContainerMountPoint(d *Daemon, project, containerName string) error {
c, err := containerLoadByProjectAndName(d.State(), project, containerName)
if err != nil {
return errors.Wrap(err, "Failed to load moved container on target node")
}
poolName, err := c.StoragePool()
if err != nil {
re... | go | func containerPostCreateContainerMountPoint(d *Daemon, project, containerName string) error {
c, err := containerLoadByProjectAndName(d.State(), project, containerName)
if err != nil {
return errors.Wrap(err, "Failed to load moved container on target node")
}
poolName, err := c.StoragePool()
if err != nil {
re... | [
"func",
"containerPostCreateContainerMountPoint",
"(",
"d",
"*",
"Daemon",
",",
"project",
",",
"containerName",
"string",
")",
"error",
"{",
"c",
",",
"err",
":=",
"containerLoadByProjectAndName",
"(",
"d",
".",
"State",
"(",
")",
",",
"project",
",",
"contai... | // Used after to create the appropriate mounts point after a container has been
// moved. | [
"Used",
"after",
"to",
"create",
"the",
"appropriate",
"mounts",
"point",
"after",
"a",
"container",
"has",
"been",
"moved",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/container_post.go#L517-L549 | test |
lxc/lxd | lxd/types/devices.go | Contains | func (list Devices) Contains(k string, d Device) bool {
// If it didn't exist, it's different
if list[k] == nil {
return false
}
old := list[k]
return deviceEquals(old, d)
} | go | func (list Devices) Contains(k string, d Device) bool {
// If it didn't exist, it's different
if list[k] == nil {
return false
}
old := list[k]
return deviceEquals(old, d)
} | [
"func",
"(",
"list",
"Devices",
")",
"Contains",
"(",
"k",
"string",
",",
"d",
"Device",
")",
"bool",
"{",
"if",
"list",
"[",
"k",
"]",
"==",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"old",
":=",
"list",
"[",
"k",
"]",
"\n",
"return",
"d... | // Contains checks if a given device exists in the set and if it's
// identical to that provided | [
"Contains",
"checks",
"if",
"a",
"given",
"device",
"exists",
"in",
"the",
"set",
"and",
"if",
"it",
"s",
"identical",
"to",
"that",
"provided"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/types/devices.go#L17-L26 | test |
lxc/lxd | lxd/types/devices.go | Update | func (list Devices) Update(newlist Devices) (map[string]Device, map[string]Device, map[string]Device, []string) {
rmlist := map[string]Device{}
addlist := map[string]Device{}
updatelist := map[string]Device{}
for key, d := range list {
if !newlist.Contains(key, d) {
rmlist[key] = d
}
}
for key, d := rang... | go | func (list Devices) Update(newlist Devices) (map[string]Device, map[string]Device, map[string]Device, []string) {
rmlist := map[string]Device{}
addlist := map[string]Device{}
updatelist := map[string]Device{}
for key, d := range list {
if !newlist.Contains(key, d) {
rmlist[key] = d
}
}
for key, d := rang... | [
"func",
"(",
"list",
"Devices",
")",
"Update",
"(",
"newlist",
"Devices",
")",
"(",
"map",
"[",
"string",
"]",
"Device",
",",
"map",
"[",
"string",
"]",
"Device",
",",
"map",
"[",
"string",
"]",
"Device",
",",
"[",
"]",
"string",
")",
"{",
"rmlist"... | // Update returns the difference between two sets | [
"Update",
"returns",
"the",
"difference",
"between",
"two",
"sets"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/types/devices.go#L29-L77 | test |
lxc/lxd | lxd/types/devices.go | DeviceNames | func (list Devices) DeviceNames() []string {
sortable := sortableDevices{}
for k, d := range list {
sortable = append(sortable, namedDevice{k, d})
}
sort.Sort(sortable)
return sortable.Names()
} | go | func (list Devices) DeviceNames() []string {
sortable := sortableDevices{}
for k, d := range list {
sortable = append(sortable, namedDevice{k, d})
}
sort.Sort(sortable)
return sortable.Names()
} | [
"func",
"(",
"list",
"Devices",
")",
"DeviceNames",
"(",
")",
"[",
"]",
"string",
"{",
"sortable",
":=",
"sortableDevices",
"{",
"}",
"\n",
"for",
"k",
",",
"d",
":=",
"range",
"list",
"{",
"sortable",
"=",
"append",
"(",
"sortable",
",",
"namedDevice"... | // DeviceNames returns the name of all devices in the set, sorted properly | [
"DeviceNames",
"returns",
"the",
"name",
"of",
"all",
"devices",
"in",
"the",
"set",
"sorted",
"properly"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/types/devices.go#L80-L88 | test |
lxc/lxd | shared/logger/log.go | Infof | func Infof(format string, args ...interface{}) {
if Log != nil {
Log.Info(fmt.Sprintf(format, args...))
}
} | go | func Infof(format string, args ...interface{}) {
if Log != nil {
Log.Info(fmt.Sprintf(format, args...))
}
} | [
"func",
"Infof",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"Log",
"!=",
"nil",
"{",
"Log",
".",
"Info",
"(",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"args",
"...",
")",
")",
"\n",
"}",
"\n",
"}"
] | // Infof logs at the INFO log level using a standard printf format string | [
"Infof",
"logs",
"at",
"the",
"INFO",
"log",
"level",
"using",
"a",
"standard",
"printf",
"format",
"string"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/logger/log.go#L69-L73 | test |
lxc/lxd | shared/logger/log.go | Debugf | func Debugf(format string, args ...interface{}) {
if Log != nil {
Log.Debug(fmt.Sprintf(format, args...))
}
} | go | func Debugf(format string, args ...interface{}) {
if Log != nil {
Log.Debug(fmt.Sprintf(format, args...))
}
} | [
"func",
"Debugf",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"Log",
"!=",
"nil",
"{",
"Log",
".",
"Debug",
"(",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"args",
"...",
")",
")",
"\n",
"}",
"\n",
"}"
] | // Debugf logs at the DEBUG log level using a standard printf format string | [
"Debugf",
"logs",
"at",
"the",
"DEBUG",
"log",
"level",
"using",
"a",
"standard",
"printf",
"format",
"string"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/logger/log.go#L76-L80 | test |
lxc/lxd | shared/logger/log.go | Warnf | func Warnf(format string, args ...interface{}) {
if Log != nil {
Log.Warn(fmt.Sprintf(format, args...))
}
} | go | func Warnf(format string, args ...interface{}) {
if Log != nil {
Log.Warn(fmt.Sprintf(format, args...))
}
} | [
"func",
"Warnf",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"Log",
"!=",
"nil",
"{",
"Log",
".",
"Warn",
"(",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"args",
"...",
")",
")",
"\n",
"}",
"\n",
"}"
] | // Warnf logs at the WARNING log level using a standard printf format string | [
"Warnf",
"logs",
"at",
"the",
"WARNING",
"log",
"level",
"using",
"a",
"standard",
"printf",
"format",
"string"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/logger/log.go#L83-L87 | test |
lxc/lxd | shared/logger/log.go | Errorf | func Errorf(format string, args ...interface{}) {
if Log != nil {
Log.Error(fmt.Sprintf(format, args...))
}
} | go | func Errorf(format string, args ...interface{}) {
if Log != nil {
Log.Error(fmt.Sprintf(format, args...))
}
} | [
"func",
"Errorf",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"Log",
"!=",
"nil",
"{",
"Log",
".",
"Error",
"(",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"args",
"...",
")",
")",
"\n",
"}",
"\n",
"}"
] | // Errorf logs at the ERROR log level using a standard printf format string | [
"Errorf",
"logs",
"at",
"the",
"ERROR",
"log",
"level",
"using",
"a",
"standard",
"printf",
"format",
"string"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/logger/log.go#L90-L94 | test |
lxc/lxd | shared/logger/log.go | Critf | func Critf(format string, args ...interface{}) {
if Log != nil {
Log.Crit(fmt.Sprintf(format, args...))
}
} | go | func Critf(format string, args ...interface{}) {
if Log != nil {
Log.Crit(fmt.Sprintf(format, args...))
}
} | [
"func",
"Critf",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"Log",
"!=",
"nil",
"{",
"Log",
".",
"Crit",
"(",
"fmt",
".",
"Sprintf",
"(",
"format",
",",
"args",
"...",
")",
")",
"\n",
"}",
"\n",
"}"
] | // Critf logs at the CRITICAL log level using a standard printf format string | [
"Critf",
"logs",
"at",
"the",
"CRITICAL",
"log",
"level",
"using",
"a",
"standard",
"printf",
"format",
"string"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/logger/log.go#L97-L101 | test |
lxc/lxd | lxd/events.go | eventForward | func eventForward(id int64, event api.Event) {
if event.Type == "logging" {
// Parse the message
logEntry := api.EventLogging{}
err := json.Unmarshal(event.Metadata, &logEntry)
if err != nil {
return
}
if !debug && logEntry.Level == "dbug" {
return
}
if !debug && !verbose && logEntry.Level == "... | go | func eventForward(id int64, event api.Event) {
if event.Type == "logging" {
// Parse the message
logEntry := api.EventLogging{}
err := json.Unmarshal(event.Metadata, &logEntry)
if err != nil {
return
}
if !debug && logEntry.Level == "dbug" {
return
}
if !debug && !verbose && logEntry.Level == "... | [
"func",
"eventForward",
"(",
"id",
"int64",
",",
"event",
"api",
".",
"Event",
")",
"{",
"if",
"event",
".",
"Type",
"==",
"\"logging\"",
"{",
"logEntry",
":=",
"api",
".",
"EventLogging",
"{",
"}",
"\n",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"... | // Forward to the local events dispatcher an event received from another node . | [
"Forward",
"to",
"the",
"local",
"events",
"dispatcher",
"an",
"event",
"received",
"from",
"another",
"node",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/events.go#L232-L254 | test |
lxc/lxd | lxd/storage.go | StorageProgressReader | func StorageProgressReader(op *operation, key string, description string) func(io.ReadCloser) io.ReadCloser {
return func(reader io.ReadCloser) io.ReadCloser {
if op == nil {
return reader
}
progress := func(progressInt int64, speedInt int64) {
progressWrapperRender(op, key, description, progressInt, spee... | go | func StorageProgressReader(op *operation, key string, description string) func(io.ReadCloser) io.ReadCloser {
return func(reader io.ReadCloser) io.ReadCloser {
if op == nil {
return reader
}
progress := func(progressInt int64, speedInt int64) {
progressWrapperRender(op, key, description, progressInt, spee... | [
"func",
"StorageProgressReader",
"(",
"op",
"*",
"operation",
",",
"key",
"string",
",",
"description",
"string",
")",
"func",
"(",
"io",
".",
"ReadCloser",
")",
"io",
".",
"ReadCloser",
"{",
"return",
"func",
"(",
"reader",
"io",
".",
"ReadCloser",
")",
... | // StorageProgressReader reports the read progress. | [
"StorageProgressReader",
"reports",
"the",
"read",
"progress",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage.go#L807-L826 | test |
lxc/lxd | lxd/storage.go | StorageProgressWriter | func StorageProgressWriter(op *operation, key string, description string) func(io.WriteCloser) io.WriteCloser {
return func(writer io.WriteCloser) io.WriteCloser {
if op == nil {
return writer
}
progress := func(progressInt int64, speedInt int64) {
progressWrapperRender(op, key, description, progressInt, ... | go | func StorageProgressWriter(op *operation, key string, description string) func(io.WriteCloser) io.WriteCloser {
return func(writer io.WriteCloser) io.WriteCloser {
if op == nil {
return writer
}
progress := func(progressInt int64, speedInt int64) {
progressWrapperRender(op, key, description, progressInt, ... | [
"func",
"StorageProgressWriter",
"(",
"op",
"*",
"operation",
",",
"key",
"string",
",",
"description",
"string",
")",
"func",
"(",
"io",
".",
"WriteCloser",
")",
"io",
".",
"WriteCloser",
"{",
"return",
"func",
"(",
"writer",
"io",
".",
"WriteCloser",
")"... | // StorageProgressWriter reports the write progress. | [
"StorageProgressWriter",
"reports",
"the",
"write",
"progress",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage.go#L829-L848 | test |
lxc/lxd | shared/osarch/release.go | GetLSBRelease | func GetLSBRelease() (map[string]string, error) {
osRelease, err := getLSBRelease("/etc/os-release")
if os.IsNotExist(err) {
return getLSBRelease("/usr/lib/os-release")
}
return osRelease, err
} | go | func GetLSBRelease() (map[string]string, error) {
osRelease, err := getLSBRelease("/etc/os-release")
if os.IsNotExist(err) {
return getLSBRelease("/usr/lib/os-release")
}
return osRelease, err
} | [
"func",
"GetLSBRelease",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"osRelease",
",",
"err",
":=",
"getLSBRelease",
"(",
"\"/etc/os-release\"",
")",
"\n",
"if",
"os",
".",
"IsNotExist",
"(",
"err",
")",
"{",
"return",
"... | // GetLSBRelease returns a map with Linux distribution information | [
"GetLSBRelease",
"returns",
"a",
"map",
"with",
"Linux",
"distribution",
"information"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/osarch/release.go#L11-L17 | test |
lxc/lxd | shared/generate/file/write.go | Reset | func Reset(path string, imports []string) error {
content := fmt.Sprintf(`package %s
// The code below was generated by %s - DO NOT EDIT!
import (
`, os.Getenv("GOPACKAGE"), os.Args[0])
for _, uri := range imports {
content += fmt.Sprintf("\t%q\n", uri)
}
content += ")\n\n"
// FIXME: we should only import w... | go | func Reset(path string, imports []string) error {
content := fmt.Sprintf(`package %s
// The code below was generated by %s - DO NOT EDIT!
import (
`, os.Getenv("GOPACKAGE"), os.Args[0])
for _, uri := range imports {
content += fmt.Sprintf("\t%q\n", uri)
}
content += ")\n\n"
// FIXME: we should only import w... | [
"func",
"Reset",
"(",
"path",
"string",
",",
"imports",
"[",
"]",
"string",
")",
"error",
"{",
"content",
":=",
"fmt",
".",
"Sprintf",
"(",
"`package %s// The code below was generated by %s - DO NOT EDIT!import (`",
",",
"os",
".",
"Getenv",
"(",
"\"GOPACKAGE\"",
... | // Reset an auto-generated source file, writing a new empty file header. | [
"Reset",
"an",
"auto",
"-",
"generated",
"source",
"file",
"writing",
"a",
"new",
"empty",
"file",
"header",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/file/write.go#L12-L44 | test |
lxc/lxd | shared/generate/file/write.go | Append | func Append(path string, snippet Snippet) error {
buffer := newBuffer()
buffer.N()
err := snippet.Generate(buffer)
if err != nil {
return errors.Wrap(err, "Generate code snippet")
}
var file *os.File
if path == "-" {
file = os.Stdout
} else {
file, err = os.OpenFile(path, os.O_APPEND|os.O_WRONLY, 0644)... | go | func Append(path string, snippet Snippet) error {
buffer := newBuffer()
buffer.N()
err := snippet.Generate(buffer)
if err != nil {
return errors.Wrap(err, "Generate code snippet")
}
var file *os.File
if path == "-" {
file = os.Stdout
} else {
file, err = os.OpenFile(path, os.O_APPEND|os.O_WRONLY, 0644)... | [
"func",
"Append",
"(",
"path",
"string",
",",
"snippet",
"Snippet",
")",
"error",
"{",
"buffer",
":=",
"newBuffer",
"(",
")",
"\n",
"buffer",
".",
"N",
"(",
")",
"\n",
"err",
":=",
"snippet",
".",
"Generate",
"(",
"buffer",
")",
"\n",
"if",
"err",
... | // Append a code snippet to a file. | [
"Append",
"a",
"code",
"snippet",
"to",
"a",
"file",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/file/write.go#L47-L79 | test |
lxc/lxd | lxd/db/containers.go | ContainerToArgs | func ContainerToArgs(container *Container) ContainerArgs {
args := ContainerArgs{
ID: container.ID,
Project: container.Project,
Name: container.Name,
Node: container.Node,
Ctype: ContainerType(container.Type),
Architecture: container.Architecture,
Ephemeral: conta... | go | func ContainerToArgs(container *Container) ContainerArgs {
args := ContainerArgs{
ID: container.ID,
Project: container.Project,
Name: container.Name,
Node: container.Node,
Ctype: ContainerType(container.Type),
Architecture: container.Architecture,
Ephemeral: conta... | [
"func",
"ContainerToArgs",
"(",
"container",
"*",
"Container",
")",
"ContainerArgs",
"{",
"args",
":=",
"ContainerArgs",
"{",
"ID",
":",
"container",
".",
"ID",
",",
"Project",
":",
"container",
".",
"Project",
",",
"Name",
":",
"container",
".",
"Name",
"... | // ContainerToArgs is a convenience to convert the new Container db struct into
// the legacy ContainerArgs. | [
"ContainerToArgs",
"is",
"a",
"convenience",
"to",
"convert",
"the",
"new",
"Container",
"db",
"struct",
"into",
"the",
"legacy",
"ContainerArgs",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L95-L119 | test |
lxc/lxd | lxd/db/containers.go | ContainerNames | func (c *ClusterTx) ContainerNames(project string) ([]string, error) {
stmt := `
SELECT containers.name FROM containers
JOIN projects ON projects.id = containers.project_id
WHERE projects.name = ? AND containers.type = ?
`
return query.SelectStrings(c.tx, stmt, project, CTypeRegular)
} | go | func (c *ClusterTx) ContainerNames(project string) ([]string, error) {
stmt := `
SELECT containers.name FROM containers
JOIN projects ON projects.id = containers.project_id
WHERE projects.name = ? AND containers.type = ?
`
return query.SelectStrings(c.tx, stmt, project, CTypeRegular)
} | [
"func",
"(",
"c",
"*",
"ClusterTx",
")",
"ContainerNames",
"(",
"project",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"stmt",
":=",
"`SELECT containers.name FROM containers JOIN projects ON projects.id = containers.project_id WHERE projects.name = ? A... | // ContainerNames returns the names of all containers the given project. | [
"ContainerNames",
"returns",
"the",
"names",
"of",
"all",
"containers",
"the",
"given",
"project",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L170-L177 | test |
lxc/lxd | lxd/db/containers.go | ContainerNodeAddress | func (c *ClusterTx) ContainerNodeAddress(project string, name string) (string, error) {
stmt := `
SELECT nodes.id, nodes.address
FROM nodes
JOIN containers ON containers.node_id = nodes.id
JOIN projects ON projects.id = containers.project_id
WHERE projects.name = ? AND containers.name = ?
`
var address string
... | go | func (c *ClusterTx) ContainerNodeAddress(project string, name string) (string, error) {
stmt := `
SELECT nodes.id, nodes.address
FROM nodes
JOIN containers ON containers.node_id = nodes.id
JOIN projects ON projects.id = containers.project_id
WHERE projects.name = ? AND containers.name = ?
`
var address string
... | [
"func",
"(",
"c",
"*",
"ClusterTx",
")",
"ContainerNodeAddress",
"(",
"project",
"string",
",",
"name",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"stmt",
":=",
"`SELECT nodes.id, nodes.address FROM nodes JOIN containers ON containers.node_id = nodes.id JOIN... | // ContainerNodeAddress returns the address of the node hosting the container
// with the given name in the given project.
//
// It returns the empty string if the container is hosted on this node. | [
"ContainerNodeAddress",
"returns",
"the",
"address",
"of",
"the",
"node",
"hosting",
"the",
"container",
"with",
"the",
"given",
"name",
"in",
"the",
"given",
"project",
".",
"It",
"returns",
"the",
"empty",
"string",
"if",
"the",
"container",
"is",
"hosted",
... | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L183-L222 | test |
lxc/lxd | lxd/db/containers.go | ContainersListByNodeAddress | func (c *ClusterTx) ContainersListByNodeAddress(project string) (map[string][]string, error) {
offlineThreshold, err := c.NodeOfflineThreshold()
if err != nil {
return nil, err
}
stmt := `
SELECT containers.name, nodes.id, nodes.address, nodes.heartbeat
FROM containers
JOIN nodes ON nodes.id = containers.nod... | go | func (c *ClusterTx) ContainersListByNodeAddress(project string) (map[string][]string, error) {
offlineThreshold, err := c.NodeOfflineThreshold()
if err != nil {
return nil, err
}
stmt := `
SELECT containers.name, nodes.id, nodes.address, nodes.heartbeat
FROM containers
JOIN nodes ON nodes.id = containers.nod... | [
"func",
"(",
"c",
"*",
"ClusterTx",
")",
"ContainersListByNodeAddress",
"(",
"project",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
",",
"error",
")",
"{",
"offlineThreshold",
",",
"err",
":=",
"c",
".",
"NodeOfflineThreshold",
"(",
... | // ContainersListByNodeAddress returns the names of all containers grouped by
// cluster node address.
//
// The node address of containers running on the local node is set to the empty
// string, to distinguish it from remote nodes.
//
// Containers whose node is down are addeded to the special address "0.0.0.0". | [
"ContainersListByNodeAddress",
"returns",
"the",
"names",
"of",
"all",
"containers",
"grouped",
"by",
"cluster",
"node",
"address",
".",
"The",
"node",
"address",
"of",
"containers",
"running",
"on",
"the",
"local",
"node",
"is",
"set",
"to",
"the",
"empty",
"... | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L231-L276 | test |
lxc/lxd | lxd/db/containers.go | ContainerListExpanded | func (c *ClusterTx) ContainerListExpanded() ([]Container, error) {
containers, err := c.ContainerList(ContainerFilter{})
if err != nil {
return nil, errors.Wrap(err, "Load containers")
}
profiles, err := c.ProfileList(ProfileFilter{})
if err != nil {
return nil, errors.Wrap(err, "Load profiles")
}
// Index... | go | func (c *ClusterTx) ContainerListExpanded() ([]Container, error) {
containers, err := c.ContainerList(ContainerFilter{})
if err != nil {
return nil, errors.Wrap(err, "Load containers")
}
profiles, err := c.ProfileList(ProfileFilter{})
if err != nil {
return nil, errors.Wrap(err, "Load profiles")
}
// Index... | [
"func",
"(",
"c",
"*",
"ClusterTx",
")",
"ContainerListExpanded",
"(",
")",
"(",
"[",
"]",
"Container",
",",
"error",
")",
"{",
"containers",
",",
"err",
":=",
"c",
".",
"ContainerList",
"(",
"ContainerFilter",
"{",
"}",
")",
"\n",
"if",
"err",
"!=",
... | // ContainerListExpanded loads all containers across all projects and expands
// their config and devices using the profiles they are associated to. | [
"ContainerListExpanded",
"loads",
"all",
"containers",
"across",
"all",
"projects",
"and",
"expands",
"their",
"config",
"and",
"devices",
"using",
"the",
"profiles",
"they",
"are",
"associated",
"to",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L280-L314 | test |
lxc/lxd | lxd/db/containers.go | ContainersByNodeName | func (c *ClusterTx) ContainersByNodeName(project string) (map[string]string, error) {
stmt := `
SELECT containers.name, nodes.name
FROM containers
JOIN nodes ON nodes.id = containers.node_id
JOIN projects ON projects.id = containers.project_id
WHERE containers.type=?
AND projects.name = ?
`
rows, err := c... | go | func (c *ClusterTx) ContainersByNodeName(project string) (map[string]string, error) {
stmt := `
SELECT containers.name, nodes.name
FROM containers
JOIN nodes ON nodes.id = containers.node_id
JOIN projects ON projects.id = containers.project_id
WHERE containers.type=?
AND projects.name = ?
`
rows, err := c... | [
"func",
"(",
"c",
"*",
"ClusterTx",
")",
"ContainersByNodeName",
"(",
"project",
"string",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"stmt",
":=",
"`SELECT containers.name, nodes.name FROM containers JOIN nodes ON nodes.id = containers.nod... | // ContainersByNodeName returns a map associating each container to the name of
// its node. | [
"ContainersByNodeName",
"returns",
"a",
"map",
"associating",
"each",
"container",
"to",
"the",
"name",
"of",
"its",
"node",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L318-L350 | test |
lxc/lxd | lxd/db/containers.go | SnapshotIDsAndNames | func (c *ClusterTx) SnapshotIDsAndNames(name string) (map[int]string, error) {
prefix := name + shared.SnapshotDelimiter
length := len(prefix)
objects := make([]struct {
ID int
Name string
}, 0)
dest := func(i int) []interface{} {
objects = append(objects, struct {
ID int
Name string
}{})
retur... | go | func (c *ClusterTx) SnapshotIDsAndNames(name string) (map[int]string, error) {
prefix := name + shared.SnapshotDelimiter
length := len(prefix)
objects := make([]struct {
ID int
Name string
}, 0)
dest := func(i int) []interface{} {
objects = append(objects, struct {
ID int
Name string
}{})
retur... | [
"func",
"(",
"c",
"*",
"ClusterTx",
")",
"SnapshotIDsAndNames",
"(",
"name",
"string",
")",
"(",
"map",
"[",
"int",
"]",
"string",
",",
"error",
")",
"{",
"prefix",
":=",
"name",
"+",
"shared",
".",
"SnapshotDelimiter",
"\n",
"length",
":=",
"len",
"("... | // SnapshotIDsAndNames returns a map of snapshot IDs to snapshot names for the
// container with the given name. | [
"SnapshotIDsAndNames",
"returns",
"a",
"map",
"of",
"snapshot",
"IDs",
"to",
"snapshot",
"names",
"for",
"the",
"container",
"with",
"the",
"given",
"name",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L354-L382 | test |
lxc/lxd | lxd/db/containers.go | ContainerNodeList | func (c *ClusterTx) ContainerNodeList() ([]Container, error) {
node, err := c.NodeName()
if err != nil {
return nil, errors.Wrap(err, "Local node name")
}
filter := ContainerFilter{
Node: node,
Type: int(CTypeRegular),
}
return c.ContainerList(filter)
} | go | func (c *ClusterTx) ContainerNodeList() ([]Container, error) {
node, err := c.NodeName()
if err != nil {
return nil, errors.Wrap(err, "Local node name")
}
filter := ContainerFilter{
Node: node,
Type: int(CTypeRegular),
}
return c.ContainerList(filter)
} | [
"func",
"(",
"c",
"*",
"ClusterTx",
")",
"ContainerNodeList",
"(",
")",
"(",
"[",
"]",
"Container",
",",
"error",
")",
"{",
"node",
",",
"err",
":=",
"c",
".",
"NodeName",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"erro... | // ContainerNodeList returns all container objects on the local node. | [
"ContainerNodeList",
"returns",
"all",
"container",
"objects",
"on",
"the",
"local",
"node",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L494-L505 | test |
lxc/lxd | lxd/db/containers.go | ContainerNodeProjectList | func (c *ClusterTx) ContainerNodeProjectList(project string) ([]Container, error) {
node, err := c.NodeName()
if err != nil {
return nil, errors.Wrap(err, "Local node name")
}
filter := ContainerFilter{
Project: project,
Node: node,
Type: int(CTypeRegular),
}
return c.ContainerList(filter)
} | go | func (c *ClusterTx) ContainerNodeProjectList(project string) ([]Container, error) {
node, err := c.NodeName()
if err != nil {
return nil, errors.Wrap(err, "Local node name")
}
filter := ContainerFilter{
Project: project,
Node: node,
Type: int(CTypeRegular),
}
return c.ContainerList(filter)
} | [
"func",
"(",
"c",
"*",
"ClusterTx",
")",
"ContainerNodeProjectList",
"(",
"project",
"string",
")",
"(",
"[",
"]",
"Container",
",",
"error",
")",
"{",
"node",
",",
"err",
":=",
"c",
".",
"NodeName",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"... | // ContainerNodeProjectList returns all container objects on the local node within the given project. | [
"ContainerNodeProjectList",
"returns",
"all",
"container",
"objects",
"on",
"the",
"local",
"node",
"within",
"the",
"given",
"project",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L508-L520 | test |
lxc/lxd | lxd/db/containers.go | ContainerRemove | func (c *Cluster) ContainerRemove(project, name string) error {
return c.Transaction(func(tx *ClusterTx) error {
return tx.ContainerDelete(project, name)
})
} | go | func (c *Cluster) ContainerRemove(project, name string) error {
return c.Transaction(func(tx *ClusterTx) error {
return tx.ContainerDelete(project, name)
})
} | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"ContainerRemove",
"(",
"project",
",",
"name",
"string",
")",
"error",
"{",
"return",
"c",
".",
"Transaction",
"(",
"func",
"(",
"tx",
"*",
"ClusterTx",
")",
"error",
"{",
"return",
"tx",
".",
"ContainerDelete",
... | // ContainerRemove removes the container with the given name from the database. | [
"ContainerRemove",
"removes",
"the",
"container",
"with",
"the",
"given",
"name",
"from",
"the",
"database",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L528-L532 | test |
lxc/lxd | lxd/db/containers.go | ContainerProjectAndName | func (c *Cluster) ContainerProjectAndName(id int) (string, string, error) {
q := `
SELECT projects.name, containers.name
FROM containers
JOIN projects ON projects.id = containers.project_id
WHERE containers.id=?
`
project := ""
name := ""
arg1 := []interface{}{id}
arg2 := []interface{}{&project, &name}
err :=... | go | func (c *Cluster) ContainerProjectAndName(id int) (string, string, error) {
q := `
SELECT projects.name, containers.name
FROM containers
JOIN projects ON projects.id = containers.project_id
WHERE containers.id=?
`
project := ""
name := ""
arg1 := []interface{}{id}
arg2 := []interface{}{&project, &name}
err :=... | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"ContainerProjectAndName",
"(",
"id",
"int",
")",
"(",
"string",
",",
"string",
",",
"error",
")",
"{",
"q",
":=",
"`SELECT projects.name, containers.name FROM containers JOIN projects ON projects.id = containers.project_idWHERE cont... | // ContainerProjectAndName returns the project and the name of the container
// with the given ID. | [
"ContainerProjectAndName",
"returns",
"the",
"project",
"and",
"the",
"name",
"of",
"the",
"container",
"with",
"the",
"given",
"ID",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L536-L553 | test |
lxc/lxd | lxd/db/containers.go | ContainerConfigClear | func ContainerConfigClear(tx *sql.Tx, id int) error {
_, err := tx.Exec("DELETE FROM containers_config WHERE container_id=?", id)
if err != nil {
return err
}
_, err = tx.Exec("DELETE FROM containers_profiles WHERE container_id=?", id)
if err != nil {
return err
}
_, err = tx.Exec(`DELETE FROM containers_dev... | go | func ContainerConfigClear(tx *sql.Tx, id int) error {
_, err := tx.Exec("DELETE FROM containers_config WHERE container_id=?", id)
if err != nil {
return err
}
_, err = tx.Exec("DELETE FROM containers_profiles WHERE container_id=?", id)
if err != nil {
return err
}
_, err = tx.Exec(`DELETE FROM containers_dev... | [
"func",
"ContainerConfigClear",
"(",
"tx",
"*",
"sql",
".",
"Tx",
",",
"id",
"int",
")",
"error",
"{",
"_",
",",
"err",
":=",
"tx",
".",
"Exec",
"(",
"\"DELETE FROM containers_config WHERE container_id=?\"",
",",
"id",
")",
"\n",
"if",
"err",
"!=",
"nil",
... | // ContainerConfigClear removes any config associated with the container with
// the given ID. | [
"ContainerConfigClear",
"removes",
"any",
"config",
"associated",
"with",
"the",
"container",
"with",
"the",
"given",
"ID",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L571-L590 | test |
lxc/lxd | lxd/db/containers.go | ContainerConfigGet | func (c *Cluster) ContainerConfigGet(id int, key string) (string, error) {
q := "SELECT value FROM containers_config WHERE container_id=? AND key=?"
value := ""
arg1 := []interface{}{id, key}
arg2 := []interface{}{&value}
err := dbQueryRowScan(c.db, q, arg1, arg2)
if err == sql.ErrNoRows {
return "", ErrNoSuchO... | go | func (c *Cluster) ContainerConfigGet(id int, key string) (string, error) {
q := "SELECT value FROM containers_config WHERE container_id=? AND key=?"
value := ""
arg1 := []interface{}{id, key}
arg2 := []interface{}{&value}
err := dbQueryRowScan(c.db, q, arg1, arg2)
if err == sql.ErrNoRows {
return "", ErrNoSuchO... | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"ContainerConfigGet",
"(",
"id",
"int",
",",
"key",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"q",
":=",
"\"SELECT value FROM containers_config WHERE container_id=? AND key=?\"",
"\n",
"value",
":=",
"\"\"",
"\n... | // ContainerConfigGet returns the value of the given key in the configuration
// of the container with the given ID. | [
"ContainerConfigGet",
"returns",
"the",
"value",
"of",
"the",
"given",
"key",
"in",
"the",
"configuration",
"of",
"the",
"container",
"with",
"the",
"given",
"ID",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L619-L630 | test |
lxc/lxd | lxd/db/containers.go | ContainerConfigRemove | func (c *Cluster) ContainerConfigRemove(id int, key string) error {
err := exec(c.db, "DELETE FROM containers_config WHERE key=? AND container_id=?", key, id)
return err
} | go | func (c *Cluster) ContainerConfigRemove(id int, key string) error {
err := exec(c.db, "DELETE FROM containers_config WHERE key=? AND container_id=?", key, id)
return err
} | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"ContainerConfigRemove",
"(",
"id",
"int",
",",
"key",
"string",
")",
"error",
"{",
"err",
":=",
"exec",
"(",
"c",
".",
"db",
",",
"\"DELETE FROM containers_config WHERE key=? AND container_id=?\"",
",",
"key",
",",
"id",... | // ContainerConfigRemove removes the given key from the config of the container
// with the given ID. | [
"ContainerConfigRemove",
"removes",
"the",
"given",
"key",
"from",
"the",
"config",
"of",
"the",
"container",
"with",
"the",
"given",
"ID",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L634-L637 | test |
lxc/lxd | lxd/db/containers.go | ContainerSetStateful | func (c *Cluster) ContainerSetStateful(id int, stateful bool) error {
statefulInt := 0
if stateful {
statefulInt = 1
}
err := exec(c.db, "UPDATE containers SET stateful=? WHERE id=?", statefulInt, id)
return err
} | go | func (c *Cluster) ContainerSetStateful(id int, stateful bool) error {
statefulInt := 0
if stateful {
statefulInt = 1
}
err := exec(c.db, "UPDATE containers SET stateful=? WHERE id=?", statefulInt, id)
return err
} | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"ContainerSetStateful",
"(",
"id",
"int",
",",
"stateful",
"bool",
")",
"error",
"{",
"statefulInt",
":=",
"0",
"\n",
"if",
"stateful",
"{",
"statefulInt",
"=",
"1",
"\n",
"}",
"\n",
"err",
":=",
"exec",
"(",
"c... | // ContainerSetStateful toggles the stateful flag of the container with the
// given ID. | [
"ContainerSetStateful",
"toggles",
"the",
"stateful",
"flag",
"of",
"the",
"container",
"with",
"the",
"given",
"ID",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L641-L649 | test |
lxc/lxd | lxd/db/containers.go | ContainerProfilesInsert | func ContainerProfilesInsert(tx *sql.Tx, id int, project string, profiles []string) error {
enabled, err := projectHasProfiles(tx, project)
if err != nil {
return errors.Wrap(err, "Check if project has profiles")
}
if !enabled {
project = "default"
}
applyOrder := 1
str := `
INSERT INTO containers_profiles ... | go | func ContainerProfilesInsert(tx *sql.Tx, id int, project string, profiles []string) error {
enabled, err := projectHasProfiles(tx, project)
if err != nil {
return errors.Wrap(err, "Check if project has profiles")
}
if !enabled {
project = "default"
}
applyOrder := 1
str := `
INSERT INTO containers_profiles ... | [
"func",
"ContainerProfilesInsert",
"(",
"tx",
"*",
"sql",
".",
"Tx",
",",
"id",
"int",
",",
"project",
"string",
",",
"profiles",
"[",
"]",
"string",
")",
"error",
"{",
"enabled",
",",
"err",
":=",
"projectHasProfiles",
"(",
"tx",
",",
"project",
")",
... | // ContainerProfilesInsert associates the container with the given ID with the
// profiles with the given names in the given project. | [
"ContainerProfilesInsert",
"associates",
"the",
"container",
"with",
"the",
"given",
"ID",
"with",
"the",
"profiles",
"with",
"the",
"given",
"names",
"in",
"the",
"given",
"project",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L653-L690 | test |
lxc/lxd | lxd/db/containers.go | ContainerProfiles | func (c *Cluster) ContainerProfiles(id int) ([]string, error) {
var name string
var profiles []string
query := `
SELECT name FROM containers_profiles
JOIN profiles ON containers_profiles.profile_id=profiles.id
WHERE container_id=?
ORDER BY containers_profiles.apply_order`
inargs := []inte... | go | func (c *Cluster) ContainerProfiles(id int) ([]string, error) {
var name string
var profiles []string
query := `
SELECT name FROM containers_profiles
JOIN profiles ON containers_profiles.profile_id=profiles.id
WHERE container_id=?
ORDER BY containers_profiles.apply_order`
inargs := []inte... | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"ContainerProfiles",
"(",
"id",
"int",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"var",
"name",
"string",
"\n",
"var",
"profiles",
"[",
"]",
"string",
"\n",
"query",
":=",
"` SELECT name FROM cont... | // ContainerProfiles returns a list of profiles for a given container ID. | [
"ContainerProfiles",
"returns",
"a",
"list",
"of",
"profiles",
"for",
"a",
"given",
"container",
"ID",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L693-L717 | test |
lxc/lxd | lxd/db/containers.go | ContainerConfig | func (c *Cluster) ContainerConfig(id int) (map[string]string, error) {
var key, value string
q := `SELECT key, value FROM containers_config WHERE container_id=?`
inargs := []interface{}{id}
outfmt := []interface{}{key, value}
// Results is already a slice here, not db Rows anymore.
results, err := queryScan(c.d... | go | func (c *Cluster) ContainerConfig(id int) (map[string]string, error) {
var key, value string
q := `SELECT key, value FROM containers_config WHERE container_id=?`
inargs := []interface{}{id}
outfmt := []interface{}{key, value}
// Results is already a slice here, not db Rows anymore.
results, err := queryScan(c.d... | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"ContainerConfig",
"(",
"id",
"int",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"var",
"key",
",",
"value",
"string",
"\n",
"q",
":=",
"`SELECT key, value FROM containers_config WHERE contain... | // ContainerConfig gets the container configuration map from the DB | [
"ContainerConfig",
"gets",
"the",
"container",
"configuration",
"map",
"from",
"the",
"DB"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L720-L743 | test |
lxc/lxd | lxd/db/containers.go | ContainerSetState | func (c *Cluster) ContainerSetState(id int, state string) error {
err := c.Transaction(func(tx *ClusterTx) error {
// Set the new value
str := fmt.Sprintf("INSERT OR REPLACE INTO containers_config (container_id, key, value) VALUES (?, 'volatile.last_state.power', ?)")
stmt, err := tx.tx.Prepare(str)
if err != ... | go | func (c *Cluster) ContainerSetState(id int, state string) error {
err := c.Transaction(func(tx *ClusterTx) error {
// Set the new value
str := fmt.Sprintf("INSERT OR REPLACE INTO containers_config (container_id, key, value) VALUES (?, 'volatile.last_state.power', ?)")
stmt, err := tx.tx.Prepare(str)
if err != ... | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"ContainerSetState",
"(",
"id",
"int",
",",
"state",
"string",
")",
"error",
"{",
"err",
":=",
"c",
".",
"Transaction",
"(",
"func",
"(",
"tx",
"*",
"ClusterTx",
")",
"error",
"{",
"str",
":=",
"fmt",
".",
"Sp... | // ContainerSetState sets the the power state of the container with the given ID. | [
"ContainerSetState",
"sets",
"the",
"the",
"power",
"state",
"of",
"the",
"container",
"with",
"the",
"given",
"ID",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L795-L811 | test |
lxc/lxd | lxd/db/containers.go | ContainerUpdate | func ContainerUpdate(tx *sql.Tx, id int, description string, architecture int, ephemeral bool,
expiryDate time.Time) error {
str := fmt.Sprintf("UPDATE containers SET description=?, architecture=?, ephemeral=?, expiry_date=? WHERE id=?")
stmt, err := tx.Prepare(str)
if err != nil {
return err
}
defer stmt.Close... | go | func ContainerUpdate(tx *sql.Tx, id int, description string, architecture int, ephemeral bool,
expiryDate time.Time) error {
str := fmt.Sprintf("UPDATE containers SET description=?, architecture=?, ephemeral=?, expiry_date=? WHERE id=?")
stmt, err := tx.Prepare(str)
if err != nil {
return err
}
defer stmt.Close... | [
"func",
"ContainerUpdate",
"(",
"tx",
"*",
"sql",
".",
"Tx",
",",
"id",
"int",
",",
"description",
"string",
",",
"architecture",
"int",
",",
"ephemeral",
"bool",
",",
"expiryDate",
"time",
".",
"Time",
")",
"error",
"{",
"str",
":=",
"fmt",
".",
"Spri... | // ContainerUpdate updates the description, architecture and ephemeral flag of
// the container with the given ID. | [
"ContainerUpdate",
"updates",
"the",
"description",
"architecture",
"and",
"ephemeral",
"flag",
"of",
"the",
"container",
"with",
"the",
"given",
"ID",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L815-L839 | test |
lxc/lxd | lxd/db/containers.go | ContainerLastUsedUpdate | func (c *Cluster) ContainerLastUsedUpdate(id int, date time.Time) error {
stmt := `UPDATE containers SET last_use_date=? WHERE id=?`
err := exec(c.db, stmt, date, id)
return err
} | go | func (c *Cluster) ContainerLastUsedUpdate(id int, date time.Time) error {
stmt := `UPDATE containers SET last_use_date=? WHERE id=?`
err := exec(c.db, stmt, date, id)
return err
} | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"ContainerLastUsedUpdate",
"(",
"id",
"int",
",",
"date",
"time",
".",
"Time",
")",
"error",
"{",
"stmt",
":=",
"`UPDATE containers SET last_use_date=? WHERE id=?`",
"\n",
"err",
":=",
"exec",
"(",
"c",
".",
"db",
",",
... | // ContainerLastUsedUpdate updates the last_use_date field of the container
// with the given ID. | [
"ContainerLastUsedUpdate",
"updates",
"the",
"last_use_date",
"field",
"of",
"the",
"container",
"with",
"the",
"given",
"ID",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L851-L855 | test |
lxc/lxd | lxd/db/containers.go | ContainerGetSnapshots | func (c *Cluster) ContainerGetSnapshots(project, name string) ([]string, error) {
result := []string{}
regexp := name + shared.SnapshotDelimiter
length := len(regexp)
q := `
SELECT containers.name
FROM containers
JOIN projects ON projects.id = containers.project_id
WHERE projects.name=? AND containers.type=? A... | go | func (c *Cluster) ContainerGetSnapshots(project, name string) ([]string, error) {
result := []string{}
regexp := name + shared.SnapshotDelimiter
length := len(regexp)
q := `
SELECT containers.name
FROM containers
JOIN projects ON projects.id = containers.project_id
WHERE projects.name=? AND containers.type=? A... | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"ContainerGetSnapshots",
"(",
"project",
",",
"name",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"result",
":=",
"[",
"]",
"string",
"{",
"}",
"\n",
"regexp",
":=",
"name",
"+",
"shared",
... | // ContainerGetSnapshots returns the names of all snapshots of the container
// in the given project with the given name. | [
"ContainerGetSnapshots",
"returns",
"the",
"names",
"of",
"all",
"snapshots",
"of",
"the",
"container",
"in",
"the",
"given",
"project",
"with",
"the",
"given",
"name",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L859-L882 | test |
lxc/lxd | lxd/db/containers.go | ContainerGetSnapshotsFull | func (c *ClusterTx) ContainerGetSnapshotsFull(project string, name string) ([]Container, error) {
filter := ContainerFilter{
Parent: name,
Project: project,
Type: int(CTypeSnapshot),
}
return c.ContainerList(filter)
} | go | func (c *ClusterTx) ContainerGetSnapshotsFull(project string, name string) ([]Container, error) {
filter := ContainerFilter{
Parent: name,
Project: project,
Type: int(CTypeSnapshot),
}
return c.ContainerList(filter)
} | [
"func",
"(",
"c",
"*",
"ClusterTx",
")",
"ContainerGetSnapshotsFull",
"(",
"project",
"string",
",",
"name",
"string",
")",
"(",
"[",
"]",
"Container",
",",
"error",
")",
"{",
"filter",
":=",
"ContainerFilter",
"{",
"Parent",
":",
"name",
",",
"Project",
... | // ContainerGetSnapshotsFull returns all container objects for snapshots of a given container | [
"ContainerGetSnapshotsFull",
"returns",
"all",
"container",
"objects",
"for",
"snapshots",
"of",
"a",
"given",
"container"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L885-L893 | test |
lxc/lxd | lxd/db/containers.go | ContainerNextSnapshot | func (c *Cluster) ContainerNextSnapshot(project string, name string, pattern string) int {
base := name + shared.SnapshotDelimiter
length := len(base)
q := `
SELECT containers.name
FROM containers
JOIN projects ON projects.id = containers.project_id
WHERE projects.name=? AND containers.type=? AND SUBSTR(contain... | go | func (c *Cluster) ContainerNextSnapshot(project string, name string, pattern string) int {
base := name + shared.SnapshotDelimiter
length := len(base)
q := `
SELECT containers.name
FROM containers
JOIN projects ON projects.id = containers.project_id
WHERE projects.name=? AND containers.type=? AND SUBSTR(contain... | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"ContainerNextSnapshot",
"(",
"project",
"string",
",",
"name",
"string",
",",
"pattern",
"string",
")",
"int",
"{",
"base",
":=",
"name",
"+",
"shared",
".",
"SnapshotDelimiter",
"\n",
"length",
":=",
"len",
"(",
"... | // ContainerNextSnapshot returns the index the next snapshot of the container
// with the given name and pattern should have. | [
"ContainerNextSnapshot",
"returns",
"the",
"index",
"the",
"next",
"snapshot",
"of",
"the",
"container",
"with",
"the",
"given",
"name",
"and",
"pattern",
"should",
"have",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L897-L929 | test |
lxc/lxd | lxd/db/containers.go | ContainerPool | func (c *ClusterTx) ContainerPool(project, containerName string) (string, error) {
// Get container storage volume. Since container names are globally
// unique, and their storage volumes carry the same name, their storage
// volumes are unique too.
poolName := ""
query := `
SELECT storage_pools.name FROM storage_... | go | func (c *ClusterTx) ContainerPool(project, containerName string) (string, error) {
// Get container storage volume. Since container names are globally
// unique, and their storage volumes carry the same name, their storage
// volumes are unique too.
poolName := ""
query := `
SELECT storage_pools.name FROM storage_... | [
"func",
"(",
"c",
"*",
"ClusterTx",
")",
"ContainerPool",
"(",
"project",
",",
"containerName",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"poolName",
":=",
"\"\"",
"\n",
"query",
":=",
"`SELECT storage_pools.name FROM storage_pools JOIN storage_volumes ... | // ContainerPool returns the storage pool of a given container. | [
"ContainerPool",
"returns",
"the",
"storage",
"pool",
"of",
"a",
"given",
"container",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L945-L970 | test |
lxc/lxd | lxd/db/containers.go | ContainerGetBackup | func (c *Cluster) ContainerGetBackup(project, name string) (ContainerBackupArgs, error) {
args := ContainerBackupArgs{}
args.Name = name
containerOnlyInt := -1
optimizedStorageInt := -1
q := `
SELECT containers_backups.id, containers_backups.container_id,
containers_backups.creation_date, containers_backup... | go | func (c *Cluster) ContainerGetBackup(project, name string) (ContainerBackupArgs, error) {
args := ContainerBackupArgs{}
args.Name = name
containerOnlyInt := -1
optimizedStorageInt := -1
q := `
SELECT containers_backups.id, containers_backups.container_id,
containers_backups.creation_date, containers_backup... | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"ContainerGetBackup",
"(",
"project",
",",
"name",
"string",
")",
"(",
"ContainerBackupArgs",
",",
"error",
")",
"{",
"args",
":=",
"ContainerBackupArgs",
"{",
"}",
"\n",
"args",
".",
"Name",
"=",
"name",
"\n",
"con... | // ContainerGetBackup returns the backup with the given name. | [
"ContainerGetBackup",
"returns",
"the",
"backup",
"with",
"the",
"given",
"name",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L987-L1023 | test |
lxc/lxd | lxd/db/containers.go | ContainerGetBackups | func (c *Cluster) ContainerGetBackups(project, name string) ([]string, error) {
var result []string
q := `SELECT containers_backups.name FROM containers_backups
JOIN containers ON containers_backups.container_id=containers.id
JOIN projects ON projects.id=containers.project_id
WHERE projects.name=? AND containers.nam... | go | func (c *Cluster) ContainerGetBackups(project, name string) ([]string, error) {
var result []string
q := `SELECT containers_backups.name FROM containers_backups
JOIN containers ON containers_backups.container_id=containers.id
JOIN projects ON projects.id=containers.project_id
WHERE projects.name=? AND containers.nam... | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"ContainerGetBackups",
"(",
"project",
",",
"name",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"var",
"result",
"[",
"]",
"string",
"\n",
"q",
":=",
"`SELECT containers_backups.name FROM containers_... | // ContainerGetBackups returns the names of all backups of the container
// with the given name. | [
"ContainerGetBackups",
"returns",
"the",
"names",
"of",
"all",
"backups",
"of",
"the",
"container",
"with",
"the",
"given",
"name",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L1027-L1046 | test |
lxc/lxd | lxd/db/containers.go | ContainerBackupCreate | func (c *Cluster) ContainerBackupCreate(args ContainerBackupArgs) error {
_, err := c.ContainerBackupID(args.Name)
if err == nil {
return ErrAlreadyDefined
}
err = c.Transaction(func(tx *ClusterTx) error {
containerOnlyInt := 0
if args.ContainerOnly {
containerOnlyInt = 1
}
optimizedStorageInt := 0
... | go | func (c *Cluster) ContainerBackupCreate(args ContainerBackupArgs) error {
_, err := c.ContainerBackupID(args.Name)
if err == nil {
return ErrAlreadyDefined
}
err = c.Transaction(func(tx *ClusterTx) error {
containerOnlyInt := 0
if args.ContainerOnly {
containerOnlyInt = 1
}
optimizedStorageInt := 0
... | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"ContainerBackupCreate",
"(",
"args",
"ContainerBackupArgs",
")",
"error",
"{",
"_",
",",
"err",
":=",
"c",
".",
"ContainerBackupID",
"(",
"args",
".",
"Name",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"return",
"... | // ContainerBackupCreate creates a new backup | [
"ContainerBackupCreate",
"creates",
"a",
"new",
"backup"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L1049-L1088 | test |
lxc/lxd | lxd/db/containers.go | ContainerBackupRemove | func (c *Cluster) ContainerBackupRemove(name string) error {
id, err := c.ContainerBackupID(name)
if err != nil {
return err
}
err = exec(c.db, "DELETE FROM containers_backups WHERE id=?", id)
if err != nil {
return err
}
return nil
} | go | func (c *Cluster) ContainerBackupRemove(name string) error {
id, err := c.ContainerBackupID(name)
if err != nil {
return err
}
err = exec(c.db, "DELETE FROM containers_backups WHERE id=?", id)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"ContainerBackupRemove",
"(",
"name",
"string",
")",
"error",
"{",
"id",
",",
"err",
":=",
"c",
".",
"ContainerBackupID",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
... | // ContainerBackupRemove removes the container backup with the given name from
// the database. | [
"ContainerBackupRemove",
"removes",
"the",
"container",
"backup",
"with",
"the",
"given",
"name",
"from",
"the",
"database",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L1092-L1104 | test |
lxc/lxd | lxd/db/containers.go | ContainerBackupRename | func (c *Cluster) ContainerBackupRename(oldName, newName string) error {
err := c.Transaction(func(tx *ClusterTx) error {
str := fmt.Sprintf("UPDATE containers_backups SET name = ? WHERE name = ?")
stmt, err := tx.tx.Prepare(str)
if err != nil {
return err
}
defer stmt.Close()
logger.Debug(
"Calling... | go | func (c *Cluster) ContainerBackupRename(oldName, newName string) error {
err := c.Transaction(func(tx *ClusterTx) error {
str := fmt.Sprintf("UPDATE containers_backups SET name = ? WHERE name = ?")
stmt, err := tx.tx.Prepare(str)
if err != nil {
return err
}
defer stmt.Close()
logger.Debug(
"Calling... | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"ContainerBackupRename",
"(",
"oldName",
",",
"newName",
"string",
")",
"error",
"{",
"err",
":=",
"c",
".",
"Transaction",
"(",
"func",
"(",
"tx",
"*",
"ClusterTx",
")",
"error",
"{",
"str",
":=",
"fmt",
".",
"... | // ContainerBackupRename renames a container backup from the given current name
// to the new one. | [
"ContainerBackupRename",
"renames",
"a",
"container",
"backup",
"from",
"the",
"given",
"current",
"name",
"to",
"the",
"new",
"one",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L1108-L1130 | test |
lxc/lxd | lxd/db/containers.go | ContainerBackupsGetExpired | func (c *Cluster) ContainerBackupsGetExpired() ([]string, error) {
var result []string
var name string
var expiryDate string
q := `SELECT containers_backups.name, containers_backups.expiry_date FROM containers_backups`
outfmt := []interface{}{name, expiryDate}
dbResults, err := queryScan(c.db, q, nil, outfmt)
i... | go | func (c *Cluster) ContainerBackupsGetExpired() ([]string, error) {
var result []string
var name string
var expiryDate string
q := `SELECT containers_backups.name, containers_backups.expiry_date FROM containers_backups`
outfmt := []interface{}{name, expiryDate}
dbResults, err := queryScan(c.db, q, nil, outfmt)
i... | [
"func",
"(",
"c",
"*",
"Cluster",
")",
"ContainerBackupsGetExpired",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"var",
"result",
"[",
"]",
"string",
"\n",
"var",
"name",
"string",
"\n",
"var",
"expiryDate",
"string",
"\n",
"q",
":=",
... | // ContainerBackupsGetExpired returns a list of expired container backups. | [
"ContainerBackupsGetExpired",
"returns",
"a",
"list",
"of",
"expired",
"container",
"backups",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L1133-L1166 | test |
lxc/lxd | lxd/sys/os.go | DefaultOS | func DefaultOS() *OS {
newOS := &OS{
VarDir: shared.VarPath(),
CacheDir: shared.CachePath(),
LogDir: shared.LogPath(),
}
newOS.InotifyWatch.Fd = -1
newOS.InotifyWatch.Targets = make(map[string]*InotifyTargetInfo)
return newOS
} | go | func DefaultOS() *OS {
newOS := &OS{
VarDir: shared.VarPath(),
CacheDir: shared.CachePath(),
LogDir: shared.LogPath(),
}
newOS.InotifyWatch.Fd = -1
newOS.InotifyWatch.Targets = make(map[string]*InotifyTargetInfo)
return newOS
} | [
"func",
"DefaultOS",
"(",
")",
"*",
"OS",
"{",
"newOS",
":=",
"&",
"OS",
"{",
"VarDir",
":",
"shared",
".",
"VarPath",
"(",
")",
",",
"CacheDir",
":",
"shared",
".",
"CachePath",
"(",
")",
",",
"LogDir",
":",
"shared",
".",
"LogPath",
"(",
")",
"... | // DefaultOS returns a fresh uninitialized OS instance with default values. | [
"DefaultOS",
"returns",
"a",
"fresh",
"uninitialized",
"OS",
"instance",
"with",
"default",
"values",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/sys/os.go#L71-L80 | test |
lxc/lxd | lxd/sys/os.go | Init | func (s *OS) Init() error {
err := s.initDirs()
if err != nil {
return err
}
s.Architectures, err = util.GetArchitectures()
if err != nil {
return err
}
s.LxcPath = filepath.Join(s.VarDir, "containers")
s.BackingFS, err = util.FilesystemDetect(s.LxcPath)
if err != nil {
logger.Error("Error detecting b... | go | func (s *OS) Init() error {
err := s.initDirs()
if err != nil {
return err
}
s.Architectures, err = util.GetArchitectures()
if err != nil {
return err
}
s.LxcPath = filepath.Join(s.VarDir, "containers")
s.BackingFS, err = util.FilesystemDetect(s.LxcPath)
if err != nil {
logger.Error("Error detecting b... | [
"func",
"(",
"s",
"*",
"OS",
")",
"Init",
"(",
")",
"error",
"{",
"err",
":=",
"s",
".",
"initDirs",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"s",
".",
"Architectures",
",",
"err",
"=",
"util",
".",
"Ge... | // Init our internal data structures. | [
"Init",
"our",
"internal",
"data",
"structures",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/sys/os.go#L83-L109 | test |
lxc/lxd | client/operations.go | GetWebsocket | func (op *operation) GetWebsocket(secret string) (*websocket.Conn, error) {
return op.r.GetOperationWebsocket(op.ID, secret)
} | go | func (op *operation) GetWebsocket(secret string) (*websocket.Conn, error) {
return op.r.GetOperationWebsocket(op.ID, secret)
} | [
"func",
"(",
"op",
"*",
"operation",
")",
"GetWebsocket",
"(",
"secret",
"string",
")",
"(",
"*",
"websocket",
".",
"Conn",
",",
"error",
")",
"{",
"return",
"op",
".",
"r",
".",
"GetOperationWebsocket",
"(",
"op",
".",
"ID",
",",
"secret",
")",
"\n"... | // GetWebsocket returns a raw websocket connection from the operation | [
"GetWebsocket",
"returns",
"a",
"raw",
"websocket",
"connection",
"from",
"the",
"operation"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/operations.go#L67-L69 | test |
lxc/lxd | client/operations.go | Refresh | func (op *operation) Refresh() error {
// Get the current version of the operation
newOp, _, err := op.r.GetOperation(op.ID)
if err != nil {
return err
}
// Update the operation struct
op.Operation = *newOp
return nil
} | go | func (op *operation) Refresh() error {
// Get the current version of the operation
newOp, _, err := op.r.GetOperation(op.ID)
if err != nil {
return err
}
// Update the operation struct
op.Operation = *newOp
return nil
} | [
"func",
"(",
"op",
"*",
"operation",
")",
"Refresh",
"(",
")",
"error",
"{",
"newOp",
",",
"_",
",",
"err",
":=",
"op",
".",
"r",
".",
"GetOperation",
"(",
"op",
".",
"ID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
... | // Refresh pulls the current version of the operation and updates the struct | [
"Refresh",
"pulls",
"the",
"current",
"version",
"of",
"the",
"operation",
"and",
"updates",
"the",
"struct"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/operations.go#L86-L97 | test |
lxc/lxd | client/operations.go | CancelTarget | func (op *remoteOperation) CancelTarget() error {
if op.targetOp == nil {
return fmt.Errorf("No associated target operation")
}
return op.targetOp.Cancel()
} | go | func (op *remoteOperation) CancelTarget() error {
if op.targetOp == nil {
return fmt.Errorf("No associated target operation")
}
return op.targetOp.Cancel()
} | [
"func",
"(",
"op",
"*",
"remoteOperation",
")",
"CancelTarget",
"(",
")",
"error",
"{",
"if",
"op",
".",
"targetOp",
"==",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"No associated target operation\"",
")",
"\n",
"}",
"\n",
"return",
"op",
".",
"... | // CancelTarget attempts to cancel the target operation | [
"CancelTarget",
"attempts",
"to",
"cancel",
"the",
"target",
"operation"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/operations.go#L285-L291 | test |
lxc/lxd | client/operations.go | GetTarget | func (op *remoteOperation) GetTarget() (*api.Operation, error) {
if op.targetOp == nil {
return nil, fmt.Errorf("No associated target operation")
}
opAPI := op.targetOp.Get()
return &opAPI, nil
} | go | func (op *remoteOperation) GetTarget() (*api.Operation, error) {
if op.targetOp == nil {
return nil, fmt.Errorf("No associated target operation")
}
opAPI := op.targetOp.Get()
return &opAPI, nil
} | [
"func",
"(",
"op",
"*",
"remoteOperation",
")",
"GetTarget",
"(",
")",
"(",
"*",
"api",
".",
"Operation",
",",
"error",
")",
"{",
"if",
"op",
".",
"targetOp",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"No associated target op... | // GetTarget returns the target operation | [
"GetTarget",
"returns",
"the",
"target",
"operation"
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/operations.go#L294-L301 | test |
lxc/lxd | lxd/endpoints/endpoints.go | up | func (e *Endpoints) up(config *Config) error {
e.mu.Lock()
defer e.mu.Unlock()
e.servers = map[kind]*http.Server{
devlxd: config.DevLxdServer,
local: config.RestServer,
network: config.RestServer,
cluster: config.RestServer,
pprof: pprofCreateServer(),
}
e.cert = config.Cert
e.inherited = map[kind... | go | func (e *Endpoints) up(config *Config) error {
e.mu.Lock()
defer e.mu.Unlock()
e.servers = map[kind]*http.Server{
devlxd: config.DevLxdServer,
local: config.RestServer,
network: config.RestServer,
cluster: config.RestServer,
pprof: pprofCreateServer(),
}
e.cert = config.Cert
e.inherited = map[kind... | [
"func",
"(",
"e",
"*",
"Endpoints",
")",
"up",
"(",
"config",
"*",
"Config",
")",
"error",
"{",
"e",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"e",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"e",
".",
"servers",
"=",
"map",
"[",
"kind",... | // Up brings up all configured endpoints and starts accepting HTTP requests. | [
"Up",
"brings",
"up",
"all",
"configured",
"endpoints",
"and",
"starts",
"accepting",
"HTTP",
"requests",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/endpoints/endpoints.go#L151-L231 | test |
lxc/lxd | lxd/endpoints/endpoints.go | Down | func (e *Endpoints) Down() error {
e.mu.Lock()
defer e.mu.Unlock()
if e.listeners[network] != nil || e.listeners[local] != nil {
logger.Infof("Stopping REST API handler:")
err := e.closeListener(network)
if err != nil {
return err
}
err = e.closeListener(local)
if err != nil {
return err
}
}
... | go | func (e *Endpoints) Down() error {
e.mu.Lock()
defer e.mu.Unlock()
if e.listeners[network] != nil || e.listeners[local] != nil {
logger.Infof("Stopping REST API handler:")
err := e.closeListener(network)
if err != nil {
return err
}
err = e.closeListener(local)
if err != nil {
return err
}
}
... | [
"func",
"(",
"e",
"*",
"Endpoints",
")",
"Down",
"(",
")",
"error",
"{",
"e",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"e",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"if",
"e",
".",
"listeners",
"[",
"network",
"]",
"!=",
"nil",
"||",... | // Down brings down all endpoints and stops serving HTTP requests. | [
"Down",
"brings",
"down",
"all",
"endpoints",
"and",
"stops",
"serving",
"HTTP",
"requests",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/endpoints/endpoints.go#L234-L281 | test |
lxc/lxd | lxd/endpoints/endpoints.go | serveHTTP | func (e *Endpoints) serveHTTP(kind kind) {
listener := e.listeners[kind]
if listener == nil {
return
}
ctx := log.Ctx{"socket": listener.Addr()}
if e.inherited[kind] {
ctx["inherited"] = true
}
message := fmt.Sprintf(" - binding %s", descriptions[kind])
logger.Info(message, ctx)
server := e.servers[kin... | go | func (e *Endpoints) serveHTTP(kind kind) {
listener := e.listeners[kind]
if listener == nil {
return
}
ctx := log.Ctx{"socket": listener.Addr()}
if e.inherited[kind] {
ctx["inherited"] = true
}
message := fmt.Sprintf(" - binding %s", descriptions[kind])
logger.Info(message, ctx)
server := e.servers[kin... | [
"func",
"(",
"e",
"*",
"Endpoints",
")",
"serveHTTP",
"(",
"kind",
"kind",
")",
"{",
"listener",
":=",
"e",
".",
"listeners",
"[",
"kind",
"]",
"\n",
"if",
"listener",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"ctx",
":=",
"log",
".",
"Ctx",
"... | // Start an HTTP server for the endpoint associated with the given code. | [
"Start",
"an",
"HTTP",
"server",
"for",
"the",
"endpoint",
"associated",
"with",
"the",
"given",
"code",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/endpoints/endpoints.go#L284-L311 | test |
lxc/lxd | lxd/endpoints/endpoints.go | closeListener | func (e *Endpoints) closeListener(kind kind) error {
listener := e.listeners[kind]
if listener == nil {
return nil
}
delete(e.listeners, kind)
logger.Info(" - closing socket", log.Ctx{"socket": listener.Addr()})
return listener.Close()
} | go | func (e *Endpoints) closeListener(kind kind) error {
listener := e.listeners[kind]
if listener == nil {
return nil
}
delete(e.listeners, kind)
logger.Info(" - closing socket", log.Ctx{"socket": listener.Addr()})
return listener.Close()
} | [
"func",
"(",
"e",
"*",
"Endpoints",
")",
"closeListener",
"(",
"kind",
"kind",
")",
"error",
"{",
"listener",
":=",
"e",
".",
"listeners",
"[",
"kind",
"]",
"\n",
"if",
"listener",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"delete",
"(",
... | // Stop the HTTP server of the endpoint associated with the given code. The
// associated socket will be shutdown too. | [
"Stop",
"the",
"HTTP",
"server",
"of",
"the",
"endpoint",
"associated",
"with",
"the",
"given",
"code",
".",
"The",
"associated",
"socket",
"will",
"be",
"shutdown",
"too",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/endpoints/endpoints.go#L315-L325 | test |
lxc/lxd | lxd/endpoints/endpoints.go | activatedListeners | func activatedListeners(systemdListeners []net.Listener, cert *shared.CertInfo) map[kind]net.Listener {
listeners := map[kind]net.Listener{}
for _, listener := range systemdListeners {
var kind kind
switch listener.(type) {
case *net.UnixListener:
kind = local
case *net.TCPListener:
kind = network
li... | go | func activatedListeners(systemdListeners []net.Listener, cert *shared.CertInfo) map[kind]net.Listener {
listeners := map[kind]net.Listener{}
for _, listener := range systemdListeners {
var kind kind
switch listener.(type) {
case *net.UnixListener:
kind = local
case *net.TCPListener:
kind = network
li... | [
"func",
"activatedListeners",
"(",
"systemdListeners",
"[",
"]",
"net",
".",
"Listener",
",",
"cert",
"*",
"shared",
".",
"CertInfo",
")",
"map",
"[",
"kind",
"]",
"net",
".",
"Listener",
"{",
"listeners",
":=",
"map",
"[",
"kind",
"]",
"net",
".",
"Li... | // Use the listeners associated with the file descriptors passed via
// socket-based activation. | [
"Use",
"the",
"listeners",
"associated",
"with",
"the",
"file",
"descriptors",
"passed",
"via",
"socket",
"-",
"based",
"activation",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/endpoints/endpoints.go#L329-L345 | test |
lxc/lxd | lxd/cluster/config.go | CandidServer | func (c *Config) CandidServer() (string, string, int64, string) {
return c.m.GetString("candid.api.url"),
c.m.GetString("candid.api.key"),
c.m.GetInt64("candid.expiry"),
c.m.GetString("candid.domains")
} | go | func (c *Config) CandidServer() (string, string, int64, string) {
return c.m.GetString("candid.api.url"),
c.m.GetString("candid.api.key"),
c.m.GetInt64("candid.expiry"),
c.m.GetString("candid.domains")
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"CandidServer",
"(",
")",
"(",
"string",
",",
"string",
",",
"int64",
",",
"string",
")",
"{",
"return",
"c",
".",
"m",
".",
"GetString",
"(",
"\"candid.api.url\"",
")",
",",
"c",
".",
"m",
".",
"GetString",
"(... | // CandidServer returns all the Candid settings needed to connect to a server. | [
"CandidServer",
"returns",
"all",
"the",
"Candid",
"settings",
"needed",
"to",
"connect",
"to",
"a",
"server",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/config.go#L68-L73 | test |
lxc/lxd | lxd/cluster/config.go | RBACServer | func (c *Config) RBACServer() (string, string, int64, string, string, string, string) {
return c.m.GetString("rbac.api.url"),
c.m.GetString("rbac.api.key"),
c.m.GetInt64("rbac.expiry"),
c.m.GetString("rbac.agent.url"),
c.m.GetString("rbac.agent.username"),
c.m.GetString("rbac.agent.private_key"),
c.m.GetSt... | go | func (c *Config) RBACServer() (string, string, int64, string, string, string, string) {
return c.m.GetString("rbac.api.url"),
c.m.GetString("rbac.api.key"),
c.m.GetInt64("rbac.expiry"),
c.m.GetString("rbac.agent.url"),
c.m.GetString("rbac.agent.username"),
c.m.GetString("rbac.agent.private_key"),
c.m.GetSt... | [
"func",
"(",
"c",
"*",
"Config",
")",
"RBACServer",
"(",
")",
"(",
"string",
",",
"string",
",",
"int64",
",",
"string",
",",
"string",
",",
"string",
",",
"string",
")",
"{",
"return",
"c",
".",
"m",
".",
"GetString",
"(",
"\"rbac.api.url\"",
")",
... | // RBACServer returns all the Candid settings needed to connect to a server. | [
"RBACServer",
"returns",
"all",
"the",
"Candid",
"settings",
"needed",
"to",
"connect",
"to",
"a",
"server",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/config.go#L76-L84 | test |
lxc/lxd | lxd/cluster/config.go | AutoUpdateInterval | func (c *Config) AutoUpdateInterval() time.Duration {
n := c.m.GetInt64("images.auto_update_interval")
return time.Duration(n) * time.Hour
} | go | func (c *Config) AutoUpdateInterval() time.Duration {
n := c.m.GetInt64("images.auto_update_interval")
return time.Duration(n) * time.Hour
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"AutoUpdateInterval",
"(",
")",
"time",
".",
"Duration",
"{",
"n",
":=",
"c",
".",
"m",
".",
"GetInt64",
"(",
"\"images.auto_update_interval\"",
")",
"\n",
"return",
"time",
".",
"Duration",
"(",
"n",
")",
"*",
"ti... | // AutoUpdateInterval returns the configured images auto update interval. | [
"AutoUpdateInterval",
"returns",
"the",
"configured",
"images",
"auto",
"update",
"interval",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/config.go#L87-L90 | test |
lxc/lxd | lxd/cluster/config.go | MAASController | func (c *Config) MAASController() (string, string) {
url := c.m.GetString("maas.api.url")
key := c.m.GetString("maas.api.key")
return url, key
} | go | func (c *Config) MAASController() (string, string) {
url := c.m.GetString("maas.api.url")
key := c.m.GetString("maas.api.key")
return url, key
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"MAASController",
"(",
")",
"(",
"string",
",",
"string",
")",
"{",
"url",
":=",
"c",
".",
"m",
".",
"GetString",
"(",
"\"maas.api.url\"",
")",
"\n",
"key",
":=",
"c",
".",
"m",
".",
"GetString",
"(",
"\"maas.a... | // MAASController the configured MAAS url and key, if any. | [
"MAASController",
"the",
"configured",
"MAAS",
"url",
"and",
"key",
"if",
"any",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/config.go#L114-L118 | test |
lxc/lxd | lxd/cluster/config.go | OfflineThreshold | func (c *Config) OfflineThreshold() time.Duration {
n := c.m.GetInt64("cluster.offline_threshold")
return time.Duration(n) * time.Second
} | go | func (c *Config) OfflineThreshold() time.Duration {
n := c.m.GetInt64("cluster.offline_threshold")
return time.Duration(n) * time.Second
} | [
"func",
"(",
"c",
"*",
"Config",
")",
"OfflineThreshold",
"(",
")",
"time",
".",
"Duration",
"{",
"n",
":=",
"c",
".",
"m",
".",
"GetInt64",
"(",
"\"cluster.offline_threshold\"",
")",
"\n",
"return",
"time",
".",
"Duration",
"(",
"n",
")",
"*",
"time",... | // OfflineThreshold returns the configured heartbeat threshold, i.e. the
// number of seconds before after which an unresponsive node is considered
// offline.. | [
"OfflineThreshold",
"returns",
"the",
"configured",
"heartbeat",
"threshold",
"i",
".",
"e",
".",
"the",
"number",
"of",
"seconds",
"before",
"after",
"which",
"an",
"unresponsive",
"node",
"is",
"considered",
"offline",
".."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/config.go#L123-L126 | test |
lxc/lxd | lxd/cluster/config.go | ConfigGetString | func ConfigGetString(cluster *db.Cluster, key string) (string, error) {
config, err := configGet(cluster)
if err != nil {
return "", err
}
return config.m.GetString(key), nil
} | go | func ConfigGetString(cluster *db.Cluster, key string) (string, error) {
config, err := configGet(cluster)
if err != nil {
return "", err
}
return config.m.GetString(key), nil
} | [
"func",
"ConfigGetString",
"(",
"cluster",
"*",
"db",
".",
"Cluster",
",",
"key",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"config",
",",
"err",
":=",
"configGet",
"(",
"cluster",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"\"... | // ConfigGetString is a convenience for loading the cluster configuration and
// returning the value of a particular key.
//
// It's a deprecated API meant to be used by call sites that are not
// interacting with the database in a transactional way. | [
"ConfigGetString",
"is",
"a",
"convenience",
"for",
"loading",
"the",
"cluster",
"configuration",
"and",
"returning",
"the",
"value",
"of",
"a",
"particular",
"key",
".",
"It",
"s",
"a",
"deprecated",
"API",
"meant",
"to",
"be",
"used",
"by",
"call",
"sites"... | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/config.go#L176-L182 | test |
lxc/lxd | lxd/cluster/config.go | ConfigGetBool | func ConfigGetBool(cluster *db.Cluster, key string) (bool, error) {
config, err := configGet(cluster)
if err != nil {
return false, err
}
return config.m.GetBool(key), nil
} | go | func ConfigGetBool(cluster *db.Cluster, key string) (bool, error) {
config, err := configGet(cluster)
if err != nil {
return false, err
}
return config.m.GetBool(key), nil
} | [
"func",
"ConfigGetBool",
"(",
"cluster",
"*",
"db",
".",
"Cluster",
",",
"key",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"config",
",",
"err",
":=",
"configGet",
"(",
"cluster",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
... | // ConfigGetBool is a convenience for loading the cluster configuration and
// returning the value of a particular boolean key.
//
// It's a deprecated API meant to be used by call sites that are not
// interacting with the database in a transactional way. | [
"ConfigGetBool",
"is",
"a",
"convenience",
"for",
"loading",
"the",
"cluster",
"configuration",
"and",
"returning",
"the",
"value",
"of",
"a",
"particular",
"boolean",
"key",
".",
"It",
"s",
"a",
"deprecated",
"API",
"meant",
"to",
"be",
"used",
"by",
"call"... | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/config.go#L189-L195 | test |
lxc/lxd | lxd/cluster/config.go | ConfigGetInt64 | func ConfigGetInt64(cluster *db.Cluster, key string) (int64, error) {
config, err := configGet(cluster)
if err != nil {
return 0, err
}
return config.m.GetInt64(key), nil
} | go | func ConfigGetInt64(cluster *db.Cluster, key string) (int64, error) {
config, err := configGet(cluster)
if err != nil {
return 0, err
}
return config.m.GetInt64(key), nil
} | [
"func",
"ConfigGetInt64",
"(",
"cluster",
"*",
"db",
".",
"Cluster",
",",
"key",
"string",
")",
"(",
"int64",
",",
"error",
")",
"{",
"config",
",",
"err",
":=",
"configGet",
"(",
"cluster",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"0",
... | // ConfigGetInt64 is a convenience for loading the cluster configuration and
// returning the value of a particular key.
//
// It's a deprecated API meant to be used by call sites that are not
// interacting with the database in a transactional way. | [
"ConfigGetInt64",
"is",
"a",
"convenience",
"for",
"loading",
"the",
"cluster",
"configuration",
"and",
"returning",
"the",
"value",
"of",
"a",
"particular",
"key",
".",
"It",
"s",
"a",
"deprecated",
"API",
"meant",
"to",
"be",
"used",
"by",
"call",
"sites",... | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/config.go#L202-L208 | test |
lxc/lxd | lxd/endpoints/cluster.go | ClusterAddress | func (e *Endpoints) ClusterAddress() string {
e.mu.RLock()
defer e.mu.RUnlock()
listener := e.listeners[cluster]
if listener == nil {
return ""
}
return listener.Addr().String()
} | go | func (e *Endpoints) ClusterAddress() string {
e.mu.RLock()
defer e.mu.RUnlock()
listener := e.listeners[cluster]
if listener == nil {
return ""
}
return listener.Addr().String()
} | [
"func",
"(",
"e",
"*",
"Endpoints",
")",
"ClusterAddress",
"(",
")",
"string",
"{",
"e",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",
"e",
".",
"mu",
".",
"RUnlock",
"(",
")",
"\n",
"listener",
":=",
"e",
".",
"listeners",
"[",
"cluster",
"]... | // ClusterAddress returns the cluster addresss of the cluster endpoint, or an
// empty string if there's no cluster endpoint. | [
"ClusterAddress",
"returns",
"the",
"cluster",
"addresss",
"of",
"the",
"cluster",
"endpoint",
"or",
"an",
"empty",
"string",
"if",
"there",
"s",
"no",
"cluster",
"endpoint",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/endpoints/cluster.go#L16-L25 | test |
lxc/lxd | shared/logger/log_debug.go | Debug | func Debug(msg string, ctx ...interface{}) {
if Log != nil {
pc, fn, line, _ := runtime.Caller(1)
msg := fmt.Sprintf("%s: %d: %s: %s", fn, line, runtime.FuncForPC(pc).Name(), msg)
Log.Debug(msg, ctx...)
}
} | go | func Debug(msg string, ctx ...interface{}) {
if Log != nil {
pc, fn, line, _ := runtime.Caller(1)
msg := fmt.Sprintf("%s: %d: %s: %s", fn, line, runtime.FuncForPC(pc).Name(), msg)
Log.Debug(msg, ctx...)
}
} | [
"func",
"Debug",
"(",
"msg",
"string",
",",
"ctx",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"Log",
"!=",
"nil",
"{",
"pc",
",",
"fn",
",",
"line",
",",
"_",
":=",
"runtime",
".",
"Caller",
"(",
"1",
")",
"\n",
"msg",
":=",
"fmt",
".",
"S... | // General wrappers around Logger interface functions. | [
"General",
"wrappers",
"around",
"Logger",
"interface",
"functions",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/logger/log_debug.go#L33-L39 | test |
lxc/lxd | lxd/api.go | RestServer | func RestServer(d *Daemon) *http.Server {
/* Setup the web server */
mux := mux.NewRouter()
mux.StrictSlash(false)
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
SyncResponse(true, []string{"/1.0"}).Render(w)
})
for endpoint, f := range ... | go | func RestServer(d *Daemon) *http.Server {
/* Setup the web server */
mux := mux.NewRouter()
mux.StrictSlash(false)
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
SyncResponse(true, []string{"/1.0"}).Render(w)
})
for endpoint, f := range ... | [
"func",
"RestServer",
"(",
"d",
"*",
"Daemon",
")",
"*",
"http",
".",
"Server",
"{",
"mux",
":=",
"mux",
".",
"NewRouter",
"(",
")",
"\n",
"mux",
".",
"StrictSlash",
"(",
"false",
")",
"\n",
"mux",
".",
"HandleFunc",
"(",
"\"/\"",
",",
"func",
"(",... | // RestServer creates an http.Server capable of handling requests against the LXD REST
// API endpoint. | [
"RestServer",
"creates",
"an",
"http",
".",
"Server",
"capable",
"of",
"handling",
"requests",
"against",
"the",
"LXD",
"REST",
"API",
"endpoint",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/api.go#L18-L47 | test |
lxc/lxd | lxd/api.go | projectParam | func projectParam(request *http.Request) string {
project := queryParam(request, "project")
if project == "" {
project = "default"
}
return project
} | go | func projectParam(request *http.Request) string {
project := queryParam(request, "project")
if project == "" {
project = "default"
}
return project
} | [
"func",
"projectParam",
"(",
"request",
"*",
"http",
".",
"Request",
")",
"string",
"{",
"project",
":=",
"queryParam",
"(",
"request",
",",
"\"project\"",
")",
"\n",
"if",
"project",
"==",
"\"\"",
"{",
"project",
"=",
"\"default\"",
"\n",
"}",
"\n",
"re... | // Extract the project query parameter from the given request. | [
"Extract",
"the",
"project",
"query",
"parameter",
"from",
"the",
"given",
"request",
"."
] | 7a41d14e4c1a6bc25918aca91004d594774dcdd3 | https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/api.go#L113-L119 | test |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.