id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
139,700 | control-center/serviced | rpc/master/hosts_server.go | RemoveHost | func (s *Server) RemoveHost(hostID string, _ *struct{}) error {
return s.f.RemoveHost(s.context(), hostID)
} | go | func (s *Server) RemoveHost(hostID string, _ *struct{}) error {
return s.f.RemoveHost(s.context(), hostID)
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"RemoveHost",
"(",
"hostID",
"string",
",",
"_",
"*",
"struct",
"{",
"}",
")",
"error",
"{",
"return",
"s",
".",
"f",
".",
"RemoveHost",
"(",
"s",
".",
"context",
"(",
")",
",",
"hostID",
")",
"\n",
"}"
] | // RemoveHost removes the host | [
"RemoveHost",
"removes",
"the",
"host"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/rpc/master/hosts_server.go#L92-L94 |
139,701 | control-center/serviced | rpc/master/hosts_server.go | FindHostsInPool | func (s *Server) FindHostsInPool(poolID string, hostReply *[]host.Host) error {
hosts, err := s.f.FindHostsInPool(s.context(), poolID)
if err != nil {
return err
}
*hostReply = hosts
return nil
} | go | func (s *Server) FindHostsInPool(poolID string, hostReply *[]host.Host) error {
hosts, err := s.f.FindHostsInPool(s.context(), poolID)
if err != nil {
return err
}
*hostReply = hosts
return nil
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"FindHostsInPool",
"(",
"poolID",
"string",
",",
"hostReply",
"*",
"[",
"]",
"host",
".",
"Host",
")",
"error",
"{",
"hosts",
",",
"err",
":=",
"s",
".",
"f",
".",
"FindHostsInPool",
"(",
"s",
".",
"context",
"... | // FindHostsInPool Returns all Hosts in a pool | [
"FindHostsInPool",
"Returns",
"all",
"Hosts",
"in",
"a",
"pool"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/rpc/master/hosts_server.go#L97-L104 |
139,702 | control-center/serviced | rpc/master/hosts_server.go | GetHostPublicKey | func (s *Server) GetHostPublicKey(hostID string, key *[]byte) error {
publicKey, err := s.f.GetHostKey(s.context(), hostID)
*key = publicKey
return err
} | go | func (s *Server) GetHostPublicKey(hostID string, key *[]byte) error {
publicKey, err := s.f.GetHostKey(s.context(), hostID)
*key = publicKey
return err
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"GetHostPublicKey",
"(",
"hostID",
"string",
",",
"key",
"*",
"[",
"]",
"byte",
")",
"error",
"{",
"publicKey",
",",
"err",
":=",
"s",
".",
"f",
".",
"GetHostKey",
"(",
"s",
".",
"context",
"(",
")",
",",
"ho... | // Return host's public key | [
"Return",
"host",
"s",
"public",
"key"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/rpc/master/hosts_server.go#L180-L184 |
139,703 | control-center/serviced | rpc/master/hosts_server.go | ResetHostKey | func (s *Server) ResetHostKey(hostID string, key *[]byte) error {
publicKey, err := s.f.ResetHostKey(s.context(), hostID)
*key = publicKey
return err
} | go | func (s *Server) ResetHostKey(hostID string, key *[]byte) error {
publicKey, err := s.f.ResetHostKey(s.context(), hostID)
*key = publicKey
return err
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"ResetHostKey",
"(",
"hostID",
"string",
",",
"key",
"*",
"[",
"]",
"byte",
")",
"error",
"{",
"publicKey",
",",
"err",
":=",
"s",
".",
"f",
".",
"ResetHostKey",
"(",
"s",
".",
"context",
"(",
")",
",",
"host... | // Reset and return host's private key | [
"Reset",
"and",
"return",
"host",
"s",
"private",
"key"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/rpc/master/hosts_server.go#L187-L191 |
139,704 | control-center/serviced | rpc/master/hosts_server.go | HostsAuthenticated | func (s *Server) HostsAuthenticated(hostIDs []string, res *map[string]bool) error {
authenticatedHosts := make(map[string]bool)
if hostIDs == nil || len(hostIDs) == 0 {
*res = authenticatedHosts
return nil
}
for _, hid := range hostIDs {
isAuth, _ := s.f.HostIsAuthenticated(s.context(), hid)
authenticatedHo... | go | func (s *Server) HostsAuthenticated(hostIDs []string, res *map[string]bool) error {
authenticatedHosts := make(map[string]bool)
if hostIDs == nil || len(hostIDs) == 0 {
*res = authenticatedHosts
return nil
}
for _, hid := range hostIDs {
isAuth, _ := s.f.HostIsAuthenticated(s.context(), hid)
authenticatedHo... | [
"func",
"(",
"s",
"*",
"Server",
")",
"HostsAuthenticated",
"(",
"hostIDs",
"[",
"]",
"string",
",",
"res",
"*",
"map",
"[",
"string",
"]",
"bool",
")",
"error",
"{",
"authenticatedHosts",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"bool",
")",
"\... | // Given a list of hostsID return if they are authenticated | [
"Given",
"a",
"list",
"of",
"hostsID",
"return",
"if",
"they",
"are",
"authenticated"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/rpc/master/hosts_server.go#L194-L206 |
139,705 | control-center/serviced | cli/api/publicendpoint.go | AddPublicEndpointPort | func (a *api) AddPublicEndpointPort(serviceid, endpointName, portAddr string, usetls bool,
protocol string, isEnabled bool, restart bool) (*servicedefinition.Port, error) {
client, err := a.connectMaster()
if err != nil {
return nil, err
}
return client.AddPublicEndpointPort(serviceid, endpointName, portAddr, u... | go | func (a *api) AddPublicEndpointPort(serviceid, endpointName, portAddr string, usetls bool,
protocol string, isEnabled bool, restart bool) (*servicedefinition.Port, error) {
client, err := a.connectMaster()
if err != nil {
return nil, err
}
return client.AddPublicEndpointPort(serviceid, endpointName, portAddr, u... | [
"func",
"(",
"a",
"*",
"api",
")",
"AddPublicEndpointPort",
"(",
"serviceid",
",",
"endpointName",
",",
"portAddr",
"string",
",",
"usetls",
"bool",
",",
"protocol",
"string",
",",
"isEnabled",
"bool",
",",
"restart",
"bool",
")",
"(",
"*",
"servicedefinitio... | // Add a new port public endpoint. | [
"Add",
"a",
"new",
"port",
"public",
"endpoint",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/api/publicendpoint.go#L22-L30 |
139,706 | control-center/serviced | cli/api/publicendpoint.go | RemovePublicEndpointPort | func (a *api) RemovePublicEndpointPort(serviceid, endpointName, portAddr string) error {
client, err := a.connectMaster()
if err != nil {
return err
}
return client.RemovePublicEndpointPort(serviceid, endpointName, portAddr)
} | go | func (a *api) RemovePublicEndpointPort(serviceid, endpointName, portAddr string) error {
client, err := a.connectMaster()
if err != nil {
return err
}
return client.RemovePublicEndpointPort(serviceid, endpointName, portAddr)
} | [
"func",
"(",
"a",
"*",
"api",
")",
"RemovePublicEndpointPort",
"(",
"serviceid",
",",
"endpointName",
",",
"portAddr",
"string",
")",
"error",
"{",
"client",
",",
"err",
":=",
"a",
".",
"connectMaster",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"r... | // Remove a port public endpoint. | [
"Remove",
"a",
"port",
"public",
"endpoint",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/api/publicendpoint.go#L33-L40 |
139,707 | control-center/serviced | coordinator/client/retry/bounded_exponential_backoff.go | BoundedExponentialBackoff | func BoundedExponentialBackoff(baseSleepTime time.Duration, maxSleepTime time.Duration, maxRetries int) Policy {
return boundedExponentialBackoff{
exponentialBackoff: exponentialBackoff{
baseSleepTime: baseSleepTime,
maxRetries: maxRetries,
},
maxSleepTime: maxSleepTime,
}
} | go | func BoundedExponentialBackoff(baseSleepTime time.Duration, maxSleepTime time.Duration, maxRetries int) Policy {
return boundedExponentialBackoff{
exponentialBackoff: exponentialBackoff{
baseSleepTime: baseSleepTime,
maxRetries: maxRetries,
},
maxSleepTime: maxSleepTime,
}
} | [
"func",
"BoundedExponentialBackoff",
"(",
"baseSleepTime",
"time",
".",
"Duration",
",",
"maxSleepTime",
"time",
".",
"Duration",
",",
"maxRetries",
"int",
")",
"Policy",
"{",
"return",
"boundedExponentialBackoff",
"{",
"exponentialBackoff",
":",
"exponentialBackoff",
... | // BoundedExponentialBackoff returns a policy that will retry up to maxRetries with an exponentially increasing
// sleep time up to maxSleepTime. | [
"BoundedExponentialBackoff",
"returns",
"a",
"policy",
"that",
"will",
"retry",
"up",
"to",
"maxRetries",
"with",
"an",
"exponentially",
"increasing",
"sleep",
"time",
"up",
"to",
"maxSleepTime",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/coordinator/client/retry/bounded_exponential_backoff.go#L27-L35 |
139,708 | control-center/serviced | facade/servicetemplate.go | AddServiceTemplate | func (f *Facade) AddServiceTemplate(ctx datastore.Context, serviceTemplate servicetemplate.ServiceTemplate, reloadLogstashConfig bool) (string, error) {
defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.AddServiceTemplate"))
alog := f.auditLogger.Message(ctx, "Adding Service Template").
Action(audit.Add).Type(se... | go | func (f *Facade) AddServiceTemplate(ctx datastore.Context, serviceTemplate servicetemplate.ServiceTemplate, reloadLogstashConfig bool) (string, error) {
defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.AddServiceTemplate"))
alog := f.auditLogger.Message(ctx, "Adding Service Template").
Action(audit.Add).Type(se... | [
"func",
"(",
"f",
"*",
"Facade",
")",
"AddServiceTemplate",
"(",
"ctx",
"datastore",
".",
"Context",
",",
"serviceTemplate",
"servicetemplate",
".",
"ServiceTemplate",
",",
"reloadLogstashConfig",
"bool",
")",
"(",
"string",
",",
"error",
")",
"{",
"defer",
"c... | //AddServiceTemplate adds a service template to the system. Returns the id of the template added | [
"AddServiceTemplate",
"adds",
"a",
"service",
"template",
"to",
"the",
"system",
".",
"Returns",
"the",
"id",
"of",
"the",
"template",
"added"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/facade/servicetemplate.go#L29-L81 |
139,709 | control-center/serviced | facade/servicetemplate.go | UpdateServiceTemplate | func (f *Facade) UpdateServiceTemplate(ctx datastore.Context, template servicetemplate.ServiceTemplate, reloadLogstashConfig bool) error {
defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.UpdateServiceTemplate"))
alog := f.auditLogger.Message(ctx, "Updating Service Template").
Action(audit.Update).Entity(&templ... | go | func (f *Facade) UpdateServiceTemplate(ctx datastore.Context, template servicetemplate.ServiceTemplate, reloadLogstashConfig bool) error {
defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.UpdateServiceTemplate"))
alog := f.auditLogger.Message(ctx, "Updating Service Template").
Action(audit.Update).Entity(&templ... | [
"func",
"(",
"f",
"*",
"Facade",
")",
"UpdateServiceTemplate",
"(",
"ctx",
"datastore",
".",
"Context",
",",
"template",
"servicetemplate",
".",
"ServiceTemplate",
",",
"reloadLogstashConfig",
"bool",
")",
"error",
"{",
"defer",
"ctx",
".",
"Metrics",
"(",
")"... | //UpdateServiceTemplate updates a service template | [
"UpdateServiceTemplate",
"updates",
"a",
"service",
"template"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/facade/servicetemplate.go#L84-L109 |
139,710 | control-center/serviced | facade/servicetemplate.go | RemoveServiceTemplate | func (f *Facade) RemoveServiceTemplate(ctx datastore.Context, id string) error {
defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.RemoveServiceTemplate"))
alog := f.auditLogger.Message(ctx, "Removing Service Template").
Action(audit.Remove).ID(id).Type(servicetemplate.GetType())
_, err := f.templateStore.Get(c... | go | func (f *Facade) RemoveServiceTemplate(ctx datastore.Context, id string) error {
defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.RemoveServiceTemplate"))
alog := f.auditLogger.Message(ctx, "Removing Service Template").
Action(audit.Remove).ID(id).Type(servicetemplate.GetType())
_, err := f.templateStore.Get(c... | [
"func",
"(",
"f",
"*",
"Facade",
")",
"RemoveServiceTemplate",
"(",
"ctx",
"datastore",
".",
"Context",
",",
"id",
"string",
")",
"error",
"{",
"defer",
"ctx",
".",
"Metrics",
"(",
")",
".",
"Stop",
"(",
"ctx",
".",
"Metrics",
"(",
")",
".",
"Start",... | //RemoveServiceTemplate removes the service template from the system | [
"RemoveServiceTemplate",
"removes",
"the",
"service",
"template",
"from",
"the",
"system"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/facade/servicetemplate.go#L112-L135 |
139,711 | control-center/serviced | facade/servicetemplate.go | RestoreServiceTemplates | func (f *Facade) RestoreServiceTemplates(ctx datastore.Context, templates []servicetemplate.ServiceTemplate) error {
defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.RestoreServiceTemplates"))
curtemplates, err := f.GetServiceTemplates(ctx)
if err != nil {
plog.WithError(err).Error("Could not look up service t... | go | func (f *Facade) RestoreServiceTemplates(ctx datastore.Context, templates []servicetemplate.ServiceTemplate) error {
defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.RestoreServiceTemplates"))
curtemplates, err := f.GetServiceTemplates(ctx)
if err != nil {
plog.WithError(err).Error("Could not look up service t... | [
"func",
"(",
"f",
"*",
"Facade",
")",
"RestoreServiceTemplates",
"(",
"ctx",
"datastore",
".",
"Context",
",",
"templates",
"[",
"]",
"servicetemplate",
".",
"ServiceTemplate",
")",
"error",
"{",
"defer",
"ctx",
".",
"Metrics",
"(",
")",
".",
"Stop",
"(",
... | // RestoreServiceTemplates restores a service template, typically from a backup | [
"RestoreServiceTemplates",
"restores",
"a",
"service",
"template",
"typically",
"from",
"a",
"backup"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/facade/servicetemplate.go#L138-L174 |
139,712 | control-center/serviced | facade/servicetemplate.go | DeployTemplateActive | func (f *Facade) DeployTemplateActive() (active []map[string]string, err error) {
// we initialize the data container to something here in case it has not been initialized yet
active = make([]map[string]string, 0)
f.deployments.mutex.RLock()
defer f.deployments.mutex.RUnlock()
for _, v := range f.deployments.depl... | go | func (f *Facade) DeployTemplateActive() (active []map[string]string, err error) {
// we initialize the data container to something here in case it has not been initialized yet
active = make([]map[string]string, 0)
f.deployments.mutex.RLock()
defer f.deployments.mutex.RUnlock()
for _, v := range f.deployments.depl... | [
"func",
"(",
"f",
"*",
"Facade",
")",
"DeployTemplateActive",
"(",
")",
"(",
"active",
"[",
"]",
"map",
"[",
"string",
"]",
"string",
",",
"err",
"error",
")",
"{",
"// we initialize the data container to something here in case it has not been initialized yet",
"activ... | // gather a list of all active DeploymentIDs | [
"gather",
"a",
"list",
"of",
"all",
"active",
"DeploymentIDs"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/facade/servicetemplate.go#L249-L260 |
139,713 | control-center/serviced | facade/servicetemplate.go | DeployTemplateStatus | func (f *Facade) DeployTemplateStatus(deploymentID string, lastStatus string, timeout time.Duration) (status string, err error) {
deployment := f.deployments.GetPendingDeployment(deploymentID)
if deployment == nil {
return "", nil
}
status, statusChanged := deployment.GetStatus()
if status != lastStatus || time... | go | func (f *Facade) DeployTemplateStatus(deploymentID string, lastStatus string, timeout time.Duration) (status string, err error) {
deployment := f.deployments.GetPendingDeployment(deploymentID)
if deployment == nil {
return "", nil
}
status, statusChanged := deployment.GetStatus()
if status != lastStatus || time... | [
"func",
"(",
"f",
"*",
"Facade",
")",
"DeployTemplateStatus",
"(",
"deploymentID",
"string",
",",
"lastStatus",
"string",
",",
"timeout",
"time",
".",
"Duration",
")",
"(",
"status",
"string",
",",
"err",
"error",
")",
"{",
"deployment",
":=",
"f",
".",
... | // DeployTemplateStatus returns the current status of a deployed template.
// If the current status is the same as the value of the lastStatus parameter,
// block until the status changes, then return the new status. A timeout may
// be applied to the status change wait; if the timeout is negative then return
// immed... | [
"DeployTemplateStatus",
"returns",
"the",
"current",
"status",
"of",
"a",
"deployed",
"template",
".",
"If",
"the",
"current",
"status",
"is",
"the",
"same",
"as",
"the",
"value",
"of",
"the",
"lastStatus",
"parameter",
"block",
"until",
"the",
"status",
"chan... | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/facade/servicetemplate.go#L268-L291 |
139,714 | control-center/serviced | facade/servicetemplate.go | DeployService | func (f *Facade) DeployService(ctx datastore.Context, poolID, parentID string, overwrite bool, svcDef servicedefinition.ServiceDefinition) (string, error) {
defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.DeployService"))
store := f.serviceStore
alog := f.auditLogger.Message(ctx, "Deploying Service Definition")... | go | func (f *Facade) DeployService(ctx datastore.Context, poolID, parentID string, overwrite bool, svcDef servicedefinition.ServiceDefinition) (string, error) {
defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.DeployService"))
store := f.serviceStore
alog := f.auditLogger.Message(ctx, "Deploying Service Definition")... | [
"func",
"(",
"f",
"*",
"Facade",
")",
"DeployService",
"(",
"ctx",
"datastore",
".",
"Context",
",",
"poolID",
",",
"parentID",
"string",
",",
"overwrite",
"bool",
",",
"svcDef",
"servicedefinition",
".",
"ServiceDefinition",
")",
"(",
"string",
",",
"error"... | // DeployService converts a service definition to a service and deploys it under
// a specific service. If the overwrite option is enabled, existing services
// with the same name will be overwritten, otherwise services may only be added. | [
"DeployService",
"converts",
"a",
"service",
"definition",
"to",
"a",
"service",
"and",
"deploys",
"it",
"under",
"a",
"specific",
"service",
".",
"If",
"the",
"overwrite",
"option",
"is",
"enabled",
"existing",
"services",
"with",
"the",
"same",
"name",
"will... | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/facade/servicetemplate.go#L371-L423 |
139,715 | control-center/serviced | dfs/restore.go | restoreV0 | func (dfs *DistributedFilesystem) restoreV0(r io.Reader) error {
backuptar := tar.NewReader(r)
// keep track of the snapshots that have been imported
snapshots := make(map[string][]string)
for {
hdr, err := backuptar.Next()
if err == io.EOF {
break
} else if err != nil {
plog.WithError(err).Error("Cou... | go | func (dfs *DistributedFilesystem) restoreV0(r io.Reader) error {
backuptar := tar.NewReader(r)
// keep track of the snapshots that have been imported
snapshots := make(map[string][]string)
for {
hdr, err := backuptar.Next()
if err == io.EOF {
break
} else if err != nil {
plog.WithError(err).Error("Cou... | [
"func",
"(",
"dfs",
"*",
"DistributedFilesystem",
")",
"restoreV0",
"(",
"r",
"io",
".",
"Reader",
")",
"error",
"{",
"backuptar",
":=",
"tar",
".",
"NewReader",
"(",
"r",
")",
"\n\n",
"// keep track of the snapshots that have been imported",
"snapshots",
":=",
... | // restoreV0 restores a pre-1.1.3 backup | [
"restoreV0",
"restores",
"a",
"pre",
"-",
"1",
".",
"1",
".",
"3",
"backup"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dfs/restore.go#L46-L107 |
139,716 | control-center/serviced | dfs/restore.go | imageLoadPipe | func (dfs *DistributedFilesystem) imageLoadPipe() (*io.PipeWriter, <-chan error) {
return loadPipe(dfs.docker.LoadImage)
} | go | func (dfs *DistributedFilesystem) imageLoadPipe() (*io.PipeWriter, <-chan error) {
return loadPipe(dfs.docker.LoadImage)
} | [
"func",
"(",
"dfs",
"*",
"DistributedFilesystem",
")",
"imageLoadPipe",
"(",
")",
"(",
"*",
"io",
".",
"PipeWriter",
",",
"<-",
"chan",
"error",
")",
"{",
"return",
"loadPipe",
"(",
"dfs",
".",
"docker",
".",
"LoadImage",
")",
"\n",
"}"
] | // imageLoadPipe returns a pipe writer and error channel for restoring docker
// images. | [
"imageLoadPipe",
"returns",
"a",
"pipe",
"writer",
"and",
"error",
"channel",
"for",
"restoring",
"docker",
"images",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dfs/restore.go#L282-L284 |
139,717 | control-center/serviced | dfs/restore.go | snapshotLoadPipe | func (dfs *DistributedFilesystem) snapshotLoadPipe(tenant, label string) (*io.PipeWriter, <-chan error) {
return loadPipe(func(r io.Reader) error {
return dfs.restoreSnapshot(tenant, label, r)
})
} | go | func (dfs *DistributedFilesystem) snapshotLoadPipe(tenant, label string) (*io.PipeWriter, <-chan error) {
return loadPipe(func(r io.Reader) error {
return dfs.restoreSnapshot(tenant, label, r)
})
} | [
"func",
"(",
"dfs",
"*",
"DistributedFilesystem",
")",
"snapshotLoadPipe",
"(",
"tenant",
",",
"label",
"string",
")",
"(",
"*",
"io",
".",
"PipeWriter",
",",
"<-",
"chan",
"error",
")",
"{",
"return",
"loadPipe",
"(",
"func",
"(",
"r",
"io",
".",
"Rea... | // snapshotLoadPipe returns a pipe writer and error channel for restoring
// a snapshot from a backup | [
"snapshotLoadPipe",
"returns",
"a",
"pipe",
"writer",
"and",
"error",
"channel",
"for",
"restoring",
"a",
"snapshot",
"from",
"a",
"backup"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dfs/restore.go#L288-L292 |
139,718 | control-center/serviced | dfs/restore.go | restoreSnapshot | func (dfs *DistributedFilesystem) restoreSnapshot(tenant, label string, r io.Reader) error {
tenantLogger := plog.WithField("tenant", tenant)
vol, err := dfs.disk.Create(tenant)
if err == volume.ErrVolumeExists {
if vol, err = dfs.disk.Get(tenant); err != nil {
tenantLogger.WithError(err).Error("Could not get ... | go | func (dfs *DistributedFilesystem) restoreSnapshot(tenant, label string, r io.Reader) error {
tenantLogger := plog.WithField("tenant", tenant)
vol, err := dfs.disk.Create(tenant)
if err == volume.ErrVolumeExists {
if vol, err = dfs.disk.Get(tenant); err != nil {
tenantLogger.WithError(err).Error("Could not get ... | [
"func",
"(",
"dfs",
"*",
"DistributedFilesystem",
")",
"restoreSnapshot",
"(",
"tenant",
",",
"label",
"string",
",",
"r",
"io",
".",
"Reader",
")",
"error",
"{",
"tenantLogger",
":=",
"plog",
".",
"WithField",
"(",
"\"",
"\"",
",",
"tenant",
")",
"\n\n"... | // restoreSnapshot restores snapshot volume data from a backup for a specific
// tenant. | [
"restoreSnapshot",
"restores",
"snapshot",
"volume",
"data",
"from",
"a",
"backup",
"for",
"a",
"specific",
"tenant",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dfs/restore.go#L296-L326 |
139,719 | control-center/serviced | dfs/restore.go | loadSnapshotImages | func (dfs *DistributedFilesystem) loadSnapshotImages(tenant, label string) error {
vol, err := dfs.disk.Get(tenant)
if err != nil {
plog.WithError(err).WithField("tenant", tenant).Error("Could not get volume for tenant")
return err
}
tenantLogger := plog.WithFields(log.Fields{
"label": label,
"tenant": te... | go | func (dfs *DistributedFilesystem) loadSnapshotImages(tenant, label string) error {
vol, err := dfs.disk.Get(tenant)
if err != nil {
plog.WithError(err).WithField("tenant", tenant).Error("Could not get volume for tenant")
return err
}
tenantLogger := plog.WithFields(log.Fields{
"label": label,
"tenant": te... | [
"func",
"(",
"dfs",
"*",
"DistributedFilesystem",
")",
"loadSnapshotImages",
"(",
"tenant",
",",
"label",
"string",
")",
"error",
"{",
"vol",
",",
"err",
":=",
"dfs",
".",
"disk",
".",
"Get",
"(",
"tenant",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"... | // loadSnapshotImages adds images to the registry based on the information
// provided by the loaded snapshot. | [
"loadSnapshotImages",
"adds",
"images",
"to",
"the",
"registry",
"based",
"on",
"the",
"information",
"provided",
"by",
"the",
"loaded",
"snapshot",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dfs/restore.go#L330-L393 |
139,720 | control-center/serviced | dfs/restore.go | loadPipe | func loadPipe(do func(io.Reader) error) (*io.PipeWriter, <-chan error) {
r, w := io.Pipe()
errc := make(chan error)
go func() {
progress := NewProgressCounter(300)
progress.Log = func() { plog.Infof("Read %v bytes from archive for restore", progress.Total) }
tr := io.TeeReader(r, progress)
err := do(tr)
r... | go | func loadPipe(do func(io.Reader) error) (*io.PipeWriter, <-chan error) {
r, w := io.Pipe()
errc := make(chan error)
go func() {
progress := NewProgressCounter(300)
progress.Log = func() { plog.Infof("Read %v bytes from archive for restore", progress.Total) }
tr := io.TeeReader(r, progress)
err := do(tr)
r... | [
"func",
"loadPipe",
"(",
"do",
"func",
"(",
"io",
".",
"Reader",
")",
"error",
")",
"(",
"*",
"io",
".",
"PipeWriter",
",",
"<-",
"chan",
"error",
")",
"{",
"r",
",",
"w",
":=",
"io",
".",
"Pipe",
"(",
")",
"\n",
"errc",
":=",
"make",
"(",
"c... | // loadPipe sets up an async pipe for writing snapshot and docker information. | [
"loadPipe",
"sets",
"up",
"an",
"async",
"pipe",
"for",
"writing",
"snapshot",
"and",
"docker",
"information",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dfs/restore.go#L396-L409 |
139,721 | control-center/serviced | commons/atomicfile/atomicfile.go | WriteFile | func WriteFile(filename string, data []byte, perm os.FileMode) error {
// find the dirname of the filename
d := filepath.Dir(filename)
if err := os.MkdirAll(d, 0755); err != nil {
return err
}
tempfile, err := ioutil.TempFile(d, filepath.Base(filename))
if err != nil {
return err
}
name := tempfile.Name()... | go | func WriteFile(filename string, data []byte, perm os.FileMode) error {
// find the dirname of the filename
d := filepath.Dir(filename)
if err := os.MkdirAll(d, 0755); err != nil {
return err
}
tempfile, err := ioutil.TempFile(d, filepath.Base(filename))
if err != nil {
return err
}
name := tempfile.Name()... | [
"func",
"WriteFile",
"(",
"filename",
"string",
",",
"data",
"[",
"]",
"byte",
",",
"perm",
"os",
".",
"FileMode",
")",
"error",
"{",
"// find the dirname of the filename",
"d",
":=",
"filepath",
".",
"Dir",
"(",
"filename",
")",
"\n",
"if",
"err",
":=",
... | // WriteFile will write the given data to the filename in an atomic manner so that
// partial writes are not possible. | [
"WriteFile",
"will",
"write",
"the",
"given",
"data",
"to",
"the",
"filename",
"in",
"an",
"atomic",
"manner",
"so",
"that",
"partial",
"writes",
"are",
"not",
"possible",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/commons/atomicfile/atomicfile.go#L24-L51 |
139,722 | control-center/serviced | coordinator/client/backoff.go | GetDelay | func (backoff *Backoff) GetDelay() time.Duration {
defer func() {
factor := 2.0
jitter := 6.0
backoff.delay = time.Duration(float64(backoff.delay) * factor)
backoff.delay += time.Duration(backoff.random.Float64() * jitter * float64(time.Second))
if backoff.delay > backoff.MaxDelay {
backoff.delay = backo... | go | func (backoff *Backoff) GetDelay() time.Duration {
defer func() {
factor := 2.0
jitter := 6.0
backoff.delay = time.Duration(float64(backoff.delay) * factor)
backoff.delay += time.Duration(backoff.random.Float64() * jitter * float64(time.Second))
if backoff.delay > backoff.MaxDelay {
backoff.delay = backo... | [
"func",
"(",
"backoff",
"*",
"Backoff",
")",
"GetDelay",
"(",
")",
"time",
".",
"Duration",
"{",
"defer",
"func",
"(",
")",
"{",
"factor",
":=",
"2.0",
"\n",
"jitter",
":=",
"6.0",
"\n\n",
"backoff",
".",
"delay",
"=",
"time",
".",
"Duration",
"(",
... | // GetDelay returns the amount of delay that should be used for the current connection attempt.
// It will return a randomized value of initialDelay on the first call, and will increase the delay
// randomly on each subsequent call up to maxDelay. The initial delay and each subsequent delay
// are randomized to avoid a... | [
"GetDelay",
"returns",
"the",
"amount",
"of",
"delay",
"that",
"should",
"be",
"used",
"for",
"the",
"current",
"connection",
"attempt",
".",
"It",
"will",
"return",
"a",
"randomized",
"value",
"of",
"initialDelay",
"on",
"the",
"first",
"call",
"and",
"will... | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/coordinator/client/backoff.go#L41-L61 |
139,723 | control-center/serviced | coordinator/client/backoff.go | Reset | func (backoff *Backoff) Reset() {
start := backoff.InitialDelay.Seconds()
minStart := 0.8 * start
maxStart := 1.2 * start
if backoff.random == nil {
backoff.initialize()
}
// compute a random value between min and max start
rando := backoff.random.Float64()
start = minStart + (rando * (maxStart - minStart))... | go | func (backoff *Backoff) Reset() {
start := backoff.InitialDelay.Seconds()
minStart := 0.8 * start
maxStart := 1.2 * start
if backoff.random == nil {
backoff.initialize()
}
// compute a random value between min and max start
rando := backoff.random.Float64()
start = minStart + (rando * (maxStart - minStart))... | [
"func",
"(",
"backoff",
"*",
"Backoff",
")",
"Reset",
"(",
")",
"{",
"start",
":=",
"backoff",
".",
"InitialDelay",
".",
"Seconds",
"(",
")",
"\n",
"minStart",
":=",
"0.8",
"*",
"start",
"\n",
"maxStart",
":=",
"1.2",
"*",
"start",
"\n\n",
"if",
"bac... | // Reset resets the backoff delay to some random value that is btwn 80-120% of the initialDelay.
// We want to randomize the initial delay so in cases where many instances simultaneously
// lose all ZK connections, they will not all start trying to reconnect at the same time. | [
"Reset",
"resets",
"the",
"backoff",
"delay",
"to",
"some",
"random",
"value",
"that",
"is",
"btwn",
"80",
"-",
"120%",
"of",
"the",
"initialDelay",
".",
"We",
"want",
"to",
"randomize",
"the",
"initial",
"delay",
"so",
"in",
"cases",
"where",
"many",
"i... | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/coordinator/client/backoff.go#L66-L84 |
139,724 | control-center/serviced | rpc/agent/agent.go | NewServer | func NewServer(staticIPs []string) *AgentServer {
// make our own copy of the slice of ips
ips := make([]string, len(staticIPs))
copy(ips, staticIPs)
return &AgentServer{
staticIPs: ips,
}
} | go | func NewServer(staticIPs []string) *AgentServer {
// make our own copy of the slice of ips
ips := make([]string, len(staticIPs))
copy(ips, staticIPs)
return &AgentServer{
staticIPs: ips,
}
} | [
"func",
"NewServer",
"(",
"staticIPs",
"[",
"]",
"string",
")",
"*",
"AgentServer",
"{",
"// make our own copy of the slice of ips",
"ips",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"staticIPs",
")",
")",
"\n",
"copy",
"(",
"ips",
",",
"stati... | // NewServer returns a new AgentServer | [
"NewServer",
"returns",
"a",
"new",
"AgentServer"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/rpc/agent/agent.go#L32-L39 |
139,725 | control-center/serviced | rpc/agent/agent.go | GetDockerLogs | func (a *AgentServer) GetDockerLogs(dockerID string, logs *string) error {
cmd := exec.Command("docker", "logs", "--tail=2000", dockerID)
output, err := cmd.CombinedOutput()
if err != nil {
plog.WithError(err).WithField("dockerid", dockerID).Error("Unable to retrieve logs from docker")
return err
}
*logs = str... | go | func (a *AgentServer) GetDockerLogs(dockerID string, logs *string) error {
cmd := exec.Command("docker", "logs", "--tail=2000", dockerID)
output, err := cmd.CombinedOutput()
if err != nil {
plog.WithError(err).WithField("dockerid", dockerID).Error("Unable to retrieve logs from docker")
return err
}
*logs = str... | [
"func",
"(",
"a",
"*",
"AgentServer",
")",
"GetDockerLogs",
"(",
"dockerID",
"string",
",",
"logs",
"*",
"string",
")",
"error",
"{",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"dockerID",
")",
"\n"... | // GetDockerLogs returns the last 2000 lines of logs from the docker container | [
"GetDockerLogs",
"returns",
"the",
"last",
"2000",
"lines",
"of",
"logs",
"from",
"the",
"docker",
"container"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/rpc/agent/agent.go#L76-L85 |
139,726 | control-center/serviced | rpc/agent/agent.go | PullImage | func (a *AgentServer) PullImage(req PullImageRequest, image *string) error {
logger := plog.WithFields(logrus.Fields{
"image": req.Image,
"registry": req.Registry})
// set up the connections
docker, err := docker.NewDockerClient()
if err != nil {
logger.WithError(err).Error("Could not connect to docker clie... | go | func (a *AgentServer) PullImage(req PullImageRequest, image *string) error {
logger := plog.WithFields(logrus.Fields{
"image": req.Image,
"registry": req.Registry})
// set up the connections
docker, err := docker.NewDockerClient()
if err != nil {
logger.WithError(err).Error("Could not connect to docker clie... | [
"func",
"(",
"a",
"*",
"AgentServer",
")",
"PullImage",
"(",
"req",
"PullImageRequest",
",",
"image",
"*",
"string",
")",
"error",
"{",
"logger",
":=",
"plog",
".",
"WithFields",
"(",
"logrus",
".",
"Fields",
"{",
"\"",
"\"",
":",
"req",
".",
"Image",
... | // PullImage pulls a registry image into the local repository. Returns the
// current image tag. | [
"PullImage",
"pulls",
"a",
"registry",
"image",
"into",
"the",
"local",
"repository",
".",
"Returns",
"the",
"current",
"image",
"tag",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/rpc/agent/agent.go#L96-L132 |
139,727 | control-center/serviced | domain/serviceconfigfile/validation.go | ValidEntity | func (scf SvcConfigFile) ValidEntity() error {
vErr := validation.NewValidationError()
vErr.Add(validation.NotEmpty("ID", scf.ID))
vErr.Add(validation.NotEmpty("ServiceTenantID", scf.ServiceTenantID))
vErr.Add(validation.NotEmpty("ServicePath", scf.ServicePath))
//path must start with /
if !strings.HasPrefix(scf... | go | func (scf SvcConfigFile) ValidEntity() error {
vErr := validation.NewValidationError()
vErr.Add(validation.NotEmpty("ID", scf.ID))
vErr.Add(validation.NotEmpty("ServiceTenantID", scf.ServiceTenantID))
vErr.Add(validation.NotEmpty("ServicePath", scf.ServicePath))
//path must start with /
if !strings.HasPrefix(scf... | [
"func",
"(",
"scf",
"SvcConfigFile",
")",
"ValidEntity",
"(",
")",
"error",
"{",
"vErr",
":=",
"validation",
".",
"NewValidationError",
"(",
")",
"\n",
"vErr",
".",
"Add",
"(",
"validation",
".",
"NotEmpty",
"(",
"\"",
"\"",
",",
"scf",
".",
"ID",
")",... | //ValidEntity check if fields are valid | [
"ValidEntity",
"check",
"if",
"fields",
"are",
"valid"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/serviceconfigfile/validation.go#L22-L40 |
139,728 | control-center/serviced | rpc/master/pool_client.go | GetResourcePool | func (c *Client) GetResourcePool(poolID string) (*pool.ResourcePool, error) {
response := pool.New(poolID)
if err := c.call("GetResourcePool", poolID, response); err != nil {
return nil, err
}
return response, nil
} | go | func (c *Client) GetResourcePool(poolID string) (*pool.ResourcePool, error) {
response := pool.New(poolID)
if err := c.call("GetResourcePool", poolID, response); err != nil {
return nil, err
}
return response, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetResourcePool",
"(",
"poolID",
"string",
")",
"(",
"*",
"pool",
".",
"ResourcePool",
",",
"error",
")",
"{",
"response",
":=",
"pool",
".",
"New",
"(",
"poolID",
")",
"\n",
"if",
"err",
":=",
"c",
".",
"call... | //GetResourcePool gets the pool for the given poolID or nil | [
"GetResourcePool",
"gets",
"the",
"pool",
"for",
"the",
"given",
"poolID",
"or",
"nil"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/rpc/master/pool_client.go#L21-L27 |
139,729 | control-center/serviced | rpc/master/pool_client.go | GetResourcePools | func (c *Client) GetResourcePools() ([]pool.ResourcePool, error) {
response := make([]pool.ResourcePool, 0)
if err := c.call("GetResourcePools", empty, &response); err != nil {
return []pool.ResourcePool{}, err
}
return response, nil
} | go | func (c *Client) GetResourcePools() ([]pool.ResourcePool, error) {
response := make([]pool.ResourcePool, 0)
if err := c.call("GetResourcePools", empty, &response); err != nil {
return []pool.ResourcePool{}, err
}
return response, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetResourcePools",
"(",
")",
"(",
"[",
"]",
"pool",
".",
"ResourcePool",
",",
"error",
")",
"{",
"response",
":=",
"make",
"(",
"[",
"]",
"pool",
".",
"ResourcePool",
",",
"0",
")",
"\n",
"if",
"err",
":=",
... | // GetResourcePools returns all pools or empty array | [
"GetResourcePools",
"returns",
"all",
"pools",
"or",
"empty",
"array"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/rpc/master/pool_client.go#L30-L36 |
139,730 | control-center/serviced | rpc/master/pool_client.go | AddResourcePool | func (c *Client) AddResourcePool(pool pool.ResourcePool) error {
return c.call("AddResourcePool", pool, nil)
} | go | func (c *Client) AddResourcePool(pool pool.ResourcePool) error {
return c.call("AddResourcePool", pool, nil)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"AddResourcePool",
"(",
"pool",
"pool",
".",
"ResourcePool",
")",
"error",
"{",
"return",
"c",
".",
"call",
"(",
"\"",
"\"",
",",
"pool",
",",
"nil",
")",
"\n",
"}"
] | //AddResourcePool adds the ResourcePool | [
"AddResourcePool",
"adds",
"the",
"ResourcePool"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/rpc/master/pool_client.go#L39-L41 |
139,731 | control-center/serviced | rpc/master/pool_client.go | UpdateResourcePool | func (c *Client) UpdateResourcePool(pool pool.ResourcePool) error {
return c.call("UpdateResourcePool", pool, nil)
} | go | func (c *Client) UpdateResourcePool(pool pool.ResourcePool) error {
return c.call("UpdateResourcePool", pool, nil)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateResourcePool",
"(",
"pool",
"pool",
".",
"ResourcePool",
")",
"error",
"{",
"return",
"c",
".",
"call",
"(",
"\"",
"\"",
",",
"pool",
",",
"nil",
")",
"\n",
"}"
] | //UpdateResourcePool adds the ResourcePool | [
"UpdateResourcePool",
"adds",
"the",
"ResourcePool"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/rpc/master/pool_client.go#L44-L46 |
139,732 | control-center/serviced | rpc/master/pool_client.go | RemoveResourcePool | func (c *Client) RemoveResourcePool(poolID string) error {
return c.call("RemoveResourcePool", poolID, nil)
} | go | func (c *Client) RemoveResourcePool(poolID string) error {
return c.call("RemoveResourcePool", poolID, nil)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"RemoveResourcePool",
"(",
"poolID",
"string",
")",
"error",
"{",
"return",
"c",
".",
"call",
"(",
"\"",
"\"",
",",
"poolID",
",",
"nil",
")",
"\n",
"}"
] | //RemoveResourcePool removes a ResourcePool | [
"RemoveResourcePool",
"removes",
"a",
"ResourcePool"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/rpc/master/pool_client.go#L49-L51 |
139,733 | control-center/serviced | rpc/master/pool_client.go | GetPoolIPs | func (c *Client) GetPoolIPs(poolID string) (*pool.PoolIPs, error) {
var poolIPs pool.PoolIPs
if err := c.call("GetPoolIPs", poolID, &poolIPs); err != nil {
return nil, err
}
return &poolIPs, nil
} | go | func (c *Client) GetPoolIPs(poolID string) (*pool.PoolIPs, error) {
var poolIPs pool.PoolIPs
if err := c.call("GetPoolIPs", poolID, &poolIPs); err != nil {
return nil, err
}
return &poolIPs, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetPoolIPs",
"(",
"poolID",
"string",
")",
"(",
"*",
"pool",
".",
"PoolIPs",
",",
"error",
")",
"{",
"var",
"poolIPs",
"pool",
".",
"PoolIPs",
"\n",
"if",
"err",
":=",
"c",
".",
"call",
"(",
"\"",
"\"",
",",... | //GetPoolIPs returns a all IPs in a ResourcePool. | [
"GetPoolIPs",
"returns",
"a",
"all",
"IPs",
"in",
"a",
"ResourcePool",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/rpc/master/pool_client.go#L54-L60 |
139,734 | control-center/serviced | rpc/master/pool_client.go | AddVirtualIP | func (c *Client) AddVirtualIP(requestVirtualIP pool.VirtualIP) error {
return c.call("AddVirtualIP", requestVirtualIP, nil)
} | go | func (c *Client) AddVirtualIP(requestVirtualIP pool.VirtualIP) error {
return c.call("AddVirtualIP", requestVirtualIP, nil)
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"AddVirtualIP",
"(",
"requestVirtualIP",
"pool",
".",
"VirtualIP",
")",
"error",
"{",
"return",
"c",
".",
"call",
"(",
"\"",
"\"",
",",
"requestVirtualIP",
",",
"nil",
")",
"\n",
"}"
] | //AddVirtualIP adds a VirtualIP to a specificpool | [
"AddVirtualIP",
"adds",
"a",
"VirtualIP",
"to",
"a",
"specificpool"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/rpc/master/pool_client.go#L63-L65 |
139,735 | control-center/serviced | volume/devicemapper/prefix.go | GetDevicePrefix | func GetDevicePrefix(root string) (string, error) {
st, err := os.Stat(root)
if err != nil {
return "", fmt.Errorf("Error looking up dir %s: %s", root, err)
}
sysSt := st.Sys().(*syscall.Stat_t)
// "reg-" stands for "regular file".
// In the future we might use "dev-" for "device file", etc.
// docker-maj,min[... | go | func GetDevicePrefix(root string) (string, error) {
st, err := os.Stat(root)
if err != nil {
return "", fmt.Errorf("Error looking up dir %s: %s", root, err)
}
sysSt := st.Sys().(*syscall.Stat_t)
// "reg-" stands for "regular file".
// In the future we might use "dev-" for "device file", etc.
// docker-maj,min[... | [
"func",
"GetDevicePrefix",
"(",
"root",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"st",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"root",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
... | // Calculate the same device prefix as Docker, using mostly their code | [
"Calculate",
"the",
"same",
"device",
"prefix",
"as",
"Docker",
"using",
"mostly",
"their",
"code"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/devicemapper/prefix.go#L20-L33 |
139,736 | control-center/serviced | domain/monitor.go | Equals | func (profile *MonitorProfile) Equals(that *MonitorProfile) bool {
return reflect.DeepEqual(profile, that)
} | go | func (profile *MonitorProfile) Equals(that *MonitorProfile) bool {
return reflect.DeepEqual(profile, that)
} | [
"func",
"(",
"profile",
"*",
"MonitorProfile",
")",
"Equals",
"(",
"that",
"*",
"MonitorProfile",
")",
"bool",
"{",
"return",
"reflect",
".",
"DeepEqual",
"(",
"profile",
",",
"that",
")",
"\n",
"}"
] | //Equals equality test for MonitorProfile | [
"Equals",
"equality",
"test",
"for",
"MonitorProfile"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/monitor.go#L31-L33 |
139,737 | control-center/serviced | domain/monitor.go | ReBuild | func (profile *MonitorProfile) ReBuild(timeSpan string, tags map[string][]string) (*MonitorProfile, error) {
newProfile := MonitorProfile{
MetricConfigs: make([]MetricConfig, len(profile.MetricConfigs)),
GraphConfigs: make([]GraphConfig, len(profile.GraphConfigs)),
ThresholdConfigs: make([]ThresholdConfig... | go | func (profile *MonitorProfile) ReBuild(timeSpan string, tags map[string][]string) (*MonitorProfile, error) {
newProfile := MonitorProfile{
MetricConfigs: make([]MetricConfig, len(profile.MetricConfigs)),
GraphConfigs: make([]GraphConfig, len(profile.GraphConfigs)),
ThresholdConfigs: make([]ThresholdConfig... | [
"func",
"(",
"profile",
"*",
"MonitorProfile",
")",
"ReBuild",
"(",
"timeSpan",
"string",
",",
"tags",
"map",
"[",
"string",
"]",
"[",
"]",
"string",
")",
"(",
"*",
"MonitorProfile",
",",
"error",
")",
"{",
"newProfile",
":=",
"MonitorProfile",
"{",
"Met... | //ReBuild metrics, graphs and thresholds with the new tags, also set graphs units based on datapoints | [
"ReBuild",
"metrics",
"graphs",
"and",
"thresholds",
"with",
"the",
"new",
"tags",
"also",
"set",
"graphs",
"units",
"based",
"on",
"datapoints"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/monitor.go#L36-L109 |
139,738 | control-center/serviced | domain/monitor.go | ValidEntity | func (profile MonitorProfile) ValidEntity() error {
violations := validation.NewValidationError()
for _, mc := range profile.MetricConfigs {
violations.Add(mc.ValidEntity())
}
for _, gc := range profile.GraphConfigs {
violations.Add(gc.ValidEntity())
}
if violations.HasError() {
return violations
}
retur... | go | func (profile MonitorProfile) ValidEntity() error {
violations := validation.NewValidationError()
for _, mc := range profile.MetricConfigs {
violations.Add(mc.ValidEntity())
}
for _, gc := range profile.GraphConfigs {
violations.Add(gc.ValidEntity())
}
if violations.HasError() {
return violations
}
retur... | [
"func",
"(",
"profile",
"MonitorProfile",
")",
"ValidEntity",
"(",
")",
"error",
"{",
"violations",
":=",
"validation",
".",
"NewValidationError",
"(",
")",
"\n",
"for",
"_",
",",
"mc",
":=",
"range",
"profile",
".",
"MetricConfigs",
"{",
"violations",
".",
... | // ValidEntity ensures the monitor profile is valid before it is written to the
// database. | [
"ValidEntity",
"ensures",
"the",
"monitor",
"profile",
"is",
"valid",
"before",
"it",
"is",
"written",
"to",
"the",
"database",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/monitor.go#L113-L126 |
139,739 | control-center/serviced | domain/pool/poolstore.go | GetResourcePools | func (ps *storeImpl) GetResourcePools(ctx datastore.Context) ([]ResourcePool, error) {
defer ctx.Metrics().Stop(ctx.Metrics().Start("PoolStore.GetResourcePools"))
return query(ctx, "_exists_:ID")
} | go | func (ps *storeImpl) GetResourcePools(ctx datastore.Context) ([]ResourcePool, error) {
defer ctx.Metrics().Stop(ctx.Metrics().Start("PoolStore.GetResourcePools"))
return query(ctx, "_exists_:ID")
} | [
"func",
"(",
"ps",
"*",
"storeImpl",
")",
"GetResourcePools",
"(",
"ctx",
"datastore",
".",
"Context",
")",
"(",
"[",
"]",
"ResourcePool",
",",
"error",
")",
"{",
"defer",
"ctx",
".",
"Metrics",
"(",
")",
".",
"Stop",
"(",
"ctx",
".",
"Metrics",
"(",... | //GetResourcePools Get a list of all the resource pools | [
"GetResourcePools",
"Get",
"a",
"list",
"of",
"all",
"the",
"resource",
"pools"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/pool/poolstore.go#L49-L52 |
139,740 | control-center/serviced | domain/pool/poolstore.go | HasVirtualIP | func (s *storeImpl) HasVirtualIP(ctx datastore.Context, poolID, virtualIP string) (bool, error) {
defer ctx.Metrics().Stop(ctx.Metrics().Start("PoolStore.HasVirtualIP"))
if poolID = strings.TrimSpace(poolID); poolID == "" {
return false, errors.New("empty pool id not allowed")
} else if virtualIP = strings.TrimSpa... | go | func (s *storeImpl) HasVirtualIP(ctx datastore.Context, poolID, virtualIP string) (bool, error) {
defer ctx.Metrics().Stop(ctx.Metrics().Start("PoolStore.HasVirtualIP"))
if poolID = strings.TrimSpace(poolID); poolID == "" {
return false, errors.New("empty pool id not allowed")
} else if virtualIP = strings.TrimSpa... | [
"func",
"(",
"s",
"*",
"storeImpl",
")",
"HasVirtualIP",
"(",
"ctx",
"datastore",
".",
"Context",
",",
"poolID",
",",
"virtualIP",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"defer",
"ctx",
".",
"Metrics",
"(",
")",
".",
"Stop",
"(",
"ctx",
... | // HasVirtualIP returns true if there is a virtual ip found for the given pool | [
"HasVirtualIP",
"returns",
"true",
"if",
"there",
"is",
"a",
"virtual",
"ip",
"found",
"for",
"the",
"given",
"pool"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/pool/poolstore.go#L72-L91 |
139,741 | control-center/serviced | domain/servicetemplate/validation.go | ValidEntity | func (st *ServiceTemplate) ValidEntity() error {
// trimmedID := strings.TrimSpace(st.ID)
violations := validation.NewValidationError()
violations.Add(validation.NotEmpty("ServiceTemplate.ID", st.ID))
// violations.Add(validation.StringsEqual(st.ID, trimmedID, "leading and trailing spaces not allowed for service te... | go | func (st *ServiceTemplate) ValidEntity() error {
// trimmedID := strings.TrimSpace(st.ID)
violations := validation.NewValidationError()
violations.Add(validation.NotEmpty("ServiceTemplate.ID", st.ID))
// violations.Add(validation.StringsEqual(st.ID, trimmedID, "leading and trailing spaces not allowed for service te... | [
"func",
"(",
"st",
"*",
"ServiceTemplate",
")",
"ValidEntity",
"(",
")",
"error",
"{",
"//\ttrimmedID := strings.TrimSpace(st.ID)",
"violations",
":=",
"validation",
".",
"NewValidationError",
"(",
")",
"\n",
"violations",
".",
"Add",
"(",
"validation",
".",
"NotE... | // ValidEntity ensure that a ServiceTemplate has valid values | [
"ValidEntity",
"ensure",
"that",
"a",
"ServiceTemplate",
"has",
"valid",
"values"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/servicetemplate/validation.go#L24-L64 |
139,742 | control-center/serviced | domain/servicetemplate/validation.go | ValidEntity | func (st *serviceTemplateWrapper) ValidEntity() error {
v := validation.NewValidationError()
v.Add(validation.NotEmpty("ID", st.ID))
v.Add(validation.NotEmpty("Name", st.Name))
v.Add(validation.NotEmpty("Data", st.Data))
if v.HasError() {
return v
}
return nil
} | go | func (st *serviceTemplateWrapper) ValidEntity() error {
v := validation.NewValidationError()
v.Add(validation.NotEmpty("ID", st.ID))
v.Add(validation.NotEmpty("Name", st.Name))
v.Add(validation.NotEmpty("Data", st.Data))
if v.HasError() {
return v
}
return nil
} | [
"func",
"(",
"st",
"*",
"serviceTemplateWrapper",
")",
"ValidEntity",
"(",
")",
"error",
"{",
"v",
":=",
"validation",
".",
"NewValidationError",
"(",
")",
"\n",
"v",
".",
"Add",
"(",
"validation",
".",
"NotEmpty",
"(",
"\"",
"\"",
",",
"st",
".",
"ID"... | //ValidEntity makes sure all serviceTemplateWrapper have non-empty values | [
"ValidEntity",
"makes",
"sure",
"all",
"serviceTemplateWrapper",
"have",
"non",
"-",
"empty",
"values"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/servicetemplate/validation.go#L67-L77 |
139,743 | control-center/serviced | proxy/certs.go | TempCertFile | func TempCertFile() (string, error) {
f, err := ioutil.TempFile("", "zenoss_cert.")
if err != nil {
return "", err
}
defer f.Close()
fmt.Fprint(f, InsecureCertPEM)
return f.Name(), nil
} | go | func TempCertFile() (string, error) {
f, err := ioutil.TempFile("", "zenoss_cert.")
if err != nil {
return "", err
}
defer f.Close()
fmt.Fprint(f, InsecureCertPEM)
return f.Name(), nil
} | [
"func",
"TempCertFile",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"ioutil",
".",
"TempFile",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
... | // TempCertFile creates a temp file with the contents set to proxyCertPEM
// and returns the temp file path. | [
"TempCertFile",
"creates",
"a",
"temp",
"file",
"with",
"the",
"contents",
"set",
"to",
"proxyCertPEM",
"and",
"returns",
"the",
"temp",
"file",
"path",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/proxy/certs.go#L77-L85 |
139,744 | control-center/serviced | proxy/certs.go | TempKeyFile | func TempKeyFile() (string, error) {
f, err := ioutil.TempFile("", "zenoss_key.")
if err != nil {
return "", err
}
defer f.Close()
fmt.Fprint(f, InsecureKeyPEM)
return f.Name(), nil
} | go | func TempKeyFile() (string, error) {
f, err := ioutil.TempFile("", "zenoss_key.")
if err != nil {
return "", err
}
defer f.Close()
fmt.Fprint(f, InsecureKeyPEM)
return f.Name(), nil
} | [
"func",
"TempKeyFile",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"ioutil",
".",
"TempFile",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
... | // TempKeyFile creates a temp file with the contents set to proxyCertPEM
// and returns the temp file path. | [
"TempKeyFile",
"creates",
"a",
"temp",
"file",
"with",
"the",
"contents",
"set",
"to",
"proxyCertPEM",
"and",
"returns",
"the",
"temp",
"file",
"path",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/proxy/certs.go#L89-L97 |
139,745 | control-center/serviced | node/agent.go | NewHostAgent | func NewHostAgent(options AgentOptions, reg registry.Registry) (*HostAgent, error) {
// save off the arguments
agent := &HostAgent{}
agent.ipaddress = options.IPAddress
agent.poolID = options.PoolID
agent.master = options.Master
agent.uiport = options.UIPort
agent.rpcport = options.RPCPort
agent.rpcDisableTLS =... | go | func NewHostAgent(options AgentOptions, reg registry.Registry) (*HostAgent, error) {
// save off the arguments
agent := &HostAgent{}
agent.ipaddress = options.IPAddress
agent.poolID = options.PoolID
agent.master = options.Master
agent.uiport = options.UIPort
agent.rpcport = options.RPCPort
agent.rpcDisableTLS =... | [
"func",
"NewHostAgent",
"(",
"options",
"AgentOptions",
",",
"reg",
"registry",
".",
"Registry",
")",
"(",
"*",
"HostAgent",
",",
"error",
")",
"{",
"// save off the arguments",
"agent",
":=",
"&",
"HostAgent",
"{",
"}",
"\n",
"agent",
".",
"ipaddress",
"=",... | // NewHostAgent creates a new HostAgent given a connection string | [
"NewHostAgent",
"creates",
"a",
"new",
"HostAgent",
"given",
"a",
"connection",
"string"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/node/agent.go#L152-L201 |
139,746 | control-center/serviced | node/agent.go | AttachAndRun | func (a *HostAgent) AttachAndRun(dockerID string, command []string) ([]byte, error) {
return utils.AttachAndRun(dockerID, command)
} | go | func (a *HostAgent) AttachAndRun(dockerID string, command []string) ([]byte, error) {
return utils.AttachAndRun(dockerID, command)
} | [
"func",
"(",
"a",
"*",
"HostAgent",
")",
"AttachAndRun",
"(",
"dockerID",
"string",
",",
"command",
"[",
"]",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"utils",
".",
"AttachAndRun",
"(",
"dockerID",
",",
"command",
")",
... | // AttachAndRun implements zkdocker.ActionHandler; it attaches to a running
// container and performs a command as specified by the container's service
// definition | [
"AttachAndRun",
"implements",
"zkdocker",
".",
"ActionHandler",
";",
"it",
"attaches",
"to",
"a",
"running",
"container",
"and",
"performs",
"a",
"command",
"as",
"specified",
"by",
"the",
"container",
"s",
"service",
"definition"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/node/agent.go#L483-L485 |
139,747 | control-center/serviced | node/agent.go | addStorageTenant | func (a *HostAgent) addStorageTenant(tenantID string) {
for _, tid := range a.storageTenants {
if tid == tenantID {
return
}
}
a.storageTenants = append(a.storageTenants, tenantID)
} | go | func (a *HostAgent) addStorageTenant(tenantID string) {
for _, tid := range a.storageTenants {
if tid == tenantID {
return
}
}
a.storageTenants = append(a.storageTenants, tenantID)
} | [
"func",
"(",
"a",
"*",
"HostAgent",
")",
"addStorageTenant",
"(",
"tenantID",
"string",
")",
"{",
"for",
"_",
",",
"tid",
":=",
"range",
"a",
".",
"storageTenants",
"{",
"if",
"tid",
"==",
"tenantID",
"{",
"return",
"\n",
"}",
"\n",
"}",
"\n",
"a",
... | // addStorageTenant remembers a storage tenant we have used | [
"addStorageTenant",
"remembers",
"a",
"storage",
"tenant",
"we",
"have",
"used"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/node/agent.go#L488-L495 |
139,748 | control-center/serviced | node/agent.go | releaseStorageTenants | func (a *HostAgent) releaseStorageTenants() {
for _, tenantID := range a.storageTenants {
if err := a.storage.Release(tenantID); err != nil {
glog.Warningf("Could not release tenant %s: %s", tenantID, err)
}
}
} | go | func (a *HostAgent) releaseStorageTenants() {
for _, tenantID := range a.storageTenants {
if err := a.storage.Release(tenantID); err != nil {
glog.Warningf("Could not release tenant %s: %s", tenantID, err)
}
}
} | [
"func",
"(",
"a",
"*",
"HostAgent",
")",
"releaseStorageTenants",
"(",
")",
"{",
"for",
"_",
",",
"tenantID",
":=",
"range",
"a",
".",
"storageTenants",
"{",
"if",
"err",
":=",
"a",
".",
"storage",
".",
"Release",
"(",
"tenantID",
")",
";",
"err",
"!... | // releaseStorageTenants releases the resources for each tenant we have used | [
"releaseStorageTenants",
"releases",
"the",
"resources",
"for",
"each",
"tenant",
"we",
"have",
"used"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/node/agent.go#L498-L504 |
139,749 | control-center/serviced | web/virtualipresource.go | restAddPoolVirtualIP | func restAddPoolVirtualIP(w *rest.ResponseWriter, r *rest.Request, ctx *requestContext) {
//TODO replace virtualiprequest with model object
var request pool.VirtualIP
err := r.DecodeJsonPayload(&request)
if err != nil {
restBadRequest(w, err)
return
}
glog.V(0).Infof("Add virtual ip: %+v", request)
client,... | go | func restAddPoolVirtualIP(w *rest.ResponseWriter, r *rest.Request, ctx *requestContext) {
//TODO replace virtualiprequest with model object
var request pool.VirtualIP
err := r.DecodeJsonPayload(&request)
if err != nil {
restBadRequest(w, err)
return
}
glog.V(0).Infof("Add virtual ip: %+v", request)
client,... | [
"func",
"restAddPoolVirtualIP",
"(",
"w",
"*",
"rest",
".",
"ResponseWriter",
",",
"r",
"*",
"rest",
".",
"Request",
",",
"ctx",
"*",
"requestContext",
")",
"{",
"//TODO replace virtualiprequest with model object",
"var",
"request",
"pool",
".",
"VirtualIP",
"\n",... | // restAddPoolVirtualIP takes a poolID, IP, netmask, and bindinterface and adds it | [
"restAddPoolVirtualIP",
"takes",
"a",
"poolID",
"IP",
"netmask",
"and",
"bindinterface",
"and",
"adds",
"it"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/web/virtualipresource.go#L25-L49 |
139,750 | control-center/serviced | web/virtualipresource.go | restRemovePoolVirtualIP | func restRemovePoolVirtualIP(w *rest.ResponseWriter, r *rest.Request, ctx *requestContext) {
ip, err := url.QueryUnescape(r.PathParam("ip"))
if err != nil {
glog.Errorf("Could not get virtual ip (%v): %v", ip, err)
restBadRequest(w, err)
return
}
poolId, err := url.QueryUnescape(r.PathParam("poolId"))
if er... | go | func restRemovePoolVirtualIP(w *rest.ResponseWriter, r *rest.Request, ctx *requestContext) {
ip, err := url.QueryUnescape(r.PathParam("ip"))
if err != nil {
glog.Errorf("Could not get virtual ip (%v): %v", ip, err)
restBadRequest(w, err)
return
}
poolId, err := url.QueryUnescape(r.PathParam("poolId"))
if er... | [
"func",
"restRemovePoolVirtualIP",
"(",
"w",
"*",
"rest",
".",
"ResponseWriter",
",",
"r",
"*",
"rest",
".",
"Request",
",",
"ctx",
"*",
"requestContext",
")",
"{",
"ip",
",",
"err",
":=",
"url",
".",
"QueryUnescape",
"(",
"r",
".",
"PathParam",
"(",
"... | // restRemovePoolVirtualIP deletes virtualip | [
"restRemovePoolVirtualIP",
"deletes",
"virtualip"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/web/virtualipresource.go#L52-L82 |
139,751 | control-center/serviced | metrics/cache.go | Get | func (c *MemoryUsageCache) Get(key string, getter MemoryUsageQuery) (val []MemoryUsageStats, err error) {
c.Lock()
defer c.Unlock()
item, ok := c.Usages[key]
if ok {
if item.Expired() {
delete(c.Usages, key)
} else {
return item.value, nil
}
}
if val, err = getter(); err != nil {
return
}
c.Usages... | go | func (c *MemoryUsageCache) Get(key string, getter MemoryUsageQuery) (val []MemoryUsageStats, err error) {
c.Lock()
defer c.Unlock()
item, ok := c.Usages[key]
if ok {
if item.Expired() {
delete(c.Usages, key)
} else {
return item.value, nil
}
}
if val, err = getter(); err != nil {
return
}
c.Usages... | [
"func",
"(",
"c",
"*",
"MemoryUsageCache",
")",
"Get",
"(",
"key",
"string",
",",
"getter",
"MemoryUsageQuery",
")",
"(",
"val",
"[",
"]",
"MemoryUsageStats",
",",
"err",
"error",
")",
"{",
"c",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"Unlock... | // Get retrieves a cached value if one exists; otherwise it calls getter, caches the result, and returns it | [
"Get",
"retrieves",
"a",
"cached",
"value",
"if",
"one",
"exists",
";",
"otherwise",
"it",
"calls",
"getter",
"caches",
"the",
"result",
"and",
"returns",
"it"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/metrics/cache.go#L49-L68 |
139,752 | control-center/serviced | domain/graph.go | Equals | func (point *DataPoint) Equals(that *DataPoint) bool {
return reflect.DeepEqual(point, that)
} | go | func (point *DataPoint) Equals(that *DataPoint) bool {
return reflect.DeepEqual(point, that)
} | [
"func",
"(",
"point",
"*",
"DataPoint",
")",
"Equals",
"(",
"that",
"*",
"DataPoint",
")",
"bool",
"{",
"return",
"reflect",
".",
"DeepEqual",
"(",
"point",
",",
"that",
")",
"\n",
"}"
] | // Equals returns if point equals that point | [
"Equals",
"returns",
"if",
"point",
"equals",
"that",
"point"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/graph.go#L94-L96 |
139,753 | control-center/serviced | domain/graph.go | Equals | func (graph *GraphConfig) Equals(that *GraphConfig) bool {
return reflect.DeepEqual(graph, that)
} | go | func (graph *GraphConfig) Equals(that *GraphConfig) bool {
return reflect.DeepEqual(graph, that)
} | [
"func",
"(",
"graph",
"*",
"GraphConfig",
")",
"Equals",
"(",
"that",
"*",
"GraphConfig",
")",
"bool",
"{",
"return",
"reflect",
".",
"DeepEqual",
"(",
"graph",
",",
"that",
")",
"\n",
"}"
] | // Equals returns if graph equals that graph | [
"Equals",
"returns",
"if",
"graph",
"equals",
"that",
"graph"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/graph.go#L127-L129 |
139,754 | control-center/serviced | domain/graph.go | ValidEntity | func (graph GraphConfig) ValidEntity() error {
if strings.HasPrefix(graph.ID, "internal") {
return fmt.Errorf("graph %s: cannot have prefix 'internal'", graph.ID)
}
if graph.BuiltIn {
return fmt.Errorf("graph %s: cannot have BuiltIn set to true", graph.ID)
}
return nil
} | go | func (graph GraphConfig) ValidEntity() error {
if strings.HasPrefix(graph.ID, "internal") {
return fmt.Errorf("graph %s: cannot have prefix 'internal'", graph.ID)
}
if graph.BuiltIn {
return fmt.Errorf("graph %s: cannot have BuiltIn set to true", graph.ID)
}
return nil
} | [
"func",
"(",
"graph",
"GraphConfig",
")",
"ValidEntity",
"(",
")",
"error",
"{",
"if",
"strings",
".",
"HasPrefix",
"(",
"graph",
".",
"ID",
",",
"\"",
"\"",
")",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"graph",
".",
"ID",
")",
... | // ValidEntity ensures that no graph configs have an id with prefix "internal" | [
"ValidEntity",
"ensures",
"that",
"no",
"graph",
"configs",
"have",
"an",
"id",
"with",
"prefix",
"internal"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/graph.go#L132-L140 |
139,755 | control-center/serviced | cli/cmd/healthcheck.go | initHealthCheck | func (c *ServicedCli) initHealthCheck() {
c.app.Commands = append(c.app.Commands, cli.Command{
Name: "healthcheck",
Usage: "Reports on health of serviced",
Description: "serviced healthcheck [ISERVICENAME-1 [ISERVICENAME-2 ... [ISERVICENAME-N]]]",
Before: c.cmdHealthCheck,
})
} | go | func (c *ServicedCli) initHealthCheck() {
c.app.Commands = append(c.app.Commands, cli.Command{
Name: "healthcheck",
Usage: "Reports on health of serviced",
Description: "serviced healthcheck [ISERVICENAME-1 [ISERVICENAME-2 ... [ISERVICENAME-N]]]",
Before: c.cmdHealthCheck,
})
} | [
"func",
"(",
"c",
"*",
"ServicedCli",
")",
"initHealthCheck",
"(",
")",
"{",
"c",
".",
"app",
".",
"Commands",
"=",
"append",
"(",
"c",
".",
"app",
".",
"Commands",
",",
"cli",
".",
"Command",
"{",
"Name",
":",
"\"",
"\"",
",",
"Usage",
":",
"\""... | // Initializer for serviced healthcheck subcommands | [
"Initializer",
"for",
"serviced",
"healthcheck",
"subcommands"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/cmd/healthcheck.go#L24-L31 |
139,756 | control-center/serviced | rpc/master/docker_server.go | ResetRegistry | func (s *Server) ResetRegistry(req struct{}, reply *int) error {
return s.f.RepairRegistry(s.context())
} | go | func (s *Server) ResetRegistry(req struct{}, reply *int) error {
return s.f.RepairRegistry(s.context())
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"ResetRegistry",
"(",
"req",
"struct",
"{",
"}",
",",
"reply",
"*",
"int",
")",
"error",
"{",
"return",
"s",
".",
"f",
".",
"RepairRegistry",
"(",
"s",
".",
"context",
"(",
")",
")",
"\n",
"}"
] | // ResetRegistry pulls from the configured docker registry and updates the
// index. | [
"ResetRegistry",
"pulls",
"from",
"the",
"configured",
"docker",
"registry",
"and",
"updates",
"the",
"index",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/rpc/master/docker_server.go#L30-L32 |
139,757 | control-center/serviced | rpc/master/docker_server.go | SyncRegistry | func (s *Server) SyncRegistry(req struct{}, reply *int) error {
return s.f.SyncRegistryImages(s.context(), true)
} | go | func (s *Server) SyncRegistry(req struct{}, reply *int) error {
return s.f.SyncRegistryImages(s.context(), true)
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"SyncRegistry",
"(",
"req",
"struct",
"{",
"}",
",",
"reply",
"*",
"int",
")",
"error",
"{",
"return",
"s",
".",
"f",
".",
"SyncRegistryImages",
"(",
"s",
".",
"context",
"(",
")",
",",
"true",
")",
"\n",
"}"... | // SyncRegistry prompts the master to repush all images in the index into the
// docker registry. | [
"SyncRegistry",
"prompts",
"the",
"master",
"to",
"repush",
"all",
"images",
"in",
"the",
"index",
"into",
"the",
"docker",
"registry",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/rpc/master/docker_server.go#L36-L38 |
139,758 | control-center/serviced | rpc/master/docker_server.go | UpgradeRegistry | func (s *Server) UpgradeRegistry(req UpgradeDockerRequest, reply *int) error {
return s.f.UpgradeRegistry(s.context(), req.Endpoint, req.Override)
} | go | func (s *Server) UpgradeRegistry(req UpgradeDockerRequest, reply *int) error {
return s.f.UpgradeRegistry(s.context(), req.Endpoint, req.Override)
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"UpgradeRegistry",
"(",
"req",
"UpgradeDockerRequest",
",",
"reply",
"*",
"int",
")",
"error",
"{",
"return",
"s",
".",
"f",
".",
"UpgradeRegistry",
"(",
"s",
".",
"context",
"(",
")",
",",
"req",
".",
"Endpoint",
... | // UpgradeRegistry migrates docker registry images from an older or remote
// docker registry. | [
"UpgradeRegistry",
"migrates",
"docker",
"registry",
"images",
"from",
"an",
"older",
"or",
"remote",
"docker",
"registry",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/rpc/master/docker_server.go#L42-L44 |
139,759 | control-center/serviced | dao/client/cp_client.go | NewControlClient | func NewControlClient(addr string) (s *ControlClient, err error) {
client, err := rpcutils.GetCachedClient(addr)
if err != nil {
return nil, err
}
s = new(ControlClient)
s.addr = addr
s.rpcClient = client
return s, nil
} | go | func NewControlClient(addr string) (s *ControlClient, err error) {
client, err := rpcutils.GetCachedClient(addr)
if err != nil {
return nil, err
}
s = new(ControlClient)
s.addr = addr
s.rpcClient = client
return s, nil
} | [
"func",
"NewControlClient",
"(",
"addr",
"string",
")",
"(",
"s",
"*",
"ControlClient",
",",
"err",
"error",
")",
"{",
"client",
",",
"err",
":=",
"rpcutils",
".",
"GetCachedClient",
"(",
"addr",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil... | // Create a new ControlClient. | [
"Create",
"a",
"new",
"ControlClient",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dao/client/cp_client.go#L53-L62 |
139,760 | control-center/serviced | domain/threshold.go | Equals | func (config *ThresholdConfig) Equals(that *ThresholdConfig) bool {
return reflect.DeepEqual(config, that)
} | go | func (config *ThresholdConfig) Equals(that *ThresholdConfig) bool {
return reflect.DeepEqual(config, that)
} | [
"func",
"(",
"config",
"*",
"ThresholdConfig",
")",
"Equals",
"(",
"that",
"*",
"ThresholdConfig",
")",
"bool",
"{",
"return",
"reflect",
".",
"DeepEqual",
"(",
"config",
",",
"that",
")",
"\n",
"}"
] | //Equals compares two threshold configs for equality | [
"Equals",
"compares",
"two",
"threshold",
"configs",
"for",
"equality"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/threshold.go#L92-L94 |
139,761 | control-center/serviced | volume/devicemapper/devicemapper.go | Init | func Init(root string, options []string) (volume.Driver, error) {
driver := &DeviceMapperDriver{
root: root,
options: options,
}
if err := driver.ensureInitialized(); err != nil {
return nil, err
}
driver.cleanUpSnapshots()
return driver, nil
} | go | func Init(root string, options []string) (volume.Driver, error) {
driver := &DeviceMapperDriver{
root: root,
options: options,
}
if err := driver.ensureInitialized(); err != nil {
return nil, err
}
driver.cleanUpSnapshots()
return driver, nil
} | [
"func",
"Init",
"(",
"root",
"string",
",",
"options",
"[",
"]",
"string",
")",
"(",
"volume",
".",
"Driver",
",",
"error",
")",
"{",
"driver",
":=",
"&",
"DeviceMapperDriver",
"{",
"root",
":",
"root",
",",
"options",
":",
"options",
",",
"}",
"\n\n... | // Init initializes the devicemapper driver | [
"Init",
"initializes",
"the",
"devicemapper",
"driver"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/devicemapper/devicemapper.go#L73-L86 |
139,762 | control-center/serviced | volume/devicemapper/devicemapper.go | cleanUpSnapshots | func (d *DeviceMapperDriver) cleanUpSnapshots() {
snapshotsOnDisk, err := d.getSnapshotsOnDisk()
if err != nil || snapshotsOnDisk == nil {
return
}
glog.V(2).Infof("Snapshots on disk: %v", snapshotsOnDisk)
snapshotsInMetadata, err := d.getSnapshotsFromMetadata()
if err != nil || snapshotsInMetadata == nil {
... | go | func (d *DeviceMapperDriver) cleanUpSnapshots() {
snapshotsOnDisk, err := d.getSnapshotsOnDisk()
if err != nil || snapshotsOnDisk == nil {
return
}
glog.V(2).Infof("Snapshots on disk: %v", snapshotsOnDisk)
snapshotsInMetadata, err := d.getSnapshotsFromMetadata()
if err != nil || snapshotsInMetadata == nil {
... | [
"func",
"(",
"d",
"*",
"DeviceMapperDriver",
")",
"cleanUpSnapshots",
"(",
")",
"{",
"snapshotsOnDisk",
",",
"err",
":=",
"d",
".",
"getSnapshotsOnDisk",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"||",
"snapshotsOnDisk",
"==",
"nil",
"{",
"return",
"\n",
... | // If there any snapshots on disk that are not tied to a device in the metadata, the
// snapshot should be removed. | [
"If",
"there",
"any",
"snapshots",
"on",
"disk",
"that",
"are",
"not",
"tied",
"to",
"a",
"device",
"in",
"the",
"metadata",
"the",
"snapshot",
"should",
"be",
"removed",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/devicemapper/devicemapper.go#L90-L152 |
139,763 | control-center/serviced | volume/devicemapper/devicemapper.go | addDevice | func (d *DeviceMapperDriver) addDevice(headDeviceHash string) (string, error) {
// Generate the device ID.
deviceHash, err := utils.NewUUID62()
if err != nil {
return "", err
}
// Create the device.
if err := d.DeviceSet.AddDevice(deviceHash, headDeviceHash); err != nil {
glog.Errorf("Unable to create devic... | go | func (d *DeviceMapperDriver) addDevice(headDeviceHash string) (string, error) {
// Generate the device ID.
deviceHash, err := utils.NewUUID62()
if err != nil {
return "", err
}
// Create the device.
if err := d.DeviceSet.AddDevice(deviceHash, headDeviceHash); err != nil {
glog.Errorf("Unable to create devic... | [
"func",
"(",
"d",
"*",
"DeviceMapperDriver",
")",
"addDevice",
"(",
"headDeviceHash",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"// Generate the device ID.",
"deviceHash",
",",
"err",
":=",
"utils",
".",
"NewUUID62",
"(",
")",
"\n",
"if",
"err",
... | // addDevice creates a new dm device and returns its device ID | [
"addDevice",
"creates",
"a",
"new",
"dm",
"device",
"and",
"returns",
"its",
"device",
"ID"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/devicemapper/devicemapper.go#L278-L316 |
139,764 | control-center/serviced | volume/devicemapper/devicemapper.go | baseSize | func (d *DeviceMapperDriver) baseSize() uint64 {
for _, option := range d.options {
if strings.HasPrefix(option, "dm.basesize=") {
if size, err := units.RAMInBytes(strings.TrimPrefix(option, "dm.basesize=")); err == nil {
return uint64(size)
}
}
}
return 100 * units.GiB
} | go | func (d *DeviceMapperDriver) baseSize() uint64 {
for _, option := range d.options {
if strings.HasPrefix(option, "dm.basesize=") {
if size, err := units.RAMInBytes(strings.TrimPrefix(option, "dm.basesize=")); err == nil {
return uint64(size)
}
}
}
return 100 * units.GiB
} | [
"func",
"(",
"d",
"*",
"DeviceMapperDriver",
")",
"baseSize",
"(",
")",
"uint64",
"{",
"for",
"_",
",",
"option",
":=",
"range",
"d",
".",
"options",
"{",
"if",
"strings",
".",
"HasPrefix",
"(",
"option",
",",
"\"",
"\"",
")",
"{",
"if",
"size",
",... | // baseSize returns value of dm.basesize if it is set, otherwise returns 100G. | [
"baseSize",
"returns",
"value",
"of",
"dm",
".",
"basesize",
"if",
"it",
"is",
"set",
"otherwise",
"returns",
"100G",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/devicemapper/devicemapper.go#L319-L328 |
139,765 | control-center/serviced | volume/devicemapper/devicemapper.go | deviceSize | func (d *DeviceMapperDriver) deviceSize(deviceHash string) (uint64, error) {
return getDeviceSize(d.devicePath(deviceHash))
} | go | func (d *DeviceMapperDriver) deviceSize(deviceHash string) (uint64, error) {
return getDeviceSize(d.devicePath(deviceHash))
} | [
"func",
"(",
"d",
"*",
"DeviceMapperDriver",
")",
"deviceSize",
"(",
"deviceHash",
"string",
")",
"(",
"uint64",
",",
"error",
")",
"{",
"return",
"getDeviceSize",
"(",
"d",
".",
"devicePath",
"(",
"deviceHash",
")",
")",
"\n",
"}"
] | // deviceSize returns the size of a device. | [
"deviceSize",
"returns",
"the",
"size",
"of",
"a",
"device",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/devicemapper/devicemapper.go#L331-L333 |
139,766 | control-center/serviced | volume/devicemapper/devicemapper.go | deviceName | func (d *DeviceMapperDriver) deviceName(deviceHash string) string {
return fmt.Sprintf("%s-%s", d.DevicePrefix, deviceHash)
} | go | func (d *DeviceMapperDriver) deviceName(deviceHash string) string {
return fmt.Sprintf("%s-%s", d.DevicePrefix, deviceHash)
} | [
"func",
"(",
"d",
"*",
"DeviceMapperDriver",
")",
"deviceName",
"(",
"deviceHash",
"string",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"d",
".",
"DevicePrefix",
",",
"deviceHash",
")",
"\n",
"}"
] | // deviceName returns the name of a device. | [
"deviceName",
"returns",
"the",
"name",
"of",
"a",
"device",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/devicemapper/devicemapper.go#L341-L343 |
139,767 | control-center/serviced | volume/devicemapper/devicemapper.go | getVolume | func (d *DeviceMapperDriver) getVolume(volumeName string, create bool) (*DeviceMapperVolume, error) {
tenant := getTenant(volumeName)
metadata, err := NewMetadata(d.MetadataPath(tenant), create)
if err != nil {
return nil, err
}
vol := &DeviceMapperVolume{
name: volumeName,
path: d.volumeDir(volumeNa... | go | func (d *DeviceMapperDriver) getVolume(volumeName string, create bool) (*DeviceMapperVolume, error) {
tenant := getTenant(volumeName)
metadata, err := NewMetadata(d.MetadataPath(tenant), create)
if err != nil {
return nil, err
}
vol := &DeviceMapperVolume{
name: volumeName,
path: d.volumeDir(volumeNa... | [
"func",
"(",
"d",
"*",
"DeviceMapperDriver",
")",
"getVolume",
"(",
"volumeName",
"string",
",",
"create",
"bool",
")",
"(",
"*",
"DeviceMapperVolume",
",",
"error",
")",
"{",
"tenant",
":=",
"getTenant",
"(",
"volumeName",
")",
"\n",
"metadata",
",",
"err... | // getVolume builds the volume object from its volume name
// If create is true, we will create the metadata file if it doesn't already exist | [
"getVolume",
"builds",
"the",
"volume",
"object",
"from",
"its",
"volume",
"name",
"If",
"create",
"is",
"true",
"we",
"will",
"create",
"the",
"metadata",
"file",
"if",
"it",
"doesn",
"t",
"already",
"exist"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/devicemapper/devicemapper.go#L347-L370 |
139,768 | control-center/serviced | volume/devicemapper/devicemapper.go | Resize | func (d *DeviceMapperDriver) Resize(volumeName string, size uint64) error {
vol, err := d.getVolume(volumeName, false)
if err != nil {
return err
}
if err := d.resize(vol.deviceHash(), size); err != nil {
return err
}
newSize := volume.FilesystemBytesSize(vol.Path())
human := units.BytesSize(float64(newSize)... | go | func (d *DeviceMapperDriver) Resize(volumeName string, size uint64) error {
vol, err := d.getVolume(volumeName, false)
if err != nil {
return err
}
if err := d.resize(vol.deviceHash(), size); err != nil {
return err
}
newSize := volume.FilesystemBytesSize(vol.Path())
human := units.BytesSize(float64(newSize)... | [
"func",
"(",
"d",
"*",
"DeviceMapperDriver",
")",
"Resize",
"(",
"volumeName",
"string",
",",
"size",
"uint64",
")",
"error",
"{",
"vol",
",",
"err",
":=",
"d",
".",
"getVolume",
"(",
"volumeName",
",",
"false",
")",
"\n",
"if",
"err",
"!=",
"nil",
"... | // Resize implements volume.Driver.Resize. | [
"Resize",
"implements",
"volume",
".",
"Driver",
".",
"Resize",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/devicemapper/devicemapper.go#L381-L393 |
139,769 | control-center/serviced | volume/devicemapper/devicemapper.go | Cleanup | func (d *DeviceMapperDriver) Cleanup() error {
glog.V(2).Infof("Cleanup() START")
defer glog.V(2).Infof("Cleanup() END")
if d.DeviceSet == nil {
return nil
}
glog.V(1).Infof("Cleaning up devicemapper driver at %s", d.root)
for _, volname := range d.List() {
_, err := d.getVolume(volname, false)
if err != ni... | go | func (d *DeviceMapperDriver) Cleanup() error {
glog.V(2).Infof("Cleanup() START")
defer glog.V(2).Infof("Cleanup() END")
if d.DeviceSet == nil {
return nil
}
glog.V(1).Infof("Cleaning up devicemapper driver at %s", d.root)
for _, volname := range d.List() {
_, err := d.getVolume(volname, false)
if err != ni... | [
"func",
"(",
"d",
"*",
"DeviceMapperDriver",
")",
"Cleanup",
"(",
")",
"error",
"{",
"glog",
".",
"V",
"(",
"2",
")",
".",
"Infof",
"(",
"\"",
"\"",
")",
"\n",
"defer",
"glog",
".",
"V",
"(",
"2",
")",
".",
"Infof",
"(",
"\"",
"\"",
")",
"\n"... | // Cleanup implements volume.Driver.Cleanup | [
"Cleanup",
"implements",
"volume",
".",
"Driver",
".",
"Cleanup"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/devicemapper/devicemapper.go#L513-L531 |
139,770 | control-center/serviced | volume/devicemapper/devicemapper.go | unmountDevice | func (d *DeviceMapperDriver) unmountDevice(deviceHash, mountpoint string) {
// We use the provided UnmountDevice func here, rather than our own
// unmount(), because we DO care about Docker's internal bookkeeping
// here. Without this, DeviceSet.DeleteDevice will fail.
if err := d.DeviceSet.UnmountDevice(deviceHas... | go | func (d *DeviceMapperDriver) unmountDevice(deviceHash, mountpoint string) {
// We use the provided UnmountDevice func here, rather than our own
// unmount(), because we DO care about Docker's internal bookkeeping
// here. Without this, DeviceSet.DeleteDevice will fail.
if err := d.DeviceSet.UnmountDevice(deviceHas... | [
"func",
"(",
"d",
"*",
"DeviceMapperDriver",
")",
"unmountDevice",
"(",
"deviceHash",
",",
"mountpoint",
"string",
")",
"{",
"// We use the provided UnmountDevice func here, rather than our own",
"// unmount(), because we DO care about Docker's internal bookkeeping",
"// here. Withou... | // unmountDevice unmounts the device | [
"unmountDevice",
"unmounts",
"the",
"device"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/devicemapper/devicemapper.go#L653-L666 |
139,771 | control-center/serviced | volume/devicemapper/devicemapper.go | readDeviceInfo | func (d *DeviceMapperDriver) readDeviceInfo(deviceHash string, devInfo *devInfo) error {
fh, err := os.Open(d.deviceInfoPath(deviceHash))
if err != nil {
glog.Errorf("Could not read device info for %s: %s", deviceHash, err)
return err
}
defer fh.Close()
if err := json.NewDecoder(fh).Decode(devInfo); err != nil... | go | func (d *DeviceMapperDriver) readDeviceInfo(deviceHash string, devInfo *devInfo) error {
fh, err := os.Open(d.deviceInfoPath(deviceHash))
if err != nil {
glog.Errorf("Could not read device info for %s: %s", deviceHash, err)
return err
}
defer fh.Close()
if err := json.NewDecoder(fh).Decode(devInfo); err != nil... | [
"func",
"(",
"d",
"*",
"DeviceMapperDriver",
")",
"readDeviceInfo",
"(",
"deviceHash",
"string",
",",
"devInfo",
"*",
"devInfo",
")",
"error",
"{",
"fh",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"d",
".",
"deviceInfoPath",
"(",
"deviceHash",
")",
")",
... | // readDeviceInfo loads the device info from metadata | [
"readDeviceInfo",
"loads",
"the",
"device",
"info",
"from",
"metadata"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/devicemapper/devicemapper.go#L669-L681 |
139,772 | control-center/serviced | volume/devicemapper/devicemapper.go | invalidateDeviceInfo | func (d *DeviceMapperDriver) invalidateDeviceInfo(deviceHash string) {
d.DeviceSet.Lock()
defer d.DeviceSet.Unlock()
delete(d.DeviceSet.Devices, deviceHash)
} | go | func (d *DeviceMapperDriver) invalidateDeviceInfo(deviceHash string) {
d.DeviceSet.Lock()
defer d.DeviceSet.Unlock()
delete(d.DeviceSet.Devices, deviceHash)
} | [
"func",
"(",
"d",
"*",
"DeviceMapperDriver",
")",
"invalidateDeviceInfo",
"(",
"deviceHash",
"string",
")",
"{",
"d",
".",
"DeviceSet",
".",
"Lock",
"(",
")",
"\n",
"defer",
"d",
".",
"DeviceSet",
".",
"Unlock",
"(",
")",
"\n",
"delete",
"(",
"d",
".",... | // invalidateDeviceInfo clears the device | [
"invalidateDeviceInfo",
"clears",
"the",
"device"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/devicemapper/devicemapper.go#L684-L688 |
139,773 | control-center/serviced | volume/devicemapper/devicemapper.go | writeDeviceInfo | func (d *DeviceMapperDriver) writeDeviceInfo(deviceHash string, devInfo devInfo) error {
devInfoPath := d.deviceInfoPath(deviceHash)
fs, err := os.Stat(devInfoPath)
if err != nil {
glog.Errorf("Could not stat file %s: %s", devInfoPath, err)
return err
}
data, err := json.Marshal(devInfo)
if err != nil {
glo... | go | func (d *DeviceMapperDriver) writeDeviceInfo(deviceHash string, devInfo devInfo) error {
devInfoPath := d.deviceInfoPath(deviceHash)
fs, err := os.Stat(devInfoPath)
if err != nil {
glog.Errorf("Could not stat file %s: %s", devInfoPath, err)
return err
}
data, err := json.Marshal(devInfo)
if err != nil {
glo... | [
"func",
"(",
"d",
"*",
"DeviceMapperDriver",
")",
"writeDeviceInfo",
"(",
"deviceHash",
"string",
",",
"devInfo",
"devInfo",
")",
"error",
"{",
"devInfoPath",
":=",
"d",
".",
"deviceInfoPath",
"(",
"deviceHash",
")",
"\n",
"fs",
",",
"err",
":=",
"os",
"."... | // writeDeviceInfo performs an atomic write to the device metadata file | [
"writeDeviceInfo",
"performs",
"an",
"atomic",
"write",
"to",
"the",
"device",
"metadata",
"file"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/devicemapper/devicemapper.go#L691-L710 |
139,774 | control-center/serviced | volume/devicemapper/devicemapper.go | resizeDevice | func (d *DeviceMapperDriver) resizeDevice(deviceHash string, size uint64) error {
var devInfo devInfo
if err := d.readDeviceInfo(deviceHash, &devInfo); err != nil {
glog.Errorf("Could not read info for device %s: %s", deviceHash, err)
return err
}
devInfo.Size = size
if err := d.writeDeviceInfo(deviceHash, dev... | go | func (d *DeviceMapperDriver) resizeDevice(deviceHash string, size uint64) error {
var devInfo devInfo
if err := d.readDeviceInfo(deviceHash, &devInfo); err != nil {
glog.Errorf("Could not read info for device %s: %s", deviceHash, err)
return err
}
devInfo.Size = size
if err := d.writeDeviceInfo(deviceHash, dev... | [
"func",
"(",
"d",
"*",
"DeviceMapperDriver",
")",
"resizeDevice",
"(",
"deviceHash",
"string",
",",
"size",
"uint64",
")",
"error",
"{",
"var",
"devInfo",
"devInfo",
"\n",
"if",
"err",
":=",
"d",
".",
"readDeviceInfo",
"(",
"deviceHash",
",",
"&",
"devInfo... | // resizeDevice sets the device size in its metadata property | [
"resizeDevice",
"sets",
"the",
"device",
"size",
"in",
"its",
"metadata",
"property"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/devicemapper/devicemapper.go#L713-L725 |
139,775 | control-center/serviced | volume/devicemapper/devicemapper.go | MetadataPath | func (d *DeviceMapperDriver) MetadataPath(tenant string) string {
return filepath.Join(d.MetadataDir(), tenant, "metadata.json")
} | go | func (d *DeviceMapperDriver) MetadataPath(tenant string) string {
return filepath.Join(d.MetadataDir(), tenant, "metadata.json")
} | [
"func",
"(",
"d",
"*",
"DeviceMapperDriver",
")",
"MetadataPath",
"(",
"tenant",
"string",
")",
"string",
"{",
"return",
"filepath",
".",
"Join",
"(",
"d",
".",
"MetadataDir",
"(",
")",
",",
"tenant",
",",
"\"",
"\"",
")",
"\n",
"}"
] | // metadataPath returns the path of the json metadata file | [
"metadataPath",
"returns",
"the",
"path",
"of",
"the",
"json",
"metadata",
"file"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/devicemapper/devicemapper.go#L746-L748 |
139,776 | control-center/serviced | volume/devicemapper/devicemapper.go | verifyThinpoolDeviceUUID | func (d *DeviceMapperDriver) verifyThinpoolDeviceUUID(thinPoolDev string) error {
thinpoolDevPath := d.ThinpoolDevPath()
if _, err := os.Stat(thinpoolDevPath); err != nil {
// If the file doesn't exist or we can't stat it, continue.
return nil
}
bytes, err := ioutil.ReadFile(thinpoolDevPath)
if err != nil {
... | go | func (d *DeviceMapperDriver) verifyThinpoolDeviceUUID(thinPoolDev string) error {
thinpoolDevPath := d.ThinpoolDevPath()
if _, err := os.Stat(thinpoolDevPath); err != nil {
// If the file doesn't exist or we can't stat it, continue.
return nil
}
bytes, err := ioutil.ReadFile(thinpoolDevPath)
if err != nil {
... | [
"func",
"(",
"d",
"*",
"DeviceMapperDriver",
")",
"verifyThinpoolDeviceUUID",
"(",
"thinPoolDev",
"string",
")",
"error",
"{",
"thinpoolDevPath",
":=",
"d",
".",
"ThinpoolDevPath",
"(",
")",
"\n\n",
"if",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"thi... | // Verifies that the thinPoolDev passed in matches what we've saved during the
// previous successful initialization. | [
"Verifies",
"that",
"the",
"thinPoolDev",
"passed",
"in",
"matches",
"what",
"we",
"ve",
"saved",
"during",
"the",
"previous",
"successful",
"initialization",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/devicemapper/devicemapper.go#L757-L784 |
139,777 | control-center/serviced | volume/devicemapper/devicemapper.go | saveThinpoolDeviceUUID | func (d *DeviceMapperDriver) saveThinpoolDeviceUUID(thinPoolDev string) error {
// Nothing to do if no thinpooldev location is provided.
if len(thinPoolDev) == 0 {
return nil
}
thinpoolDevPath := d.ThinpoolDevPath()
lvuuid, err := getlvmuuid(thinPoolDev)
if err != nil {
return err
}
fd, err := os.Create(... | go | func (d *DeviceMapperDriver) saveThinpoolDeviceUUID(thinPoolDev string) error {
// Nothing to do if no thinpooldev location is provided.
if len(thinPoolDev) == 0 {
return nil
}
thinpoolDevPath := d.ThinpoolDevPath()
lvuuid, err := getlvmuuid(thinPoolDev)
if err != nil {
return err
}
fd, err := os.Create(... | [
"func",
"(",
"d",
"*",
"DeviceMapperDriver",
")",
"saveThinpoolDeviceUUID",
"(",
"thinPoolDev",
"string",
")",
"error",
"{",
"// Nothing to do if no thinpooldev location is provided.",
"if",
"len",
"(",
"thinPoolDev",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",... | // Saves the thinPoolDev to a file so we can verify it later. | [
"Saves",
"the",
"thinPoolDev",
"to",
"a",
"file",
"so",
"we",
"can",
"verify",
"it",
"later",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/devicemapper/devicemapper.go#L787-L807 |
139,778 | control-center/serviced | volume/devicemapper/devicemapper.go | WriteMetadata | func (v *DeviceMapperVolume) WriteMetadata(label, name string) (io.WriteCloser, error) {
filePath := filepath.Join(v.driver.MetadataDir(), v.rawSnapshotLabel(label), name)
if err := os.MkdirAll(filepath.Dir(filePath), 0755); err != nil && !os.IsExist(err) {
glog.Errorf("Could not create path for file %s: %s", name,... | go | func (v *DeviceMapperVolume) WriteMetadata(label, name string) (io.WriteCloser, error) {
filePath := filepath.Join(v.driver.MetadataDir(), v.rawSnapshotLabel(label), name)
if err := os.MkdirAll(filepath.Dir(filePath), 0755); err != nil && !os.IsExist(err) {
glog.Errorf("Could not create path for file %s: %s", name,... | [
"func",
"(",
"v",
"*",
"DeviceMapperVolume",
")",
"WriteMetadata",
"(",
"label",
",",
"name",
"string",
")",
"(",
"io",
".",
"WriteCloser",
",",
"error",
")",
"{",
"filePath",
":=",
"filepath",
".",
"Join",
"(",
"v",
".",
"driver",
".",
"MetadataDir",
... | // WriteMetadata writes the metadata info for a snapshot | [
"WriteMetadata",
"writes",
"the",
"metadata",
"info",
"for",
"a",
"snapshot"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/devicemapper/devicemapper.go#L937-L944 |
139,779 | control-center/serviced | volume/devicemapper/devicemapper.go | unmount | func (v *DeviceMapperVolume) unmount() error {
glog.V(2).Infof("unmount() (%s) START", v.name)
defer glog.V(2).Infof("unmount() (%s) END", v.name)
v.driver.DeviceSet.Lock()
defer v.driver.DeviceSet.Unlock()
mountPath := v.Path()
glog.V(2).Infof("Unmounting from path %s START", mountPath)
if err := unmount(mount... | go | func (v *DeviceMapperVolume) unmount() error {
glog.V(2).Infof("unmount() (%s) START", v.name)
defer glog.V(2).Infof("unmount() (%s) END", v.name)
v.driver.DeviceSet.Lock()
defer v.driver.DeviceSet.Unlock()
mountPath := v.Path()
glog.V(2).Infof("Unmounting from path %s START", mountPath)
if err := unmount(mount... | [
"func",
"(",
"v",
"*",
"DeviceMapperVolume",
")",
"unmount",
"(",
")",
"error",
"{",
"glog",
".",
"V",
"(",
"2",
")",
".",
"Infof",
"(",
"\"",
"\"",
",",
"v",
".",
"name",
")",
"\n",
"defer",
"glog",
".",
"V",
"(",
"2",
")",
".",
"Infof",
"("... | // unmount unmounts the current device from the volume mount point. Docker's
// code has a function for this, but it depends on some internal state that we
// both can't count on and don't care about. | [
"unmount",
"unmounts",
"the",
"current",
"device",
"from",
"the",
"volume",
"mount",
"point",
".",
"Docker",
"s",
"code",
"has",
"a",
"function",
"for",
"this",
"but",
"it",
"depends",
"on",
"some",
"internal",
"state",
"that",
"we",
"both",
"can",
"t",
... | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/devicemapper/devicemapper.go#L955-L973 |
139,780 | control-center/serviced | volume/devicemapper/devicemapper.go | isInvalidSnapshot | func (v *DeviceMapperVolume) isInvalidSnapshot(rawLabel string) bool {
reader, err := v.ReadMetadata(rawLabel, ".SNAPSHOTINFO")
if err != nil {
return true
}
reader.Close()
return false
} | go | func (v *DeviceMapperVolume) isInvalidSnapshot(rawLabel string) bool {
reader, err := v.ReadMetadata(rawLabel, ".SNAPSHOTINFO")
if err != nil {
return true
}
reader.Close()
return false
} | [
"func",
"(",
"v",
"*",
"DeviceMapperVolume",
")",
"isInvalidSnapshot",
"(",
"rawLabel",
"string",
")",
"bool",
"{",
"reader",
",",
"err",
":=",
"v",
".",
"ReadMetadata",
"(",
"rawLabel",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"retur... | // isInvalidSnapshot checks to see if the snapshot is missing a .SNAPSHOTINFO file | [
"isInvalidSnapshot",
"checks",
"to",
"see",
"if",
"the",
"snapshot",
"is",
"missing",
"a",
".",
"SNAPSHOTINFO",
"file"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/devicemapper/devicemapper.go#L1158-L1165 |
139,781 | control-center/serviced | volume/devicemapper/devicemapper.go | GetTenantStorageStats | func (d *DeviceMapperDriver) GetTenantStorageStats() ([]volume.TenantStorageStats, error) {
var result []volume.TenantStorageStats
status := d.DeviceSet.Status()
// If this is loop-lvm, the metadata device will be in status.MetadataFile
mdDevice := status.MetadataFile
if mdDevice == "" {
// It's direct-lvm, so b... | go | func (d *DeviceMapperDriver) GetTenantStorageStats() ([]volume.TenantStorageStats, error) {
var result []volume.TenantStorageStats
status := d.DeviceSet.Status()
// If this is loop-lvm, the metadata device will be in status.MetadataFile
mdDevice := status.MetadataFile
if mdDevice == "" {
// It's direct-lvm, so b... | [
"func",
"(",
"d",
"*",
"DeviceMapperDriver",
")",
"GetTenantStorageStats",
"(",
")",
"(",
"[",
"]",
"volume",
".",
"TenantStorageStats",
",",
"error",
")",
"{",
"var",
"result",
"[",
"]",
"volume",
".",
"TenantStorageStats",
"\n",
"status",
":=",
"d",
".",... | // GetTenantStorageStats returns storage stats for each tenant in the system. | [
"GetTenantStorageStats",
"returns",
"storage",
"stats",
"for",
"each",
"tenant",
"in",
"the",
"system",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/devicemapper/devicemapper.go#L1476-L1560 |
139,782 | control-center/serviced | volume/devicemapper/devicemapper.go | getlvmuuid | func getlvmuuid(thinpooldev string) (string, error) {
output, err := exec.Command("lvdisplay", "-C", "--noheadings", "--options", "lv_uuid", thinpooldev).Output()
if err != nil {
err = fmt.Errorf("Could not get the lv_uuid for %s: %s (%s)", thinpooldev, string(output), err)
glog.Error(err)
return "", err
}
re... | go | func getlvmuuid(thinpooldev string) (string, error) {
output, err := exec.Command("lvdisplay", "-C", "--noheadings", "--options", "lv_uuid", thinpooldev).Output()
if err != nil {
err = fmt.Errorf("Could not get the lv_uuid for %s: %s (%s)", thinpooldev, string(output), err)
glog.Error(err)
return "", err
}
re... | [
"func",
"getlvmuuid",
"(",
"thinpooldev",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"output",
",",
"err",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"thinpoo... | // Returns the LV_UUID for a thinpool. | [
"Returns",
"the",
"LV_UUID",
"for",
"a",
"thinpool",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/devicemapper/devicemapper.go#L1765-L1773 |
139,783 | control-center/serviced | scheduler/scheduler.go | NewScheduler | func NewScheduler(poolID string, instance_id string, storageServer *storage.Server, cpDao dao.ControlPlane, facade *facade.Facade, pushreg *imgreg.RegistryListener, snapshotTTL int) (*scheduler, error) {
s := &scheduler{
cpDao: cpDao,
poolID: poolID,
instance_id: instance_id,
shutdown: ma... | go | func NewScheduler(poolID string, instance_id string, storageServer *storage.Server, cpDao dao.ControlPlane, facade *facade.Facade, pushreg *imgreg.RegistryListener, snapshotTTL int) (*scheduler, error) {
s := &scheduler{
cpDao: cpDao,
poolID: poolID,
instance_id: instance_id,
shutdown: ma... | [
"func",
"NewScheduler",
"(",
"poolID",
"string",
",",
"instance_id",
"string",
",",
"storageServer",
"*",
"storage",
".",
"Server",
",",
"cpDao",
"dao",
".",
"ControlPlane",
",",
"facade",
"*",
"facade",
".",
"Facade",
",",
"pushreg",
"*",
"imgreg",
".",
"... | // NewScheduler creates a new scheduler master | [
"NewScheduler",
"creates",
"a",
"new",
"scheduler",
"master"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/scheduler/scheduler.go#L62-L76 |
139,784 | control-center/serviced | scheduler/scheduler.go | Stop | func (s *scheduler) Stop() {
s.Lock()
defer s.Unlock()
if !s.started {
return
}
close(s.shutdown)
<-s.stopped
} | go | func (s *scheduler) Stop() {
s.Lock()
defer s.Unlock()
if !s.started {
return
}
close(s.shutdown)
<-s.stopped
} | [
"func",
"(",
"s",
"*",
"scheduler",
")",
"Stop",
"(",
")",
"{",
"s",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"!",
"s",
".",
"started",
"{",
"return",
"\n",
"}",
"\n",
"close",
"(",
"s",
".",
"shutdown... | // Stop stops all scheduler processes for the master | [
"Stop",
"stops",
"all",
"scheduler",
"processes",
"for",
"the",
"master"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/scheduler/scheduler.go#L220-L229 |
139,785 | control-center/serviced | scheduler/scheduler.go | Ready | func (s *scheduler) Ready() error {
glog.Infof("Entering lead for realm %s!", s.realm)
glog.Infof("Host Master successfully started")
return nil
} | go | func (s *scheduler) Ready() error {
glog.Infof("Entering lead for realm %s!", s.realm)
glog.Infof("Host Master successfully started")
return nil
} | [
"func",
"(",
"s",
"*",
"scheduler",
")",
"Ready",
"(",
")",
"error",
"{",
"glog",
".",
"Infof",
"(",
"\"",
"\"",
",",
"s",
".",
"realm",
")",
"\n",
"glog",
".",
"Infof",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // Ready implements zzk.Listener | [
"Ready",
"implements",
"zzk",
".",
"Listener"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/scheduler/scheduler.go#L243-L247 |
139,786 | control-center/serviced | scheduler/scheduler.go | Spawn | func (s *scheduler) Spawn(shutdown <-chan interface{}, poolID string) {
s.zkleaderFunc(shutdown, s.conn, s.cpDao, s.facade, poolID)
} | go | func (s *scheduler) Spawn(shutdown <-chan interface{}, poolID string) {
s.zkleaderFunc(shutdown, s.conn, s.cpDao, s.facade, poolID)
} | [
"func",
"(",
"s",
"*",
"scheduler",
")",
"Spawn",
"(",
"shutdown",
"<-",
"chan",
"interface",
"{",
"}",
",",
"poolID",
"string",
")",
"{",
"s",
".",
"zkleaderFunc",
"(",
"shutdown",
",",
"s",
".",
"conn",
",",
"s",
".",
"cpDao",
",",
"s",
".",
"f... | // Spawn implements zzk.Listener | [
"Spawn",
"implements",
"zzk",
".",
"Listener"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/scheduler/scheduler.go#L257-L259 |
139,787 | control-center/serviced | dfs/delete.go | Delete | func (dfs *DistributedFilesystem) Delete(snapshotID string) error {
vol, err := dfs.disk.GetTenant(snapshotID)
if err != nil {
return err
}
if info, err := vol.SnapshotInfo(snapshotID); err != volume.ErrInvalidSnapshot {
if err != nil {
return err
} else if err := dfs.deleteImages(info.TenantID, info.Labe... | go | func (dfs *DistributedFilesystem) Delete(snapshotID string) error {
vol, err := dfs.disk.GetTenant(snapshotID)
if err != nil {
return err
}
if info, err := vol.SnapshotInfo(snapshotID); err != volume.ErrInvalidSnapshot {
if err != nil {
return err
} else if err := dfs.deleteImages(info.TenantID, info.Labe... | [
"func",
"(",
"dfs",
"*",
"DistributedFilesystem",
")",
"Delete",
"(",
"snapshotID",
"string",
")",
"error",
"{",
"vol",
",",
"err",
":=",
"dfs",
".",
"disk",
".",
"GetTenant",
"(",
"snapshotID",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err"... | // Delete removes application data of a particular snapshot from the dfs and
// registry. | [
"Delete",
"removes",
"application",
"data",
"of",
"a",
"particular",
"snapshot",
"from",
"the",
"dfs",
"and",
"registry",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dfs/delete.go#L22-L42 |
139,788 | control-center/serviced | zzk/listen.go | Manage | func Manage(shutdown <-chan interface{}, root string, l Listener2) {
defer l.Exited()
logger := plog.WithField("zkroot", root)
for {
select {
case conn := <-connect(root):
if conn != nil {
logger.Info("Acquired a client connection to zookeeper")
l.Listen(shutdown, conn)
}
case <-shutdown:
}
... | go | func Manage(shutdown <-chan interface{}, root string, l Listener2) {
defer l.Exited()
logger := plog.WithField("zkroot", root)
for {
select {
case conn := <-connect(root):
if conn != nil {
logger.Info("Acquired a client connection to zookeeper")
l.Listen(shutdown, conn)
}
case <-shutdown:
}
... | [
"func",
"Manage",
"(",
"shutdown",
"<-",
"chan",
"interface",
"{",
"}",
",",
"root",
"string",
",",
"l",
"Listener2",
")",
"{",
"defer",
"l",
".",
"Exited",
"(",
")",
"\n",
"logger",
":=",
"plog",
".",
"WithField",
"(",
"\"",
"\"",
",",
"root",
")"... | // Manage continuously restarts the listener until it shuts down | [
"Manage",
"continuously",
"restarts",
"the",
"listener",
"until",
"it",
"shuts",
"down"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/zzk/listen.go#L29-L50 |
139,789 | control-center/serviced | zzk/listen.go | Listen2 | func Listen2(shutdown <-chan interface{}, conn client.Connection, s Spawner) {
var (
cancel = make(chan struct{})
exited = make(chan string)
active = make(map[string]struct{})
)
logger := plog.WithField("zkpath", s.Path())
// set the connection
s.SetConn(conn)
// make sure all running spawns exit on shut... | go | func Listen2(shutdown <-chan interface{}, conn client.Connection, s Spawner) {
var (
cancel = make(chan struct{})
exited = make(chan string)
active = make(map[string]struct{})
)
logger := plog.WithField("zkpath", s.Path())
// set the connection
s.SetConn(conn)
// make sure all running spawns exit on shut... | [
"func",
"Listen2",
"(",
"shutdown",
"<-",
"chan",
"interface",
"{",
"}",
",",
"conn",
"client",
".",
"Connection",
",",
"s",
"Spawner",
")",
"{",
"var",
"(",
"cancel",
"=",
"make",
"(",
"chan",
"struct",
"{",
"}",
")",
"\n",
"exited",
"=",
"make",
... | // Listen2 manages spawning threads to handle nodes created under the parent
// path. | [
"Listen2",
"manages",
"spawning",
"threads",
"to",
"handle",
"nodes",
"created",
"under",
"the",
"parent",
"path",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/zzk/listen.go#L76-L155 |
139,790 | control-center/serviced | datastore/elastic/connection.go | toJSONMessages | func toJSONMessages(result *core.SearchResult) []datastore.JSONMessage {
var total = len(result.Hits.Hits)
var msgs = make([]datastore.JSONMessage, total)
logger := plog.WithField("total", total)
if total > 0 {
// Note that while it's possible for queries to span types, the vast majority of CC use cases (all?)
... | go | func toJSONMessages(result *core.SearchResult) []datastore.JSONMessage {
var total = len(result.Hits.Hits)
var msgs = make([]datastore.JSONMessage, total)
logger := plog.WithField("total", total)
if total > 0 {
// Note that while it's possible for queries to span types, the vast majority of CC use cases (all?)
... | [
"func",
"toJSONMessages",
"(",
"result",
"*",
"core",
".",
"SearchResult",
")",
"[",
"]",
"datastore",
".",
"JSONMessage",
"{",
"var",
"total",
"=",
"len",
"(",
"result",
".",
"Hits",
".",
"Hits",
")",
"\n",
"var",
"msgs",
"=",
"make",
"(",
"[",
"]",... | // convert search result of json host to dao.Host array | [
"convert",
"search",
"result",
"of",
"json",
"host",
"to",
"dao",
".",
"Host",
"array"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/datastore/elastic/connection.go#L144-L170 |
139,791 | control-center/serviced | datastore/elastic/connection.go | elasticGet | func elasticGet(pretty bool, index string, _type string, id string) (elasticResponse, error) {
var url string
var retval elasticResponse
if len(_type) > 0 {
url = fmt.Sprintf("/%s/%s/%s?%s", index, _type, id, api.Pretty(pretty))
} else {
url = fmt.Sprintf("/%s/%s?%s", index, id, api.Pretty(pretty))
}
body, er... | go | func elasticGet(pretty bool, index string, _type string, id string) (elasticResponse, error) {
var url string
var retval elasticResponse
if len(_type) > 0 {
url = fmt.Sprintf("/%s/%s/%s?%s", index, _type, id, api.Pretty(pretty))
} else {
url = fmt.Sprintf("/%s/%s?%s", index, id, api.Pretty(pretty))
}
body, er... | [
"func",
"elasticGet",
"(",
"pretty",
"bool",
",",
"index",
"string",
",",
"_type",
"string",
",",
"id",
"string",
")",
"(",
"elasticResponse",
",",
"error",
")",
"{",
"var",
"url",
"string",
"\n",
"var",
"retval",
"elasticResponse",
"\n",
"if",
"len",
"(... | //Modified from elastigo to use custom response type | [
"Modified",
"from",
"elastigo",
"to",
"use",
"custom",
"response",
"type"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/datastore/elastic/connection.go#L173-L193 |
139,792 | control-center/serviced | utils/strings.go | StringSliceEquals | func StringSliceEquals(lhs []string, rhs []string) bool {
if lhs == nil && rhs == nil {
return true
}
if lhs == nil && rhs != nil {
return false
}
if lhs != nil && rhs == nil {
return false
}
if len(lhs) != len(rhs) {
return false
}
for i := range lhs {
if lhs[i] != rhs[i] {
return false
}
... | go | func StringSliceEquals(lhs []string, rhs []string) bool {
if lhs == nil && rhs == nil {
return true
}
if lhs == nil && rhs != nil {
return false
}
if lhs != nil && rhs == nil {
return false
}
if len(lhs) != len(rhs) {
return false
}
for i := range lhs {
if lhs[i] != rhs[i] {
return false
}
... | [
"func",
"StringSliceEquals",
"(",
"lhs",
"[",
"]",
"string",
",",
"rhs",
"[",
"]",
"string",
")",
"bool",
"{",
"if",
"lhs",
"==",
"nil",
"&&",
"rhs",
"==",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"if",
"lhs",
"==",
"nil",
"&&",
"rhs",
"!... | // StringSliceEquals compare two string slices for equality | [
"StringSliceEquals",
"compare",
"two",
"string",
"slices",
"for",
"equality"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/utils/strings.go#L22-L46 |
139,793 | control-center/serviced | utils/strings.go | CompareVersions | func CompareVersions(v1, v2 string) int {
maxlen := 1
s1 := strings.Split(v1, ".")
s2 := strings.Split(v2, ".")
for _, s := range append(s1, s2...) {
if len(s) > maxlen {
maxlen = len(s)
}
}
if len(s1) > len(s2) {
t := make([]string, len(s1))
copy(t, s2)
s2 = t
}
if len(s2) > len(s1) {
t := make(... | go | func CompareVersions(v1, v2 string) int {
maxlen := 1
s1 := strings.Split(v1, ".")
s2 := strings.Split(v2, ".")
for _, s := range append(s1, s2...) {
if len(s) > maxlen {
maxlen = len(s)
}
}
if len(s1) > len(s2) {
t := make([]string, len(s1))
copy(t, s2)
s2 = t
}
if len(s2) > len(s1) {
t := make(... | [
"func",
"CompareVersions",
"(",
"v1",
",",
"v2",
"string",
")",
"int",
"{",
"maxlen",
":=",
"1",
"\n",
"s1",
":=",
"strings",
".",
"Split",
"(",
"v1",
",",
"\"",
"\"",
")",
"\n",
"s2",
":=",
"strings",
".",
"Split",
"(",
"v2",
",",
"\"",
"\"",
... | // Compare two version strings by splitting by '.', making the slices the same length, then
// padding the strings with 0's. The string comparison will now work against numeric
// versioning, as well as "1.5.2b1" style strings. | [
"Compare",
"two",
"version",
"strings",
"by",
"splitting",
"by",
".",
"making",
"the",
"slices",
"the",
"same",
"length",
"then",
"padding",
"the",
"strings",
"with",
"0",
"s",
".",
"The",
"string",
"comparison",
"will",
"now",
"work",
"against",
"numeric",
... | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/utils/strings.go#L75-L102 |
139,794 | control-center/serviced | dfs/tag.go | Tag | func (dfs *DistributedFilesystem) Tag(snapshotID string, tagName string) error {
// Get the parent volume that owns the snapshot
vol, err := dfs.disk.GetTenant(snapshotID)
if err != nil {
glog.Errorf("Could not get tenant of snapshot %s: %s", snapshotID, err)
return err
}
// Add a tag to the snapshot
if err :... | go | func (dfs *DistributedFilesystem) Tag(snapshotID string, tagName string) error {
// Get the parent volume that owns the snapshot
vol, err := dfs.disk.GetTenant(snapshotID)
if err != nil {
glog.Errorf("Could not get tenant of snapshot %s: %s", snapshotID, err)
return err
}
// Add a tag to the snapshot
if err :... | [
"func",
"(",
"dfs",
"*",
"DistributedFilesystem",
")",
"Tag",
"(",
"snapshotID",
"string",
",",
"tagName",
"string",
")",
"error",
"{",
"// Get the parent volume that owns the snapshot",
"vol",
",",
"err",
":=",
"dfs",
".",
"disk",
".",
"GetTenant",
"(",
"snapsh... | // Tag adds tags to an existing snapshot | [
"Tag",
"adds",
"tags",
"to",
"an",
"existing",
"snapshot"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dfs/tag.go#L19-L32 |
139,795 | control-center/serviced | volume/status.go | UnmarshalJSON | func (u *UsageData) UnmarshalJSON(data []byte) error {
var usageData UsageData
var usageRaw []json.RawMessage
// we should have a slice of usage entries in json
err := json.Unmarshal(data, &usageRaw)
if err != nil {
return err
}
for _, usage := range usageRaw {
// unmarshal into a map, so we can check our fi... | go | func (u *UsageData) UnmarshalJSON(data []byte) error {
var usageData UsageData
var usageRaw []json.RawMessage
// we should have a slice of usage entries in json
err := json.Unmarshal(data, &usageRaw)
if err != nil {
return err
}
for _, usage := range usageRaw {
// unmarshal into a map, so we can check our fi... | [
"func",
"(",
"u",
"*",
"UsageData",
")",
"UnmarshalJSON",
"(",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"var",
"usageData",
"UsageData",
"\n",
"var",
"usageRaw",
"[",
"]",
"json",
".",
"RawMessage",
"\n",
"// we should have a slice of usage entries in json",... | // UnmarshalJSON satisfies Unmarshaler interface | [
"UnmarshalJSON",
"satisfies",
"Unmarshaler",
"interface"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/status.go#L43-L115 |
139,796 | control-center/serviced | volume/status.go | GetStatus | func GetStatus() *Statuses {
result := &Statuses{}
result.DeviceMapperStatusMap = make(map[string]*DeviceMapperStatus)
result.SimpleStatusMap = make(map[string]*SimpleStatus)
driverMap := getDrivers()
for path, driver := range *driverMap {
status, err := driver.Status()
if err != nil {
glog.Warningf("Error ... | go | func GetStatus() *Statuses {
result := &Statuses{}
result.DeviceMapperStatusMap = make(map[string]*DeviceMapperStatus)
result.SimpleStatusMap = make(map[string]*SimpleStatus)
driverMap := getDrivers()
for path, driver := range *driverMap {
status, err := driver.Status()
if err != nil {
glog.Warningf("Error ... | [
"func",
"GetStatus",
"(",
")",
"*",
"Statuses",
"{",
"result",
":=",
"&",
"Statuses",
"{",
"}",
"\n",
"result",
".",
"DeviceMapperStatusMap",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"DeviceMapperStatus",
")",
"\n",
"result",
".",
"SimpleStatusMap... | // GetStatus retrieves the status for the volumeNames passed in. If volumeNames is empty, it gets all statuses. | [
"GetStatus",
"retrieves",
"the",
"status",
"for",
"the",
"volumeNames",
"passed",
"in",
".",
"If",
"volumeNames",
"is",
"empty",
"it",
"gets",
"all",
"statuses",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/status.go#L199-L220 |
139,797 | control-center/serviced | volume/btrfs/btrfs.go | Init | func Init(root string, _ []string) (volume.Driver, error) {
if !volume.IsBtrfsFilesystem(root) {
return nil, ErrBtrfsInvalidFilesystem
}
// get the driver object id
objectID := "5" // root driver is always 5 unless it is a subvolume
raw, err := volume.RunBtrFSCmd(volume.IsSudoer(), "subvolume", "show", root)
if... | go | func Init(root string, _ []string) (volume.Driver, error) {
if !volume.IsBtrfsFilesystem(root) {
return nil, ErrBtrfsInvalidFilesystem
}
// get the driver object id
objectID := "5" // root driver is always 5 unless it is a subvolume
raw, err := volume.RunBtrFSCmd(volume.IsSudoer(), "subvolume", "show", root)
if... | [
"func",
"Init",
"(",
"root",
"string",
",",
"_",
"[",
"]",
"string",
")",
"(",
"volume",
".",
"Driver",
",",
"error",
")",
"{",
"if",
"!",
"volume",
".",
"IsBtrfsFilesystem",
"(",
"root",
")",
"{",
"return",
"nil",
",",
"ErrBtrfsInvalidFilesystem",
"\n... | // Btrfs driver initialization | [
"Btrfs",
"driver",
"initialization"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/btrfs/btrfs.go#L76-L104 |
139,798 | control-center/serviced | volume/btrfs/btrfs.go | WriteMetadata | func (v *BtrfsVolume) WriteMetadata(label, name string) (io.WriteCloser, error) {
filePath := filepath.Join(v.Path(), name)
if err := os.MkdirAll(filepath.Dir(filePath), 0755); err != nil && !os.IsExist(err) {
glog.Errorf("Could not create path for file %s: %s", name, err)
return nil, err
}
return os.Create(fi... | go | func (v *BtrfsVolume) WriteMetadata(label, name string) (io.WriteCloser, error) {
filePath := filepath.Join(v.Path(), name)
if err := os.MkdirAll(filepath.Dir(filePath), 0755); err != nil && !os.IsExist(err) {
glog.Errorf("Could not create path for file %s: %s", name, err)
return nil, err
}
return os.Create(fi... | [
"func",
"(",
"v",
"*",
"BtrfsVolume",
")",
"WriteMetadata",
"(",
"label",
",",
"name",
"string",
")",
"(",
"io",
".",
"WriteCloser",
",",
"error",
")",
"{",
"filePath",
":=",
"filepath",
".",
"Join",
"(",
"v",
".",
"Path",
"(",
")",
",",
"name",
")... | // WriteMetadata writes the metadata info for a snapshot by writing to the base
// volume. | [
"WriteMetadata",
"writes",
"the",
"metadata",
"info",
"for",
"a",
"snapshot",
"by",
"writing",
"to",
"the",
"base",
"volume",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/btrfs/btrfs.go#L291-L299 |
139,799 | control-center/serviced | volume/btrfs/btrfs.go | writeSnapshotInfo | func (v *BtrfsVolume) writeSnapshotInfo(label string, info *volume.SnapshotInfo) error {
writer, err := v.WriteMetadata(label, ".SNAPSHOTINFO")
if err != nil {
glog.Errorf("Could not write meta info for snapshot %s: %s", label, err)
return err
}
defer writer.Close()
encoder := json.NewEncoder(writer)
if err :... | go | func (v *BtrfsVolume) writeSnapshotInfo(label string, info *volume.SnapshotInfo) error {
writer, err := v.WriteMetadata(label, ".SNAPSHOTINFO")
if err != nil {
glog.Errorf("Could not write meta info for snapshot %s: %s", label, err)
return err
}
defer writer.Close()
encoder := json.NewEncoder(writer)
if err :... | [
"func",
"(",
"v",
"*",
"BtrfsVolume",
")",
"writeSnapshotInfo",
"(",
"label",
"string",
",",
"info",
"*",
"volume",
".",
"SnapshotInfo",
")",
"error",
"{",
"writer",
",",
"err",
":=",
"v",
".",
"WriteMetadata",
"(",
"label",
",",
"\"",
"\"",
")",
"\n",... | // writeSnapshotInfo writes metadata about a snapshot | [
"writeSnapshotInfo",
"writes",
"metadata",
"about",
"a",
"snapshot"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/btrfs/btrfs.go#L353-L366 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.