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,300 | control-center/serviced | facade/serviceconfig.go | UpdateServiceConfig | func (f *Facade) UpdateServiceConfig(ctx datastore.Context, fileID string, conf servicedefinition.ConfigFile) error {
defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.UpdateServiceConfig"))
logger := plog.WithFields(log.Fields{
"fileid": fileID,
"filename": conf.Filename,
})
alog := f.auditLogger.Message... | go | func (f *Facade) UpdateServiceConfig(ctx datastore.Context, fileID string, conf servicedefinition.ConfigFile) error {
defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.UpdateServiceConfig"))
logger := plog.WithFields(log.Fields{
"fileid": fileID,
"filename": conf.Filename,
})
alog := f.auditLogger.Message... | [
"func",
"(",
"f",
"*",
"Facade",
")",
"UpdateServiceConfig",
"(",
"ctx",
"datastore",
".",
"Context",
",",
"fileID",
"string",
",",
"conf",
"servicedefinition",
".",
"ConfigFile",
")",
"error",
"{",
"defer",
"ctx",
".",
"Metrics",
"(",
")",
".",
"Stop",
... | // UpdateServiceConfig updates an existing service config file | [
"UpdateServiceConfig",
"updates",
"an",
"existing",
"service",
"config",
"file"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/facade/serviceconfig.go#L135-L166 |
139,301 | control-center/serviced | facade/serviceconfig.go | DeleteServiceConfig | func (f *Facade) DeleteServiceConfig(ctx datastore.Context, fileID string) error {
defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.DeleteServiceConfig"))
logger := plog.WithField("fileid", fileID)
alog := f.auditLogger.Message(ctx, "Removing Service Configuration").
Action(audit.Remove).ID(fileID).Type(servi... | go | func (f *Facade) DeleteServiceConfig(ctx datastore.Context, fileID string) error {
defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.DeleteServiceConfig"))
logger := plog.WithField("fileid", fileID)
alog := f.auditLogger.Message(ctx, "Removing Service Configuration").
Action(audit.Remove).ID(fileID).Type(servi... | [
"func",
"(",
"f",
"*",
"Facade",
")",
"DeleteServiceConfig",
"(",
"ctx",
"datastore",
".",
"Context",
",",
"fileID",
"string",
")",
"error",
"{",
"defer",
"ctx",
".",
"Metrics",
"(",
")",
".",
"Stop",
"(",
"ctx",
".",
"Metrics",
"(",
")",
".",
"Start... | // DeleteServiceConfig deletes a service config file | [
"DeleteServiceConfig",
"deletes",
"a",
"service",
"config",
"file"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/facade/serviceconfig.go#L169-L184 |
139,302 | control-center/serviced | facade/serviceconfig.go | updateServiceConfigs | func (f *Facade) updateServiceConfigs(ctx datastore.Context, serviceID string, configFiles []servicedefinition.ConfigFile, forceDelete bool) error {
tenantID, servicePath, err := f.getServicePath(ctx, serviceID)
if err != nil {
return err
}
svcConfigFiles, err := f.configStore.GetConfigFiles(ctx, tenantID, servic... | go | func (f *Facade) updateServiceConfigs(ctx datastore.Context, serviceID string, configFiles []servicedefinition.ConfigFile, forceDelete bool) error {
tenantID, servicePath, err := f.getServicePath(ctx, serviceID)
if err != nil {
return err
}
svcConfigFiles, err := f.configStore.GetConfigFiles(ctx, tenantID, servic... | [
"func",
"(",
"f",
"*",
"Facade",
")",
"updateServiceConfigs",
"(",
"ctx",
"datastore",
".",
"Context",
",",
"serviceID",
"string",
",",
"configFiles",
"[",
"]",
"servicedefinition",
".",
"ConfigFile",
",",
"forceDelete",
"bool",
")",
"error",
"{",
"tenantID",
... | // updateServiceConfigs adds or updates configuration files. If forceDelete is
// set to true, then remove any extranneous service configurations. | [
"updateServiceConfigs",
"adds",
"or",
"updates",
"configuration",
"files",
".",
"If",
"forceDelete",
"is",
"set",
"to",
"true",
"then",
"remove",
"any",
"extranneous",
"service",
"configurations",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/facade/serviceconfig.go#L204-L259 |
139,303 | control-center/serviced | facade/serviceconfig.go | fillServiceConfigs | func (f *Facade) fillServiceConfigs(ctx datastore.Context, svc *service.Service) error {
tenantID, servicePath, err := f.getServicePath(ctx, svc.ID)
if err != nil {
return err
}
svcConfigFiles, err := f.configStore.GetConfigFiles(ctx, tenantID, servicePath)
if err != nil {
glog.Errorf("Could not load existing ... | go | func (f *Facade) fillServiceConfigs(ctx datastore.Context, svc *service.Service) error {
tenantID, servicePath, err := f.getServicePath(ctx, svc.ID)
if err != nil {
return err
}
svcConfigFiles, err := f.configStore.GetConfigFiles(ctx, tenantID, servicePath)
if err != nil {
glog.Errorf("Could not load existing ... | [
"func",
"(",
"f",
"*",
"Facade",
")",
"fillServiceConfigs",
"(",
"ctx",
"datastore",
".",
"Context",
",",
"svc",
"*",
"service",
".",
"Service",
")",
"error",
"{",
"tenantID",
",",
"servicePath",
",",
"err",
":=",
"f",
".",
"getServicePath",
"(",
"ctx",
... | // fillServiceConfigs sets the configuration files on the service | [
"fillServiceConfigs",
"sets",
"the",
"configuration",
"files",
"on",
"the",
"service"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/facade/serviceconfig.go#L262-L283 |
139,304 | control-center/serviced | domain/servicedefinition/validation.go | validate | func (sd *ServiceDefinition) validate(context *validationContext) error {
//TODO: check name, description, config files.
//Check MinMax settings
if err := sd.Instances.Validate(); err != nil {
return fmt.Errorf("service Definition %v: %v", sd.Name, err)
}
if err := validation.StringIn(sd.Launch, commons.AUTO, ... | go | func (sd *ServiceDefinition) validate(context *validationContext) error {
//TODO: check name, description, config files.
//Check MinMax settings
if err := sd.Instances.Validate(); err != nil {
return fmt.Errorf("service Definition %v: %v", sd.Name, err)
}
if err := validation.StringIn(sd.Launch, commons.AUTO, ... | [
"func",
"(",
"sd",
"*",
"ServiceDefinition",
")",
"validate",
"(",
"context",
"*",
"validationContext",
")",
"error",
"{",
"//TODO: check name, description, config files.",
"//Check MinMax settings",
"if",
"err",
":=",
"sd",
".",
"Instances",
".",
"Validate",
"(",
"... | //validate ServiceDefinition configuration and any embedded ServiceDefinitions | [
"validate",
"ServiceDefinition",
"configuration",
"and",
"any",
"embedded",
"ServiceDefinitions"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/servicedefinition/validation.go#L34-L70 |
139,305 | control-center/serviced | domain/servicedefinition/validation.go | validServiceDefinitions | func validServiceDefinitions(ds *[]ServiceDefinition, context *validationContext) error {
for _, sd := range *ds {
if err := sd.validate(context); err != nil {
return err
}
}
return nil
} | go | func validServiceDefinitions(ds *[]ServiceDefinition, context *validationContext) error {
for _, sd := range *ds {
if err := sd.validate(context); err != nil {
return err
}
}
return nil
} | [
"func",
"validServiceDefinitions",
"(",
"ds",
"*",
"[",
"]",
"ServiceDefinition",
",",
"context",
"*",
"validationContext",
")",
"error",
"{",
"for",
"_",
",",
"sd",
":=",
"range",
"*",
"ds",
"{",
"if",
"err",
":=",
"sd",
".",
"validate",
"(",
"context",... | // validServiceDefinitions validates an array of ServiceDefinition recursively | [
"validServiceDefinitions",
"validates",
"an",
"array",
"of",
"ServiceDefinition",
"recursively"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/servicedefinition/validation.go#L73-L80 |
139,306 | control-center/serviced | domain/servicedefinition/validation.go | NormalizeLaunch | func (sd *ServiceDefinition) NormalizeLaunch() {
testStr := strings.Trim(strings.ToLower(sd.Launch), " ")
if testStr == "" {
testStr = commons.AUTO
}
sd.Launch = testStr
} | go | func (sd *ServiceDefinition) NormalizeLaunch() {
testStr := strings.Trim(strings.ToLower(sd.Launch), " ")
if testStr == "" {
testStr = commons.AUTO
}
sd.Launch = testStr
} | [
"func",
"(",
"sd",
"*",
"ServiceDefinition",
")",
"NormalizeLaunch",
"(",
")",
"{",
"testStr",
":=",
"strings",
".",
"Trim",
"(",
"strings",
".",
"ToLower",
"(",
"sd",
".",
"Launch",
")",
",",
"\"",
"\"",
")",
"\n",
"if",
"testStr",
"==",
"\"",
"\"",... | //NormalizeLaunch normalizes the launch string. Sets to commons.AUTO if empty otherwise just trims and lower cases. Does
//not check if value is valid | [
"NormalizeLaunch",
"normalizes",
"the",
"launch",
"string",
".",
"Sets",
"to",
"commons",
".",
"AUTO",
"if",
"empty",
"otherwise",
"just",
"trims",
"and",
"lower",
"cases",
".",
"Does",
"not",
"check",
"if",
"value",
"is",
"valid"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/servicedefinition/validation.go#L84-L90 |
139,307 | control-center/serviced | domain/servicedefinition/validation.go | validateVHost | func (vc validationContext) validateVHost(se EndpointDefinition) error {
if len(se.VHostList) > 0 {
for _, vhost := range se.VHostList {
if _, found := vc.vhosts[vhost.Name]; found {
return fmt.Errorf("duplicate VHost found: %v", vhost.Name)
}
vc.vhosts[vhost.Name] = se
}
}
return nil
} | go | func (vc validationContext) validateVHost(se EndpointDefinition) error {
if len(se.VHostList) > 0 {
for _, vhost := range se.VHostList {
if _, found := vc.vhosts[vhost.Name]; found {
return fmt.Errorf("duplicate VHost found: %v", vhost.Name)
}
vc.vhosts[vhost.Name] = se
}
}
return nil
} | [
"func",
"(",
"vc",
"validationContext",
")",
"validateVHost",
"(",
"se",
"EndpointDefinition",
")",
"error",
"{",
"if",
"len",
"(",
"se",
".",
"VHostList",
")",
">",
"0",
"{",
"for",
"_",
",",
"vhost",
":=",
"range",
"se",
".",
"VHostList",
"{",
"if",
... | //validateVHost ensures that the VHosts in a ServiceEndpoint have not already been defined | [
"validateVHost",
"ensures",
"that",
"the",
"VHosts",
"in",
"a",
"ServiceEndpoint",
"have",
"not",
"already",
"been",
"defined"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/servicedefinition/validation.go#L98-L108 |
139,308 | control-center/serviced | domain/servicedefinition/validation.go | ValidEntity | func (se EndpointDefinition) ValidEntity() error {
trimName := strings.Trim(se.Name, " ")
if trimName == "" {
return fmt.Errorf("service definition %v: endpoint must have a name %v", se.Name, se)
}
if se.Purpose != "import" {
if err := validation.ValidPort(int(se.PortNumber)); err != nil {
return fmt.Errorf(... | go | func (se EndpointDefinition) ValidEntity() error {
trimName := strings.Trim(se.Name, " ")
if trimName == "" {
return fmt.Errorf("service definition %v: endpoint must have a name %v", se.Name, se)
}
if se.Purpose != "import" {
if err := validation.ValidPort(int(se.PortNumber)); err != nil {
return fmt.Errorf(... | [
"func",
"(",
"se",
"EndpointDefinition",
")",
"ValidEntity",
"(",
")",
"error",
"{",
"trimName",
":=",
"strings",
".",
"Trim",
"(",
"se",
".",
"Name",
",",
"\"",
"\"",
")",
"\n",
"if",
"trimName",
"==",
"\"",
"\"",
"{",
"return",
"fmt",
".",
"Errorf"... | //ValidEntity used to make sure ServiceEndpoint is in a valid state | [
"ValidEntity",
"used",
"to",
"make",
"sure",
"ServiceEndpoint",
"is",
"in",
"a",
"valid",
"state"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/servicedefinition/validation.go#L111-L125 |
139,309 | control-center/serviced | domain/servicedefinition/validation.go | ValidEntity | func (arc AddressResourceConfig) ValidEntity() error {
//check if protocol set or port not 0
violations := validation.NewValidationError()
if arc.Protocol != "" || arc.Port > 0 {
//some setting, now lets make sure they are valid
if err := validation.ValidPort(int(arc.Port)); err != nil {
violations.Add(fmt.Er... | go | func (arc AddressResourceConfig) ValidEntity() error {
//check if protocol set or port not 0
violations := validation.NewValidationError()
if arc.Protocol != "" || arc.Port > 0 {
//some setting, now lets make sure they are valid
if err := validation.ValidPort(int(arc.Port)); err != nil {
violations.Add(fmt.Er... | [
"func",
"(",
"arc",
"AddressResourceConfig",
")",
"ValidEntity",
"(",
")",
"error",
"{",
"//check if protocol set or port not 0",
"violations",
":=",
"validation",
".",
"NewValidationError",
"(",
")",
"\n",
"if",
"arc",
".",
"Protocol",
"!=",
"\"",
"\"",
"||",
"... | //ValidEntity used to make sure AddressResourceConfig is in a valid state | [
"ValidEntity",
"used",
"to",
"make",
"sure",
"AddressResourceConfig",
"is",
"in",
"a",
"valid",
"state"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/servicedefinition/validation.go#L136-L154 |
139,310 | control-center/serviced | domain/servicedefinition/validation.go | Normalize | func (arc *AddressResourceConfig) Normalize() {
testProto := strings.Trim(strings.ToLower(arc.Protocol), " ")
arc.Protocol = testProto
} | go | func (arc *AddressResourceConfig) Normalize() {
testProto := strings.Trim(strings.ToLower(arc.Protocol), " ")
arc.Protocol = testProto
} | [
"func",
"(",
"arc",
"*",
"AddressResourceConfig",
")",
"Normalize",
"(",
")",
"{",
"testProto",
":=",
"strings",
".",
"Trim",
"(",
"strings",
".",
"ToLower",
"(",
"arc",
".",
"Protocol",
")",
",",
"\"",
"\"",
")",
"\n",
"arc",
".",
"Protocol",
"=",
"... | //Normalize adjusts attributes to be in an expected format, lowercases and trims certain fields | [
"Normalize",
"adjusts",
"attributes",
"to",
"be",
"in",
"an",
"expected",
"format",
"lowercases",
"and",
"trims",
"certain",
"fields"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/servicedefinition/validation.go#L157-L160 |
139,311 | control-center/serviced | utils/mount.go | ListAll | func (m *LinuxMount) ListAll() (mounts []MountInfo, err error) {
fh, err := os.Open(m.ProcMount)
if err != nil {
return nil, err
}
defer fh.Close()
reader := bufio.NewReader(fh)
for {
line, err := reader.ReadString('\n')
if line = strings.TrimSpace(line); line != "" {
var fields []string
if fields = s... | go | func (m *LinuxMount) ListAll() (mounts []MountInfo, err error) {
fh, err := os.Open(m.ProcMount)
if err != nil {
return nil, err
}
defer fh.Close()
reader := bufio.NewReader(fh)
for {
line, err := reader.ReadString('\n')
if line = strings.TrimSpace(line); line != "" {
var fields []string
if fields = s... | [
"func",
"(",
"m",
"*",
"LinuxMount",
")",
"ListAll",
"(",
")",
"(",
"mounts",
"[",
"]",
"MountInfo",
",",
"err",
"error",
")",
"{",
"fh",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"m",
".",
"ProcMount",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",... | // ListAll returns info on all mount points | [
"ListAll",
"returns",
"info",
"on",
"all",
"mount",
"points"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/utils/mount.go#L75-L108 |
139,312 | control-center/serviced | utils/mount.go | IsMounted | func (m *LinuxMount) IsMounted(path string) (bool, error) {
mounts, err := m.ListAll()
if err != nil {
return false, err
}
for _, mount := range mounts {
if mount.Device == path || mount.MountPoint == path {
return true, nil
}
}
return false, nil
} | go | func (m *LinuxMount) IsMounted(path string) (bool, error) {
mounts, err := m.ListAll()
if err != nil {
return false, err
}
for _, mount := range mounts {
if mount.Device == path || mount.MountPoint == path {
return true, nil
}
}
return false, nil
} | [
"func",
"(",
"m",
"*",
"LinuxMount",
")",
"IsMounted",
"(",
"path",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"mounts",
",",
"err",
":=",
"m",
".",
"ListAll",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",... | // IsMounted returns true if path is a mountpoint or device | [
"IsMounted",
"returns",
"true",
"if",
"path",
"is",
"a",
"mountpoint",
"or",
"device"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/utils/mount.go#L111-L122 |
139,313 | control-center/serviced | utils/mount.go | Unmount | func (m *LinuxMount) Unmount(path string) error {
if mounted, err := m.IsMounted(path); err != nil {
return err
} else if mounted {
cmd := exec.Command("umount", "-f", path)
if out, err := cmd.CombinedOutput(); err != nil {
return ExecError{
Command: cmd.Args,
Output: out,
Err: err,
}
}... | go | func (m *LinuxMount) Unmount(path string) error {
if mounted, err := m.IsMounted(path); err != nil {
return err
} else if mounted {
cmd := exec.Command("umount", "-f", path)
if out, err := cmd.CombinedOutput(); err != nil {
return ExecError{
Command: cmd.Args,
Output: out,
Err: err,
}
}... | [
"func",
"(",
"m",
"*",
"LinuxMount",
")",
"Unmount",
"(",
"path",
"string",
")",
"error",
"{",
"if",
"mounted",
",",
"err",
":=",
"m",
".",
"IsMounted",
"(",
"path",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"else",
"if",
"mo... | // Unmount unmounts a device or mountpoint | [
"Unmount",
"unmounts",
"a",
"device",
"or",
"mountpoint"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/utils/mount.go#L125-L139 |
139,314 | control-center/serviced | volume/devicemapper/devmapper/deviceset.go | xfsSupported | func xfsSupported() bool {
// Make sure mkfs.xfs is available
if _, err := exec.LookPath("mkfs.xfs"); err != nil {
return false
}
// Check if kernel supports xfs filesystem or not.
exec.Command("modprobe", "xfs").Run()
f, err := os.Open("/proc/filesystems")
if err != nil {
logrus.Warnf("devmapper: Could no... | go | func xfsSupported() bool {
// Make sure mkfs.xfs is available
if _, err := exec.LookPath("mkfs.xfs"); err != nil {
return false
}
// Check if kernel supports xfs filesystem or not.
exec.Command("modprobe", "xfs").Run()
f, err := os.Open("/proc/filesystems")
if err != nil {
logrus.Warnf("devmapper: Could no... | [
"func",
"xfsSupported",
"(",
")",
"bool",
"{",
"// Make sure mkfs.xfs is available",
"if",
"_",
",",
"err",
":=",
"exec",
".",
"LookPath",
"(",
"\"",
"\"",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"// Check if kernel supports ... | // Return true only if kernel supports xfs and mkfs.xfs is available | [
"Return",
"true",
"only",
"if",
"kernel",
"supports",
"xfs",
"and",
"mkfs",
".",
"xfs",
"is",
"available"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/devicemapper/devmapper/deviceset.go#L555-L582 |
139,315 | control-center/serviced | volume/devicemapper/devmapper/deviceset.go | DMLog | func (devices *DeviceSet) DMLog(level int, file string, line int, dmError int, message string) {
// By default libdm sends us all the messages including debug ones.
// We need to filter out messages here and figure out which one
// should be printed.
if level > logLevel {
return
}
// FIXME(vbatts) push this ba... | go | func (devices *DeviceSet) DMLog(level int, file string, line int, dmError int, message string) {
// By default libdm sends us all the messages including debug ones.
// We need to filter out messages here and figure out which one
// should be printed.
if level > logLevel {
return
}
// FIXME(vbatts) push this ba... | [
"func",
"(",
"devices",
"*",
"DeviceSet",
")",
"DMLog",
"(",
"level",
"int",
",",
"file",
"string",
",",
"line",
"int",
",",
"dmError",
"int",
",",
"message",
"string",
")",
"{",
"// By default libdm sends us all the messages including debug ones.",
"// We need to f... | // DMLog implements logging using DevMapperLogger interface. | [
"DMLog",
"implements",
"logging",
"using",
"DevMapperLogger",
"interface",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/volume/devicemapper/devmapper/deviceset.go#L1261-L1278 |
139,316 | control-center/serviced | domain/host/hoststore.go | GetHostByIP | func (hs *storeImpl) GetHostByIP(ctx datastore.Context, hostIP string) (*Host, error) {
defer ctx.Metrics().Stop(ctx.Metrics().Start("HostStore.GetHostByIP"))
if hostIP = strings.TrimSpace(hostIP); hostIP == "" {
return nil, errors.New("empty hostIP not allowed")
}
query := search.Query().Term("IPs.IPAddress", h... | go | func (hs *storeImpl) GetHostByIP(ctx datastore.Context, hostIP string) (*Host, error) {
defer ctx.Metrics().Stop(ctx.Metrics().Start("HostStore.GetHostByIP"))
if hostIP = strings.TrimSpace(hostIP); hostIP == "" {
return nil, errors.New("empty hostIP not allowed")
}
query := search.Query().Term("IPs.IPAddress", h... | [
"func",
"(",
"hs",
"*",
"storeImpl",
")",
"GetHostByIP",
"(",
"ctx",
"datastore",
".",
"Context",
",",
"hostIP",
"string",
")",
"(",
"*",
"Host",
",",
"error",
")",
"{",
"defer",
"ctx",
".",
"Metrics",
"(",
")",
".",
"Stop",
"(",
"ctx",
".",
"Metri... | // GetHostByIP looks up a host by the given ip address | [
"GetHostByIP",
"looks",
"up",
"a",
"host",
"by",
"the",
"given",
"ip",
"address"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/host/hoststore.go#L66-L86 |
139,317 | control-center/serviced | domain/host/hoststore.go | GetN | func (hs *storeImpl) GetN(ctx datastore.Context, limit uint64) ([]Host, error) {
defer ctx.Metrics().Stop(ctx.Metrics().Start("HostStore.GetN"))
q := datastore.NewQuery(ctx)
query := search.Query().Search("_exists_:ID")
search := search.Search("controlplane").Type(kind).Size(strconv.FormatUint(limit, 10)).Query(que... | go | func (hs *storeImpl) GetN(ctx datastore.Context, limit uint64) ([]Host, error) {
defer ctx.Metrics().Stop(ctx.Metrics().Start("HostStore.GetN"))
q := datastore.NewQuery(ctx)
query := search.Query().Search("_exists_:ID")
search := search.Search("controlplane").Type(kind).Size(strconv.FormatUint(limit, 10)).Query(que... | [
"func",
"(",
"hs",
"*",
"storeImpl",
")",
"GetN",
"(",
"ctx",
"datastore",
".",
"Context",
",",
"limit",
"uint64",
")",
"(",
"[",
"]",
"Host",
",",
"error",
")",
"{",
"defer",
"ctx",
".",
"Metrics",
"(",
")",
".",
"Stop",
"(",
"ctx",
".",
"Metric... | // GetN returns all hosts up to limit. | [
"GetN",
"returns",
"all",
"hosts",
"up",
"to",
"limit",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/host/hoststore.go#L89-L99 |
139,318 | control-center/serviced | domain/host/hoststore.go | HostKey | func HostKey(id string) datastore.Key {
id = strings.TrimSpace(id)
return datastore.NewKey(kind, id)
} | go | func HostKey(id string) datastore.Key {
id = strings.TrimSpace(id)
return datastore.NewKey(kind, id)
} | [
"func",
"HostKey",
"(",
"id",
"string",
")",
"datastore",
".",
"Key",
"{",
"id",
"=",
"strings",
".",
"TrimSpace",
"(",
"id",
")",
"\n",
"return",
"datastore",
".",
"NewKey",
"(",
"kind",
",",
"id",
")",
"\n",
"}"
] | //HostKey creates a Key suitable for getting, putting and deleting Hosts | [
"HostKey",
"creates",
"a",
"Key",
"suitable",
"for",
"getting",
"putting",
"and",
"deleting",
"Hosts"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/host/hoststore.go#L102-L105 |
139,319 | control-center/serviced | web/api_pools.go | getPools | func getPools(w *rest.ResponseWriter, r *rest.Request, ctx *requestContext) {
facade := ctx.getFacade()
dataCtx := ctx.getDatastoreContext()
pools, err := facade.GetReadPools(dataCtx)
if err != nil {
restServerError(w, err)
return
}
w.WriteJson(pools)
} | go | func getPools(w *rest.ResponseWriter, r *rest.Request, ctx *requestContext) {
facade := ctx.getFacade()
dataCtx := ctx.getDatastoreContext()
pools, err := facade.GetReadPools(dataCtx)
if err != nil {
restServerError(w, err)
return
}
w.WriteJson(pools)
} | [
"func",
"getPools",
"(",
"w",
"*",
"rest",
".",
"ResponseWriter",
",",
"r",
"*",
"rest",
".",
"Request",
",",
"ctx",
"*",
"requestContext",
")",
"{",
"facade",
":=",
"ctx",
".",
"getFacade",
"(",
")",
"\n",
"dataCtx",
":=",
"ctx",
".",
"getDatastoreCon... | // getPools returns the list of pools requested. This call supports paging. | [
"getPools",
"returns",
"the",
"list",
"of",
"pools",
"requested",
".",
"This",
"call",
"supports",
"paging",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/web/api_pools.go#L21-L32 |
139,320 | control-center/serviced | commons/diet/diet.go | Insert | func (d *Diet) Insert(x, y uint64) {
x, y = sortBoundaries(x, y)
d.root = insert(x, y, d.root)
} | go | func (d *Diet) Insert(x, y uint64) {
x, y = sortBoundaries(x, y)
d.root = insert(x, y, d.root)
} | [
"func",
"(",
"d",
"*",
"Diet",
")",
"Insert",
"(",
"x",
",",
"y",
"uint64",
")",
"{",
"x",
",",
"y",
"=",
"sortBoundaries",
"(",
"x",
",",
"y",
")",
"\n",
"d",
".",
"root",
"=",
"insert",
"(",
"x",
",",
"y",
",",
"d",
".",
"root",
")",
"\... | // Insert adds a new range of integers to the tree. | [
"Insert",
"adds",
"a",
"new",
"range",
"of",
"integers",
"to",
"the",
"tree",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/commons/diet/diet.go#L39-L42 |
139,321 | control-center/serviced | commons/diet/diet.go | Balance | func (d *Diet) Balance() {
if d.root != nil {
d.root = balance(d.root)
}
} | go | func (d *Diet) Balance() {
if d.root != nil {
d.root = balance(d.root)
}
} | [
"func",
"(",
"d",
"*",
"Diet",
")",
"Balance",
"(",
")",
"{",
"if",
"d",
".",
"root",
"!=",
"nil",
"{",
"d",
".",
"root",
"=",
"balance",
"(",
"d",
".",
"root",
")",
"\n",
"}",
"\n",
"}"
] | // Balance balances the tree using the DSW algorithm. It is most efficient to
// do this after the tree is complete. | [
"Balance",
"balances",
"the",
"tree",
"using",
"the",
"DSW",
"algorithm",
".",
"It",
"is",
"most",
"efficient",
"to",
"do",
"this",
"after",
"the",
"tree",
"is",
"complete",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/commons/diet/diet.go#L46-L50 |
139,322 | control-center/serviced | commons/diet/diet.go | Intersection | func (d *Diet) Intersection(x, y uint64) uint64 {
x, y = sortBoundaries(x, y)
return intersection(x, y, d.root)
} | go | func (d *Diet) Intersection(x, y uint64) uint64 {
x, y = sortBoundaries(x, y)
return intersection(x, y, d.root)
} | [
"func",
"(",
"d",
"*",
"Diet",
")",
"Intersection",
"(",
"x",
",",
"y",
"uint64",
")",
"uint64",
"{",
"x",
",",
"y",
"=",
"sortBoundaries",
"(",
"x",
",",
"y",
")",
"\n",
"return",
"intersection",
"(",
"x",
",",
"y",
",",
"d",
".",
"root",
")",... | // Intersection finds the intersection of the range of integers specified with
// any of the members of the tree. It returns the number of members in common. | [
"Intersection",
"finds",
"the",
"intersection",
"of",
"the",
"range",
"of",
"integers",
"specified",
"with",
"any",
"of",
"the",
"members",
"of",
"the",
"tree",
".",
"It",
"returns",
"the",
"number",
"of",
"members",
"in",
"common",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/commons/diet/diet.go#L54-L57 |
139,323 | control-center/serviced | commons/diet/diet.go | IntersectionAll | func (d *Diet) IntersectionAll(other *Diet) uint64 {
return intersectionAll(d.root, other)
} | go | func (d *Diet) IntersectionAll(other *Diet) uint64 {
return intersectionAll(d.root, other)
} | [
"func",
"(",
"d",
"*",
"Diet",
")",
"IntersectionAll",
"(",
"other",
"*",
"Diet",
")",
"uint64",
"{",
"return",
"intersectionAll",
"(",
"d",
".",
"root",
",",
"other",
")",
"\n",
"}"
] | // IntersectionAll finds the number of members in common between two Diets. | [
"IntersectionAll",
"finds",
"the",
"number",
"of",
"members",
"in",
"common",
"between",
"two",
"Diets",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/commons/diet/diet.go#L60-L62 |
139,324 | control-center/serviced | commons/diet/diet.go | Contains | func (d *Diet) Contains(x, y uint64) bool {
x, y = sortBoundaries(x, y)
return intersection(x, y, d.root) == y-x+1
} | go | func (d *Diet) Contains(x, y uint64) bool {
x, y = sortBoundaries(x, y)
return intersection(x, y, d.root) == y-x+1
} | [
"func",
"(",
"d",
"*",
"Diet",
")",
"Contains",
"(",
"x",
",",
"y",
"uint64",
")",
"bool",
"{",
"x",
",",
"y",
"=",
"sortBoundaries",
"(",
"x",
",",
"y",
")",
"\n",
"return",
"intersection",
"(",
"x",
",",
"y",
",",
"d",
".",
"root",
")",
"==... | // Contains returns whether all of the range specified is contained within this
// diet. | [
"Contains",
"returns",
"whether",
"all",
"of",
"the",
"range",
"specified",
"is",
"contained",
"within",
"this",
"diet",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/commons/diet/diet.go#L71-L74 |
139,325 | control-center/serviced | auth/utils.go | NotifyOnChange | func NotifyOnChange(filename string, ops fsnotify.Op, cancel <-chan interface{}) (<-chan struct{}, error) {
filename = filepath.Clean(filename)
dir := filepath.Dir(filename)
w, err := fsnotify.NewWatcher()
if err != nil {
return nil, err
}
if err := w.Add(dir); err != nil {
return nil, err
}
outchan := make... | go | func NotifyOnChange(filename string, ops fsnotify.Op, cancel <-chan interface{}) (<-chan struct{}, error) {
filename = filepath.Clean(filename)
dir := filepath.Dir(filename)
w, err := fsnotify.NewWatcher()
if err != nil {
return nil, err
}
if err := w.Add(dir); err != nil {
return nil, err
}
outchan := make... | [
"func",
"NotifyOnChange",
"(",
"filename",
"string",
",",
"ops",
"fsnotify",
".",
"Op",
",",
"cancel",
"<-",
"chan",
"interface",
"{",
"}",
")",
"(",
"<-",
"chan",
"struct",
"{",
"}",
",",
"error",
")",
"{",
"filename",
"=",
"filepath",
".",
"Clean",
... | // NotifyOnChange watches a file for changes that match the given operation set
// and notifies on a channel when they occur. | [
"NotifyOnChange",
"watches",
"a",
"file",
"for",
"changes",
"that",
"match",
"the",
"given",
"operation",
"set",
"and",
"notifies",
"on",
"a",
"channel",
"when",
"they",
"occur",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/auth/utils.go#L24-L51 |
139,326 | control-center/serviced | domain/service/validation.go | ValidEntity | func (s *Service) ValidEntity() error {
vErr := validation.NewValidationError()
vErr.Add(validation.NotEmpty("ID", s.ID))
vErr.Add(validation.NotEmpty("Name", s.Name))
vErr.Add(validation.NotEmpty("PoolID", s.PoolID))
vErr.Add(validation.StringIn(s.Launch, commons.AUTO, commons.MANUAL))
vErr.Add(validation.IntI... | go | func (s *Service) ValidEntity() error {
vErr := validation.NewValidationError()
vErr.Add(validation.NotEmpty("ID", s.ID))
vErr.Add(validation.NotEmpty("Name", s.Name))
vErr.Add(validation.NotEmpty("PoolID", s.PoolID))
vErr.Add(validation.StringIn(s.Launch, commons.AUTO, commons.MANUAL))
vErr.Add(validation.IntI... | [
"func",
"(",
"s",
"*",
"Service",
")",
"ValidEntity",
"(",
")",
"error",
"{",
"vErr",
":=",
"validation",
".",
"NewValidationError",
"(",
")",
"\n",
"vErr",
".",
"Add",
"(",
"validation",
".",
"NotEmpty",
"(",
"\"",
"\"",
",",
"s",
".",
"ID",
")",
... | //ValidEntity validate that Service has all required fields | [
"ValidEntity",
"validate",
"that",
"Service",
"has",
"all",
"required",
"fields"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/service/validation.go#L24-L61 |
139,327 | control-center/serviced | domain/service/validation.go | ValidEntity | func (endpoint ServiceEndpoint) ValidEntity() error {
violations := validation.NewValidationError()
violations.Add(validation.NotEmpty("endpoint.Name", endpoint.Name))
violations.Add(validation.StringIn(endpoint.Purpose, "export", "import", "import_all"))
if endpoint.Protocol != "" {
violations.Add(validation.St... | go | func (endpoint ServiceEndpoint) ValidEntity() error {
violations := validation.NewValidationError()
violations.Add(validation.NotEmpty("endpoint.Name", endpoint.Name))
violations.Add(validation.StringIn(endpoint.Purpose, "export", "import", "import_all"))
if endpoint.Protocol != "" {
violations.Add(validation.St... | [
"func",
"(",
"endpoint",
"ServiceEndpoint",
")",
"ValidEntity",
"(",
")",
"error",
"{",
"violations",
":=",
"validation",
".",
"NewValidationError",
"(",
")",
"\n",
"violations",
".",
"Add",
"(",
"validation",
".",
"NotEmpty",
"(",
"\"",
"\"",
",",
"endpoint... | // ValidEntity ensures the enpoint has valid values, does not check vhosts, public ports and assignments | [
"ValidEntity",
"ensures",
"the",
"enpoint",
"has",
"valid",
"values",
"does",
"not",
"check",
"vhosts",
"public",
"ports",
"and",
"assignments"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/service/validation.go#L64-L80 |
139,328 | control-center/serviced | script/parser.go | parseLine | func parseLine(line string) (string, []string, error) {
line = strings.TrimLeftFunc(line, unicode.IsSpace)
shellwords.ParseEnv = false
shellwords.ParseBacktick = false
fields, err := shellwords.Parse(line)
if err != nil {
return "", []string{}, err
}
//ignore empty lines
if len(fields) == 0 {
return "", []... | go | func parseLine(line string) (string, []string, error) {
line = strings.TrimLeftFunc(line, unicode.IsSpace)
shellwords.ParseEnv = false
shellwords.ParseBacktick = false
fields, err := shellwords.Parse(line)
if err != nil {
return "", []string{}, err
}
//ignore empty lines
if len(fields) == 0 {
return "", []... | [
"func",
"parseLine",
"(",
"line",
"string",
")",
"(",
"string",
",",
"[",
"]",
"string",
",",
"error",
")",
"{",
"line",
"=",
"strings",
".",
"TrimLeftFunc",
"(",
"line",
",",
"unicode",
".",
"IsSpace",
")",
"\n",
"shellwords",
".",
"ParseEnv",
"=",
... | //parseLine returns the command and args array if any. If line is empty empty string and args are returned | [
"parseLine",
"returns",
"the",
"command",
"and",
"args",
"array",
"if",
"any",
".",
"If",
"line",
"is",
"empty",
"empty",
"string",
"and",
"args",
"are",
"returned"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/script/parser.go#L68-L92 |
139,329 | control-center/serviced | script/parser.go | parseNode | func parseNode(ctx *parseContext) error {
prefix, args, err := parseLine(ctx.line)
if err != nil {
return fmt.Errorf("could not parse line %d: %s: %s", ctx.lineNum, ctx.line, err)
}
f, found := nodeFactories[prefix]
if !found {
return fmt.Errorf("could not parse line %d: %s", ctx.lineNum, ctx.line)
}
node, ... | go | func parseNode(ctx *parseContext) error {
prefix, args, err := parseLine(ctx.line)
if err != nil {
return fmt.Errorf("could not parse line %d: %s: %s", ctx.lineNum, ctx.line, err)
}
f, found := nodeFactories[prefix]
if !found {
return fmt.Errorf("could not parse line %d: %s", ctx.lineNum, ctx.line)
}
node, ... | [
"func",
"parseNode",
"(",
"ctx",
"*",
"parseContext",
")",
"error",
"{",
"prefix",
",",
"args",
",",
"err",
":=",
"parseLine",
"(",
"ctx",
".",
"line",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
... | // parseCommand parses current line and creates a command | [
"parseCommand",
"parses",
"current",
"line",
"and",
"creates",
"a",
"command"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/script/parser.go#L95-L113 |
139,330 | control-center/serviced | cli/api/api.go | NewAPI | func NewAPI(master master.ClientInterface, agent *agent.Client, docker *dockerclient.Client, dao dao.ControlPlane) API {
return &api{master: master, agent: agent, docker: docker, dao: dao}
} | go | func NewAPI(master master.ClientInterface, agent *agent.Client, docker *dockerclient.Client, dao dao.ControlPlane) API {
return &api{master: master, agent: agent, docker: docker, dao: dao}
} | [
"func",
"NewAPI",
"(",
"master",
"master",
".",
"ClientInterface",
",",
"agent",
"*",
"agent",
".",
"Client",
",",
"docker",
"*",
"dockerclient",
".",
"Client",
",",
"dao",
"dao",
".",
"ControlPlane",
")",
"API",
"{",
"return",
"&",
"api",
"{",
"master",... | // New creates a new API type | [
"New",
"creates",
"a",
"new",
"API",
"type"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/api/api.go#L53-L55 |
139,331 | control-center/serviced | cli/api/api.go | connectMaster | func (a *api) connectMaster() (master.ClientInterface, error) {
if a.master == nil {
var err error
a.master, err = master.NewClient(config.GetOptions().Endpoint)
if err != nil {
return nil, fmt.Errorf("could not create a client to the master: %s", err)
}
a.authenticateHost()
}
return a.master, nil
} | go | func (a *api) connectMaster() (master.ClientInterface, error) {
if a.master == nil {
var err error
a.master, err = master.NewClient(config.GetOptions().Endpoint)
if err != nil {
return nil, fmt.Errorf("could not create a client to the master: %s", err)
}
a.authenticateHost()
}
return a.master, nil
} | [
"func",
"(",
"a",
"*",
"api",
")",
"connectMaster",
"(",
")",
"(",
"master",
".",
"ClientInterface",
",",
"error",
")",
"{",
"if",
"a",
".",
"master",
"==",
"nil",
"{",
"var",
"err",
"error",
"\n",
"a",
".",
"master",
",",
"err",
"=",
"master",
"... | // Opens a connection to the master if not already connected | [
"Opens",
"a",
"connection",
"to",
"the",
"master",
"if",
"not",
"already",
"connected"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/api/api.go#L137-L147 |
139,332 | control-center/serviced | cli/api/api.go | connectAgent | func (a *api) connectAgent(address string) (*agent.Client, error) {
if a.agent == nil {
var err error
a.agent, err = agent.NewClient(address)
if err != nil {
return nil, fmt.Errorf("could not create a client to the agent: %s", err)
}
a.authenticateHost()
}
return a.agent, nil
} | go | func (a *api) connectAgent(address string) (*agent.Client, error) {
if a.agent == nil {
var err error
a.agent, err = agent.NewClient(address)
if err != nil {
return nil, fmt.Errorf("could not create a client to the agent: %s", err)
}
a.authenticateHost()
}
return a.agent, nil
} | [
"func",
"(",
"a",
"*",
"api",
")",
"connectAgent",
"(",
"address",
"string",
")",
"(",
"*",
"agent",
".",
"Client",
",",
"error",
")",
"{",
"if",
"a",
".",
"agent",
"==",
"nil",
"{",
"var",
"err",
"error",
"\n",
"a",
".",
"agent",
",",
"err",
"... | // Opens a connection to the agent if not already connected | [
"Opens",
"a",
"connection",
"to",
"the",
"agent",
"if",
"not",
"already",
"connected"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/api/api.go#L150-L160 |
139,333 | control-center/serviced | cli/api/api.go | connectDocker | func (a *api) connectDocker() (*dockerclient.Client, error) {
if a.docker == nil {
const DockerEndpoint string = "unix:///var/run/docker.sock"
var err error
if a.docker, err = dockerclient.NewClient(DockerEndpoint); err != nil {
return nil, fmt.Errorf("could not create a client to docker: %s", err)
}
}
re... | go | func (a *api) connectDocker() (*dockerclient.Client, error) {
if a.docker == nil {
const DockerEndpoint string = "unix:///var/run/docker.sock"
var err error
if a.docker, err = dockerclient.NewClient(DockerEndpoint); err != nil {
return nil, fmt.Errorf("could not create a client to docker: %s", err)
}
}
re... | [
"func",
"(",
"a",
"*",
"api",
")",
"connectDocker",
"(",
")",
"(",
"*",
"dockerclient",
".",
"Client",
",",
"error",
")",
"{",
"if",
"a",
".",
"docker",
"==",
"nil",
"{",
"const",
"DockerEndpoint",
"string",
"=",
"\"",
"\"",
"\n",
"var",
"err",
"er... | // Opens a connection to docker if not already connected | [
"Opens",
"a",
"connection",
"to",
"docker",
"if",
"not",
"already",
"connected"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/api/api.go#L163-L172 |
139,334 | control-center/serviced | cli/api/api.go | authenticateHost | func (a *api) authenticateHost() error {
if hostAuthenticated {
return nil
}
options := config.GetOptions()
// Try to load the master keys, fail silently if they don't exist
masterKeyFile := filepath.Join(options.IsvcsPath, auth.MasterKeyFileName)
if err := auth.LoadMasterKeyFile(masterKeyFile); err != nil {
... | go | func (a *api) authenticateHost() error {
if hostAuthenticated {
return nil
}
options := config.GetOptions()
// Try to load the master keys, fail silently if they don't exist
masterKeyFile := filepath.Join(options.IsvcsPath, auth.MasterKeyFileName)
if err := auth.LoadMasterKeyFile(masterKeyFile); err != nil {
... | [
"func",
"(",
"a",
"*",
"api",
")",
"authenticateHost",
"(",
")",
"error",
"{",
"if",
"hostAuthenticated",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"options",
":=",
"config",
".",
"GetOptions",
"(",
")",
"\n\n",
"// Try to load the master keys, fail silently if t... | // This will authenticate the host once to get a valid token for any CLI commands
// that require it. | [
"This",
"will",
"authenticate",
"the",
"host",
"once",
"to",
"get",
"a",
"valid",
"token",
"for",
"any",
"CLI",
"commands",
"that",
"require",
"it",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/api/api.go#L190-L229 |
139,335 | control-center/serviced | dao/elasticsearch/filesystem.go | SetProgress | func (p *InProgress) SetProgress(filename, op string) {
p.locker.Lock()
defer p.locker.Unlock()
p.running = true
p.filename = filename
p.op = op
} | go | func (p *InProgress) SetProgress(filename, op string) {
p.locker.Lock()
defer p.locker.Unlock()
p.running = true
p.filename = filename
p.op = op
} | [
"func",
"(",
"p",
"*",
"InProgress",
")",
"SetProgress",
"(",
"filename",
",",
"op",
"string",
")",
"{",
"p",
".",
"locker",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"locker",
".",
"Unlock",
"(",
")",
"\n",
"p",
".",
"running",
"=",
"true"... | // SetProgress sets the current operation | [
"SetProgress",
"sets",
"the",
"current",
"operation"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dao/elasticsearch/filesystem.go#L48-L54 |
139,336 | control-center/serviced | dao/elasticsearch/filesystem.go | SetError | func (p *InProgress) SetError(err error) {
p.locker.Lock()
defer p.locker.Unlock()
p.running = false
p.err = err
} | go | func (p *InProgress) SetError(err error) {
p.locker.Lock()
defer p.locker.Unlock()
p.running = false
p.err = err
} | [
"func",
"(",
"p",
"*",
"InProgress",
")",
"SetError",
"(",
"err",
"error",
")",
"{",
"p",
".",
"locker",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"locker",
".",
"Unlock",
"(",
")",
"\n",
"p",
".",
"running",
"=",
"false",
"\n",
"p",
".",... | // SetError sets the error returned from the current operation | [
"SetError",
"sets",
"the",
"error",
"returned",
"from",
"the",
"current",
"operation"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dao/elasticsearch/filesystem.go#L57-L62 |
139,337 | control-center/serviced | dao/elasticsearch/filesystem.go | Reset | func (p *InProgress) Reset() {
p.locker.Lock()
defer p.locker.Unlock()
p.running = false
p.filename = ""
p.op = ""
p.err = nil
} | go | func (p *InProgress) Reset() {
p.locker.Lock()
defer p.locker.Unlock()
p.running = false
p.filename = ""
p.op = ""
p.err = nil
} | [
"func",
"(",
"p",
"*",
"InProgress",
")",
"Reset",
"(",
")",
"{",
"p",
".",
"locker",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"locker",
".",
"Unlock",
"(",
")",
"\n",
"p",
".",
"running",
"=",
"false",
"\n",
"p",
".",
"filename",
"=",
... | // Reset resets the progress indicator | [
"Reset",
"resets",
"the",
"progress",
"indicator"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dao/elasticsearch/filesystem.go#L65-L72 |
139,338 | control-center/serviced | dao/elasticsearch/filesystem.go | UnsetProgress | func (p *InProgress) UnsetProgress(err error) {
p.locker.Lock()
defer p.locker.Unlock()
p.filename = ""
p.op = ""
p.err = err
} | go | func (p *InProgress) UnsetProgress(err error) {
p.locker.Lock()
defer p.locker.Unlock()
p.filename = ""
p.op = ""
p.err = err
} | [
"func",
"(",
"p",
"*",
"InProgress",
")",
"UnsetProgress",
"(",
"err",
"error",
")",
"{",
"p",
".",
"locker",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"locker",
".",
"Unlock",
"(",
")",
"\n",
"p",
".",
"filename",
"=",
"\"",
"\"",
"\n",
... | // UnsetProgress unsets the current operation | [
"UnsetProgress",
"unsets",
"the",
"current",
"operation"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dao/elasticsearch/filesystem.go#L75-L81 |
139,339 | control-center/serviced | dao/elasticsearch/filesystem.go | GetProgress | func (p *InProgress) GetProgress() (bool, string, string, error) {
p.locker.RLock()
defer p.locker.RUnlock()
return p.running, p.filename, p.op, p.err
} | go | func (p *InProgress) GetProgress() (bool, string, string, error) {
p.locker.RLock()
defer p.locker.RUnlock()
return p.running, p.filename, p.op, p.err
} | [
"func",
"(",
"p",
"*",
"InProgress",
")",
"GetProgress",
"(",
")",
"(",
"bool",
",",
"string",
",",
"string",
",",
"error",
")",
"{",
"p",
".",
"locker",
".",
"RLock",
"(",
")",
"\n",
"defer",
"p",
".",
"locker",
".",
"RUnlock",
"(",
")",
"\n",
... | // GetProgress returns the progress of the current running backup or restore. | [
"GetProgress",
"returns",
"the",
"progress",
"of",
"the",
"current",
"running",
"backup",
"or",
"restore",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dao/elasticsearch/filesystem.go#L84-L88 |
139,340 | control-center/serviced | dao/elasticsearch/filesystem.go | Backup | func (dao *ControlPlaneDao) Backup(backupRequest model.BackupRequest, filename *string) (err error) {
ctx := datastore.Get()
if len(backupRequest.Username) > 0 {
ctx.SetUser(backupRequest.Username)
}
// synchronize the dfs
dfslocker := dao.facade.DFSLock(ctx)
dfslocker.Lock("backup")
defer dfslocker.Unlock()
... | go | func (dao *ControlPlaneDao) Backup(backupRequest model.BackupRequest, filename *string) (err error) {
ctx := datastore.Get()
if len(backupRequest.Username) > 0 {
ctx.SetUser(backupRequest.Username)
}
// synchronize the dfs
dfslocker := dao.facade.DFSLock(ctx)
dfslocker.Lock("backup")
defer dfslocker.Unlock()
... | [
"func",
"(",
"dao",
"*",
"ControlPlaneDao",
")",
"Backup",
"(",
"backupRequest",
"model",
".",
"BackupRequest",
",",
"filename",
"*",
"string",
")",
"(",
"err",
"error",
")",
"{",
"ctx",
":=",
"datastore",
".",
"Get",
"(",
")",
"\n",
"if",
"len",
"(",
... | // Backup takes a backup of the full application stack and returns the filename
// that it is written to. | [
"Backup",
"takes",
"a",
"backup",
"of",
"the",
"full",
"application",
"stack",
"and",
"returns",
"the",
"filename",
"that",
"it",
"is",
"written",
"to",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dao/elasticsearch/filesystem.go#L94-L157 |
139,341 | control-center/serviced | dao/elasticsearch/filesystem.go | AsyncBackup | func (dao *ControlPlaneDao) AsyncBackup(backupRequest model.BackupRequest, filename *string) (err error) {
ctx := datastore.Get()
if len(backupRequest.Username) > 0 {
ctx.SetUser(backupRequest.Username)
}
dfslocker := dao.facade.DFSLock(ctx)
dfslocker.Lock("backup")
inprogress.Reset()
dfslocker.Unlock()
go da... | go | func (dao *ControlPlaneDao) AsyncBackup(backupRequest model.BackupRequest, filename *string) (err error) {
ctx := datastore.Get()
if len(backupRequest.Username) > 0 {
ctx.SetUser(backupRequest.Username)
}
dfslocker := dao.facade.DFSLock(ctx)
dfslocker.Lock("backup")
inprogress.Reset()
dfslocker.Unlock()
go da... | [
"func",
"(",
"dao",
"*",
"ControlPlaneDao",
")",
"AsyncBackup",
"(",
"backupRequest",
"model",
".",
"BackupRequest",
",",
"filename",
"*",
"string",
")",
"(",
"err",
"error",
")",
"{",
"ctx",
":=",
"datastore",
".",
"Get",
"(",
")",
"\n",
"if",
"len",
... | // AsyncBackup is the same as backup, but asynchronous | [
"AsyncBackup",
"is",
"the",
"same",
"as",
"backup",
"but",
"asynchronous"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dao/elasticsearch/filesystem.go#L179-L190 |
139,342 | control-center/serviced | dao/elasticsearch/filesystem.go | Restore | func (dao *ControlPlaneDao) Restore(restoreRequest model.RestoreRequest, _ *int) (err error) {
ctx := datastore.Get()
if len(restoreRequest.Username) > 0 {
ctx.SetUser(restoreRequest.Username)
}
dfslocker := dao.facade.DFSLock(ctx)
dfslocker.Lock("restore")
defer dfslocker.Unlock()
inprogress.SetProgress(resto... | go | func (dao *ControlPlaneDao) Restore(restoreRequest model.RestoreRequest, _ *int) (err error) {
ctx := datastore.Get()
if len(restoreRequest.Username) > 0 {
ctx.SetUser(restoreRequest.Username)
}
dfslocker := dao.facade.DFSLock(ctx)
dfslocker.Lock("restore")
defer dfslocker.Unlock()
inprogress.SetProgress(resto... | [
"func",
"(",
"dao",
"*",
"ControlPlaneDao",
")",
"Restore",
"(",
"restoreRequest",
"model",
".",
"RestoreRequest",
",",
"_",
"*",
"int",
")",
"(",
"err",
"error",
")",
"{",
"ctx",
":=",
"datastore",
".",
"Get",
"(",
")",
"\n",
"if",
"len",
"(",
"rest... | // Restore restores the full application stack from a backup file. | [
"Restore",
"restores",
"the",
"full",
"application",
"stack",
"from",
"a",
"backup",
"file",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dao/elasticsearch/filesystem.go#L193-L224 |
139,343 | control-center/serviced | dao/elasticsearch/filesystem.go | AsyncRestore | func (dao *ControlPlaneDao) AsyncRestore(restoreRequest model.RestoreRequest, unused *int) (err error) {
ctx := datastore.Get()
if len(restoreRequest.Username) > 0 {
ctx.SetUser(restoreRequest.Username)
}
dfslocker := dao.facade.DFSLock(ctx)
dfslocker.Lock("restore")
inprogress.Reset()
dfslocker.Unlock()
go d... | go | func (dao *ControlPlaneDao) AsyncRestore(restoreRequest model.RestoreRequest, unused *int) (err error) {
ctx := datastore.Get()
if len(restoreRequest.Username) > 0 {
ctx.SetUser(restoreRequest.Username)
}
dfslocker := dao.facade.DFSLock(ctx)
dfslocker.Lock("restore")
inprogress.Reset()
dfslocker.Unlock()
go d... | [
"func",
"(",
"dao",
"*",
"ControlPlaneDao",
")",
"AsyncRestore",
"(",
"restoreRequest",
"model",
".",
"RestoreRequest",
",",
"unused",
"*",
"int",
")",
"(",
"err",
"error",
")",
"{",
"ctx",
":=",
"datastore",
".",
"Get",
"(",
")",
"\n",
"if",
"len",
"(... | // AsyncRestore is the same as restore, but asynchronous. | [
"AsyncRestore",
"is",
"the",
"same",
"as",
"restore",
"but",
"asynchronous",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dao/elasticsearch/filesystem.go#L227-L238 |
139,344 | control-center/serviced | dao/elasticsearch/filesystem.go | ListBackups | func (dao *ControlPlaneDao) ListBackups(dirpath string, files *[]model.BackupFile) (err error) {
*files = []model.BackupFile{}
// Read the contents of the directory
if dirpath == "" {
dirpath = dao.backupsPath
}
dir, err := os.Open(dirpath)
if err != nil {
return err
}
defer dir.Close()
fis, err := dir.R... | go | func (dao *ControlPlaneDao) ListBackups(dirpath string, files *[]model.BackupFile) (err error) {
*files = []model.BackupFile{}
// Read the contents of the directory
if dirpath == "" {
dirpath = dao.backupsPath
}
dir, err := os.Open(dirpath)
if err != nil {
return err
}
defer dir.Close()
fis, err := dir.R... | [
"func",
"(",
"dao",
"*",
"ControlPlaneDao",
")",
"ListBackups",
"(",
"dirpath",
"string",
",",
"files",
"*",
"[",
"]",
"model",
".",
"BackupFile",
")",
"(",
"err",
"error",
")",
"{",
"*",
"files",
"=",
"[",
"]",
"model",
".",
"BackupFile",
"{",
"}",
... | // ListBackups returns the list of backups | [
"ListBackups",
"returns",
"the",
"list",
"of",
"backups"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dao/elasticsearch/filesystem.go#L241-L301 |
139,345 | control-center/serviced | dao/elasticsearch/filesystem.go | BackupStatus | func (dao *ControlPlaneDao) BackupStatus(_ model.EntityRequest, status *string) (err error) {
running, filename, op, err := inprogress.GetProgress()
if running {
*status = fmt.Sprintf("Performing a %s on %s", op, filename)
} else {
if err != nil {
*status = fmt.Sprintf("Completed a %s on %s with error: %s", o... | go | func (dao *ControlPlaneDao) BackupStatus(_ model.EntityRequest, status *string) (err error) {
running, filename, op, err := inprogress.GetProgress()
if running {
*status = fmt.Sprintf("Performing a %s on %s", op, filename)
} else {
if err != nil {
*status = fmt.Sprintf("Completed a %s on %s with error: %s", o... | [
"func",
"(",
"dao",
"*",
"ControlPlaneDao",
")",
"BackupStatus",
"(",
"_",
"model",
".",
"EntityRequest",
",",
"status",
"*",
"string",
")",
"(",
"err",
"error",
")",
"{",
"running",
",",
"filename",
",",
"op",
",",
"err",
":=",
"inprogress",
".",
"Get... | // BackupStatus returns the current status of the backup or restore that is
// running. | [
"BackupStatus",
"returns",
"the",
"current",
"status",
"of",
"the",
"backup",
"or",
"restore",
"that",
"is",
"running",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dao/elasticsearch/filesystem.go#L305-L318 |
139,346 | control-center/serviced | dao/elasticsearch/filesystem.go | Snapshot | func (dao *ControlPlaneDao) Snapshot(req model.SnapshotRequest, snapshotID *string) (err error) {
ctx := datastore.Get()
// synchronize the dfs
dfslocker := dao.facade.DFSLock(ctx)
dfslocker.Lock("snapshot")
defer dfslocker.Unlock()
tagList := []string{}
if len(req.Tag) > 0 {
tagList = []string{req.Tag}
}
... | go | func (dao *ControlPlaneDao) Snapshot(req model.SnapshotRequest, snapshotID *string) (err error) {
ctx := datastore.Get()
// synchronize the dfs
dfslocker := dao.facade.DFSLock(ctx)
dfslocker.Lock("snapshot")
defer dfslocker.Unlock()
tagList := []string{}
if len(req.Tag) > 0 {
tagList = []string{req.Tag}
}
... | [
"func",
"(",
"dao",
"*",
"ControlPlaneDao",
")",
"Snapshot",
"(",
"req",
"model",
".",
"SnapshotRequest",
",",
"snapshotID",
"*",
"string",
")",
"(",
"err",
"error",
")",
"{",
"ctx",
":=",
"datastore",
".",
"Get",
"(",
")",
"\n\n",
"// synchronize the dfs"... | // Snapshot captures the current state of a single application | [
"Snapshot",
"captures",
"the",
"current",
"state",
"of",
"a",
"single",
"application"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dao/elasticsearch/filesystem.go#L321-L340 |
139,347 | control-center/serviced | dao/elasticsearch/filesystem.go | Rollback | func (dao *ControlPlaneDao) Rollback(req model.RollbackRequest, _ *int) (err error) {
ctx := datastore.Get()
// synchronize the dfs
dfslocker := dao.facade.DFSLock(ctx)
dfslocker.Lock("rollback")
defer dfslocker.Unlock()
err = dao.facade.Rollback(ctx, req.SnapshotID, req.ForceRestart)
return
} | go | func (dao *ControlPlaneDao) Rollback(req model.RollbackRequest, _ *int) (err error) {
ctx := datastore.Get()
// synchronize the dfs
dfslocker := dao.facade.DFSLock(ctx)
dfslocker.Lock("rollback")
defer dfslocker.Unlock()
err = dao.facade.Rollback(ctx, req.SnapshotID, req.ForceRestart)
return
} | [
"func",
"(",
"dao",
"*",
"ControlPlaneDao",
")",
"Rollback",
"(",
"req",
"model",
".",
"RollbackRequest",
",",
"_",
"*",
"int",
")",
"(",
"err",
"error",
")",
"{",
"ctx",
":=",
"datastore",
".",
"Get",
"(",
")",
"\n\n",
"// synchronize the dfs",
"dfslock... | // Rollback reverts a single application to a particular state | [
"Rollback",
"reverts",
"a",
"single",
"application",
"to",
"a",
"particular",
"state"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dao/elasticsearch/filesystem.go#L343-L352 |
139,348 | control-center/serviced | dao/elasticsearch/filesystem.go | DeleteSnapshot | func (dao *ControlPlaneDao) DeleteSnapshot(snapshotID string, _ *int) (err error) {
ctx := datastore.Get()
// synchronize the dfs
dfslocker := dao.facade.DFSLock(ctx)
dfslocker.Lock("delete snapshot")
defer dfslocker.Unlock()
err = dao.facade.DeleteSnapshot(ctx, snapshotID)
return
} | go | func (dao *ControlPlaneDao) DeleteSnapshot(snapshotID string, _ *int) (err error) {
ctx := datastore.Get()
// synchronize the dfs
dfslocker := dao.facade.DFSLock(ctx)
dfslocker.Lock("delete snapshot")
defer dfslocker.Unlock()
err = dao.facade.DeleteSnapshot(ctx, snapshotID)
return
} | [
"func",
"(",
"dao",
"*",
"ControlPlaneDao",
")",
"DeleteSnapshot",
"(",
"snapshotID",
"string",
",",
"_",
"*",
"int",
")",
"(",
"err",
"error",
")",
"{",
"ctx",
":=",
"datastore",
".",
"Get",
"(",
")",
"\n\n",
"// synchronize the dfs",
"dfslocker",
":=",
... | // DeleteSnapshot deletes a single snapshot | [
"DeleteSnapshot",
"deletes",
"a",
"single",
"snapshot"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dao/elasticsearch/filesystem.go#L355-L364 |
139,349 | control-center/serviced | dao/elasticsearch/filesystem.go | ListSnapshots | func (dao *ControlPlaneDao) ListSnapshots(serviceID string, snapshots *[]model.SnapshotInfo) (err error) {
ctx := datastore.Get()
// synchronize the dfs
dfslocker := dao.facade.DFSLock(ctx)
dfslocker.Lock("list snapshots")
defer dfslocker.Unlock()
*snapshots = make([]model.SnapshotInfo, 0)
snapshotIDs, err := ... | go | func (dao *ControlPlaneDao) ListSnapshots(serviceID string, snapshots *[]model.SnapshotInfo) (err error) {
ctx := datastore.Get()
// synchronize the dfs
dfslocker := dao.facade.DFSLock(ctx)
dfslocker.Lock("list snapshots")
defer dfslocker.Unlock()
*snapshots = make([]model.SnapshotInfo, 0)
snapshotIDs, err := ... | [
"func",
"(",
"dao",
"*",
"ControlPlaneDao",
")",
"ListSnapshots",
"(",
"serviceID",
"string",
",",
"snapshots",
"*",
"[",
"]",
"model",
".",
"SnapshotInfo",
")",
"(",
"err",
"error",
")",
"{",
"ctx",
":=",
"datastore",
".",
"Get",
"(",
")",
"\n\n",
"//... | // ListSnapshots returns a list of all snapshots for a service | [
"ListSnapshots",
"returns",
"a",
"list",
"of",
"all",
"snapshots",
"for",
"a",
"service"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dao/elasticsearch/filesystem.go#L379-L417 |
139,350 | control-center/serviced | dao/elasticsearch/filesystem.go | ResetRegistry | func (dao *ControlPlaneDao) ResetRegistry(_ model.EntityRequest, _ *int) (err error) {
// Do not DFSLock here, Facade does that
err = dao.facade.SyncRegistryImages(datastore.Get(), true)
return
} | go | func (dao *ControlPlaneDao) ResetRegistry(_ model.EntityRequest, _ *int) (err error) {
// Do not DFSLock here, Facade does that
err = dao.facade.SyncRegistryImages(datastore.Get(), true)
return
} | [
"func",
"(",
"dao",
"*",
"ControlPlaneDao",
")",
"ResetRegistry",
"(",
"_",
"model",
".",
"EntityRequest",
",",
"_",
"*",
"int",
")",
"(",
"err",
"error",
")",
"{",
"// Do not DFSLock here, Facade does that",
"err",
"=",
"dao",
".",
"facade",
".",
"SyncRegis... | // ResetRegistry prompts all images to be pushed back into the docker registry | [
"ResetRegistry",
"prompts",
"all",
"images",
"to",
"be",
"pushed",
"back",
"into",
"the",
"docker",
"registry"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dao/elasticsearch/filesystem.go#L420-L424 |
139,351 | control-center/serviced | dao/elasticsearch/filesystem.go | RepairRegistry | func (dao *ControlPlaneDao) RepairRegistry(_ model.EntityRequest, _ *int) (err error) {
// Do not DFSLock here, Facade does that
err = dao.facade.RepairRegistry(datastore.Get())
return
} | go | func (dao *ControlPlaneDao) RepairRegistry(_ model.EntityRequest, _ *int) (err error) {
// Do not DFSLock here, Facade does that
err = dao.facade.RepairRegistry(datastore.Get())
return
} | [
"func",
"(",
"dao",
"*",
"ControlPlaneDao",
")",
"RepairRegistry",
"(",
"_",
"model",
".",
"EntityRequest",
",",
"_",
"*",
"int",
")",
"(",
"err",
"error",
")",
"{",
"// Do not DFSLock here, Facade does that",
"err",
"=",
"dao",
".",
"facade",
".",
"RepairRe... | // RepairRegistry will try to recover the latest image of all service images
// from the docker registry and save it to the index. | [
"RepairRegistry",
"will",
"try",
"to",
"recover",
"the",
"latest",
"image",
"of",
"all",
"service",
"images",
"from",
"the",
"docker",
"registry",
"and",
"save",
"it",
"to",
"the",
"index",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dao/elasticsearch/filesystem.go#L428-L432 |
139,352 | control-center/serviced | dao/elasticsearch/filesystem.go | ReadyDFS | func (dao *ControlPlaneDao) ReadyDFS(serviceID string, _ *int) (err error) {
ctx := datastore.Get()
// synchronize the dfs
dfslocker := dao.facade.DFSLock(ctx)
dfslocker.Lock("reset tenant lock")
defer dfslocker.Unlock()
err = dao.facade.ResetLock(ctx, serviceID)
return
} | go | func (dao *ControlPlaneDao) ReadyDFS(serviceID string, _ *int) (err error) {
ctx := datastore.Get()
// synchronize the dfs
dfslocker := dao.facade.DFSLock(ctx)
dfslocker.Lock("reset tenant lock")
defer dfslocker.Unlock()
err = dao.facade.ResetLock(ctx, serviceID)
return
} | [
"func",
"(",
"dao",
"*",
"ControlPlaneDao",
")",
"ReadyDFS",
"(",
"serviceID",
"string",
",",
"_",
"*",
"int",
")",
"(",
"err",
"error",
")",
"{",
"ctx",
":=",
"datastore",
".",
"Get",
"(",
")",
"\n\n",
"// synchronize the dfs",
"dfslocker",
":=",
"dao",... | // ReadyDFS locks until it receives notice that the dfs is idle | [
"ReadyDFS",
"locks",
"until",
"it",
"receives",
"notice",
"that",
"the",
"dfs",
"is",
"idle"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dao/elasticsearch/filesystem.go#L435-L445 |
139,353 | control-center/serviced | dao/elasticsearch/filesystem.go | TagSnapshot | func (dao *ControlPlaneDao) TagSnapshot(request model.TagSnapshotRequest, _ *int) error {
return dao.facade.TagSnapshot(request.SnapshotID, request.TagName)
} | go | func (dao *ControlPlaneDao) TagSnapshot(request model.TagSnapshotRequest, _ *int) error {
return dao.facade.TagSnapshot(request.SnapshotID, request.TagName)
} | [
"func",
"(",
"dao",
"*",
"ControlPlaneDao",
")",
"TagSnapshot",
"(",
"request",
"model",
".",
"TagSnapshotRequest",
",",
"_",
"*",
"int",
")",
"error",
"{",
"return",
"dao",
".",
"facade",
".",
"TagSnapshot",
"(",
"request",
".",
"SnapshotID",
",",
"reques... | // TagSnapshot adds a tag to an existing snapshot | [
"TagSnapshot",
"adds",
"a",
"tag",
"to",
"an",
"existing",
"snapshot"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dao/elasticsearch/filesystem.go#L448-L450 |
139,354 | control-center/serviced | dao/elasticsearch/filesystem.go | RemoveSnapshotTag | func (dao *ControlPlaneDao) RemoveSnapshotTag(request model.SnapshotByTagRequest, snapshotID *string) (err error) {
ctx := datastore.Get()
*snapshotID, err = dao.facade.RemoveSnapshotTag(ctx, request.ServiceID, request.TagName)
return err
} | go | func (dao *ControlPlaneDao) RemoveSnapshotTag(request model.SnapshotByTagRequest, snapshotID *string) (err error) {
ctx := datastore.Get()
*snapshotID, err = dao.facade.RemoveSnapshotTag(ctx, request.ServiceID, request.TagName)
return err
} | [
"func",
"(",
"dao",
"*",
"ControlPlaneDao",
")",
"RemoveSnapshotTag",
"(",
"request",
"model",
".",
"SnapshotByTagRequest",
",",
"snapshotID",
"*",
"string",
")",
"(",
"err",
"error",
")",
"{",
"ctx",
":=",
"datastore",
".",
"Get",
"(",
")",
"\n",
"*",
"... | // RemoveSnapshotTag removes a tag from an existing snapshot | [
"RemoveSnapshotTag",
"removes",
"a",
"tag",
"from",
"an",
"existing",
"snapshot"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dao/elasticsearch/filesystem.go#L453-L457 |
139,355 | control-center/serviced | dao/elasticsearch/filesystem.go | GetSnapshotByServiceIDAndTag | func (dao *ControlPlaneDao) GetSnapshotByServiceIDAndTag(request model.SnapshotByTagRequest, snapshot *model.SnapshotInfo) (err error) {
ctx := datastore.Get()
info, err := dao.facade.GetSnapshotByServiceIDAndTag(ctx, request.ServiceID, request.TagName)
if err != nil {
return
}
*snapshot = model.SnapshotInfo{
... | go | func (dao *ControlPlaneDao) GetSnapshotByServiceIDAndTag(request model.SnapshotByTagRequest, snapshot *model.SnapshotInfo) (err error) {
ctx := datastore.Get()
info, err := dao.facade.GetSnapshotByServiceIDAndTag(ctx, request.ServiceID, request.TagName)
if err != nil {
return
}
*snapshot = model.SnapshotInfo{
... | [
"func",
"(",
"dao",
"*",
"ControlPlaneDao",
")",
"GetSnapshotByServiceIDAndTag",
"(",
"request",
"model",
".",
"SnapshotByTagRequest",
",",
"snapshot",
"*",
"model",
".",
"SnapshotInfo",
")",
"(",
"err",
"error",
")",
"{",
"ctx",
":=",
"datastore",
".",
"Get",... | // GetSnapshotByServiceIDAndTag Gets the snapshot from a specific service with a specific tag | [
"GetSnapshotByServiceIDAndTag",
"Gets",
"the",
"snapshot",
"from",
"a",
"specific",
"service",
"with",
"a",
"specific",
"tag"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dao/elasticsearch/filesystem.go#L460-L474 |
139,356 | control-center/serviced | cli/cmd/version.go | initVersion | func (c *ServicedCli) initVersion() {
c.app.Commands = append(c.app.Commands, cli.Command{
Name: "version",
Usage: "shows version information",
Description: "",
Action: c.cmdVersion,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "verbose, v",
Usage: "Show JSON format",
},
},
})
} | go | func (c *ServicedCli) initVersion() {
c.app.Commands = append(c.app.Commands, cli.Command{
Name: "version",
Usage: "shows version information",
Description: "",
Action: c.cmdVersion,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "verbose, v",
Usage: "Show JSON format",
},
},
})
} | [
"func",
"(",
"c",
"*",
"ServicedCli",
")",
"initVersion",
"(",
")",
"{",
"c",
".",
"app",
".",
"Commands",
"=",
"append",
"(",
"c",
".",
"app",
".",
"Commands",
",",
"cli",
".",
"Command",
"{",
"Name",
":",
"\"",
"\"",
",",
"Usage",
":",
"\"",
... | // Initializer for serviced version | [
"Initializer",
"for",
"serviced",
"version"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/cmd/version.go#L28-L41 |
139,357 | control-center/serviced | domain/servicetemplate/servicetemplate.go | Equals | func (a *ServiceTemplate) Equals(b *ServiceTemplate) bool {
if a.ID != b.ID {
return false
}
if a.Name != b.Name {
return false
}
if a.Version != b.Version {
return false
}
if a.Description != b.Description {
return false
}
if !reflect.DeepEqual(a.Services, b.Services) {
return false
}
if !reflect.... | go | func (a *ServiceTemplate) Equals(b *ServiceTemplate) bool {
if a.ID != b.ID {
return false
}
if a.Name != b.Name {
return false
}
if a.Version != b.Version {
return false
}
if a.Description != b.Description {
return false
}
if !reflect.DeepEqual(a.Services, b.Services) {
return false
}
if !reflect.... | [
"func",
"(",
"a",
"*",
"ServiceTemplate",
")",
"Equals",
"(",
"b",
"*",
"ServiceTemplate",
")",
"bool",
"{",
"if",
"a",
".",
"ID",
"!=",
"b",
".",
"ID",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"a",
".",
"Name",
"!=",
"b",
".",
"Name",
"{... | // Equals checks the equality of two service templates | [
"Equals",
"checks",
"the",
"equality",
"of",
"two",
"service",
"templates"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/servicetemplate/servicetemplate.go#L50-L70 |
139,358 | control-center/serviced | domain/servicetemplate/servicetemplate.go | FromJSON | func FromJSON(data string) (*ServiceTemplate, error) {
var st ServiceTemplate
err := json.Unmarshal([]byte(data), &st)
return &st, err
} | go | func FromJSON(data string) (*ServiceTemplate, error) {
var st ServiceTemplate
err := json.Unmarshal([]byte(data), &st)
return &st, err
} | [
"func",
"FromJSON",
"(",
"data",
"string",
")",
"(",
"*",
"ServiceTemplate",
",",
"error",
")",
"{",
"var",
"st",
"ServiceTemplate",
"\n",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"[",
"]",
"byte",
"(",
"data",
")",
",",
"&",
"st",
")",
"\n",
"r... | //FromJSON creates a ServiceTemplate from the json string | [
"FromJSON",
"creates",
"a",
"ServiceTemplate",
"from",
"the",
"json",
"string"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/domain/servicetemplate/servicetemplate.go#L84-L88 |
139,359 | control-center/serviced | dfs/mounts.go | VerifyTenantMounts | func (dfs *DistributedFilesystem) VerifyTenantMounts(tenantID string) error {
logger := plog.WithField("tenantid", tenantID)
vol, err := dfs.disk.Get(tenantID)
if err != nil {
logger.WithError(err).Error("Could not get volume for tenant")
return err
}
volumePath := vol.Path()
exportPath := path.Join(dfs.net... | go | func (dfs *DistributedFilesystem) VerifyTenantMounts(tenantID string) error {
logger := plog.WithField("tenantid", tenantID)
vol, err := dfs.disk.Get(tenantID)
if err != nil {
logger.WithError(err).Error("Could not get volume for tenant")
return err
}
volumePath := vol.Path()
exportPath := path.Join(dfs.net... | [
"func",
"(",
"dfs",
"*",
"DistributedFilesystem",
")",
"VerifyTenantMounts",
"(",
"tenantID",
"string",
")",
"error",
"{",
"logger",
":=",
"plog",
".",
"WithField",
"(",
"\"",
"\"",
",",
"tenantID",
")",
"\n\n",
"vol",
",",
"err",
":=",
"dfs",
".",
"disk... | // Verifies that the mount points are correct. Returns nil if there are no problems; returns
// an error if we had problems getting the backing devices or if the devices don't match. | [
"Verifies",
"that",
"the",
"mount",
"points",
"are",
"correct",
".",
"Returns",
"nil",
"if",
"there",
"are",
"no",
"problems",
";",
"returns",
"an",
"error",
"if",
"we",
"had",
"problems",
"getting",
"the",
"backing",
"devices",
"or",
"if",
"the",
"devices... | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dfs/mounts.go#L34-L71 |
139,360 | control-center/serviced | cli/cmd/server.go | initServer | func (c *ServicedCli) initServer() {
c.app.Commands = append(c.app.Commands, cli.Command{
Name: "server",
Usage: "Starts serviced",
Description: "serviced server",
Action: c.cmdServer,
})
} | go | func (c *ServicedCli) initServer() {
c.app.Commands = append(c.app.Commands, cli.Command{
Name: "server",
Usage: "Starts serviced",
Description: "serviced server",
Action: c.cmdServer,
})
} | [
"func",
"(",
"c",
"*",
"ServicedCli",
")",
"initServer",
"(",
")",
"{",
"c",
".",
"app",
".",
"Commands",
"=",
"append",
"(",
"c",
".",
"app",
".",
"Commands",
",",
"cli",
".",
"Command",
"{",
"Name",
":",
"\"",
"\"",
",",
"Usage",
":",
"\"",
"... | // Initializer for serviced server | [
"Initializer",
"for",
"serviced",
"server"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/cmd/server.go#L27-L34 |
139,361 | control-center/serviced | cli/cmd/metric.go | initMetric | func (c *ServicedCli) initMetric() {
c.app.Commands = append(c.app.Commands, cli.Command{
Name: "metric",
Usage: "Interact with metrics",
Description: "",
Subcommands: []cli.Command{
{
Name: "push",
Usage: "Push a metric value",
Description: "serviced metric push MET... | go | func (c *ServicedCli) initMetric() {
c.app.Commands = append(c.app.Commands, cli.Command{
Name: "metric",
Usage: "Interact with metrics",
Description: "",
Subcommands: []cli.Command{
{
Name: "push",
Usage: "Push a metric value",
Description: "serviced metric push MET... | [
"func",
"(",
"c",
"*",
"ServicedCli",
")",
"initMetric",
"(",
")",
"{",
"c",
".",
"app",
".",
"Commands",
"=",
"append",
"(",
"c",
".",
"app",
".",
"Commands",
",",
"cli",
".",
"Command",
"{",
"Name",
":",
"\"",
"\"",
",",
"Usage",
":",
"\"",
"... | // Initializer for serviced metric | [
"Initializer",
"for",
"serviced",
"metric"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/cmd/metric.go#L22-L36 |
139,362 | control-center/serviced | dfs/nfs/mounts.go | String | func (options mountOptions) String() string {
vals := make([]string, len(options))
i := 0
for k, v := range options {
if len(v) == 0 {
vals[i] = k
} else {
vals[i] = k + "=" + v
}
i++
}
return strings.Join(vals, ",")
} | go | func (options mountOptions) String() string {
vals := make([]string, len(options))
i := 0
for k, v := range options {
if len(v) == 0 {
vals[i] = k
} else {
vals[i] = k + "=" + v
}
i++
}
return strings.Join(vals, ",")
} | [
"func",
"(",
"options",
"mountOptions",
")",
"String",
"(",
")",
"string",
"{",
"vals",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"options",
")",
")",
"\n",
"i",
":=",
"0",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"options",
"{",
... | // String prints options in manner that mimics fstab format; ie only append =val when
// val is not empty. | [
"String",
"prints",
"options",
"in",
"manner",
"that",
"mimics",
"fstab",
"format",
";",
"ie",
"only",
"append",
"=",
"val",
"when",
"val",
"is",
"not",
"empty",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dfs/nfs/mounts.go#L28-L40 |
139,363 | control-center/serviced | cli/cmd/docker.go | initDocker | func (c *ServicedCli) initDocker() {
c.app.Commands = append(c.app.Commands, cli.Command{
Name: "docker",
Usage: "Docker administration commands",
Description: "",
Subcommands: []cli.Command{
{
Name: "sync",
Usage: "serviced docker sync",
Description: "sync pushes all i... | go | func (c *ServicedCli) initDocker() {
c.app.Commands = append(c.app.Commands, cli.Command{
Name: "docker",
Usage: "Docker administration commands",
Description: "",
Subcommands: []cli.Command{
{
Name: "sync",
Usage: "serviced docker sync",
Description: "sync pushes all i... | [
"func",
"(",
"c",
"*",
"ServicedCli",
")",
"initDocker",
"(",
")",
"{",
"c",
".",
"app",
".",
"Commands",
"=",
"append",
"(",
"c",
".",
"app",
".",
"Commands",
",",
"cli",
".",
"Command",
"{",
"Name",
":",
"\"",
"\"",
",",
"Usage",
":",
"\"",
"... | // initDocker is the initializer for serviced docker | [
"initDocker",
"is",
"the",
"initializer",
"for",
"serviced",
"docker"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/cmd/docker.go#L25-L65 |
139,364 | control-center/serviced | cli/cmd/docker.go | cmdRegistrySync | func (c *ServicedCli) cmdRegistrySync(ctx *cli.Context) {
err := c.driver.RegistrySync()
if err != nil {
log.WithError(err).Fatal("Unable to sync Docker images to local registry")
}
} | go | func (c *ServicedCli) cmdRegistrySync(ctx *cli.Context) {
err := c.driver.RegistrySync()
if err != nil {
log.WithError(err).Fatal("Unable to sync Docker images to local registry")
}
} | [
"func",
"(",
"c",
"*",
"ServicedCli",
")",
"cmdRegistrySync",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"{",
"err",
":=",
"c",
".",
"driver",
".",
"RegistrySync",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"WithError",
"(",
"err"... | // serviced docker sync | [
"serviced",
"docker",
"sync"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/cmd/docker.go#L68-L73 |
139,365 | control-center/serviced | cli/cmd/docker.go | cmdResetRegistry | func (c *ServicedCli) cmdResetRegistry(ctx *cli.Context) {
if err := c.driver.ResetRegistry(); err != nil {
log.WithError(err).Fatal("Unable to reset local Docker registry")
}
} | go | func (c *ServicedCli) cmdResetRegistry(ctx *cli.Context) {
if err := c.driver.ResetRegistry(); err != nil {
log.WithError(err).Fatal("Unable to reset local Docker registry")
}
} | [
"func",
"(",
"c",
"*",
"ServicedCli",
")",
"cmdResetRegistry",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"{",
"if",
"err",
":=",
"c",
".",
"driver",
".",
"ResetRegistry",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"log",
".",
"WithError",
"(",
"err... | // serviced reset-registry | [
"serviced",
"reset",
"-",
"registry"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/cmd/docker.go#L76-L80 |
139,366 | control-center/serviced | cli/cmd/docker.go | cmdMigrateRegistry | func (c *ServicedCli) cmdMigrateRegistry(ctx *cli.Context) {
endpoint := ctx.String("registry")
override := ctx.Bool("override")
if err := c.driver.UpgradeRegistry(endpoint, override); err != nil {
log.WithFields(logrus.Fields{
"registry": endpoint,
"override": override,
}).WithError(err).Fatal("Unable to ... | go | func (c *ServicedCli) cmdMigrateRegistry(ctx *cli.Context) {
endpoint := ctx.String("registry")
override := ctx.Bool("override")
if err := c.driver.UpgradeRegistry(endpoint, override); err != nil {
log.WithFields(logrus.Fields{
"registry": endpoint,
"override": override,
}).WithError(err).Fatal("Unable to ... | [
"func",
"(",
"c",
"*",
"ServicedCli",
")",
"cmdMigrateRegistry",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"{",
"endpoint",
":=",
"ctx",
".",
"String",
"(",
"\"",
"\"",
")",
"\n",
"override",
":=",
"ctx",
".",
"Bool",
"(",
"\"",
"\"",
")",
"\n",... | // serviced migrate-registry | [
"serviced",
"migrate",
"-",
"registry"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/cmd/docker.go#L83-L92 |
139,367 | control-center/serviced | cli/cmd/docker.go | cmdDockerOverride | func (c *ServicedCli) cmdDockerOverride(ctx *cli.Context) {
args := ctx.Args()
if len(args) != 2 {
fmt.Printf("Incorrect Usage.\n\n")
cli.ShowCommandHelp(ctx, "override")
return
}
oldImage := args[0]
newImage := args[1]
if err := c.driver.DockerOverride(newImage, oldImage); err != nil {
fmt.Fprintln(os... | go | func (c *ServicedCli) cmdDockerOverride(ctx *cli.Context) {
args := ctx.Args()
if len(args) != 2 {
fmt.Printf("Incorrect Usage.\n\n")
cli.ShowCommandHelp(ctx, "override")
return
}
oldImage := args[0]
newImage := args[1]
if err := c.driver.DockerOverride(newImage, oldImage); err != nil {
fmt.Fprintln(os... | [
"func",
"(",
"c",
"*",
"ServicedCli",
")",
"cmdDockerOverride",
"(",
"ctx",
"*",
"cli",
".",
"Context",
")",
"{",
"args",
":=",
"ctx",
".",
"Args",
"(",
")",
"\n\n",
"if",
"len",
"(",
"args",
")",
"!=",
"2",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
... | // serviced docker override NEWIMAGE OLDIMAGE | [
"serviced",
"docker",
"override",
"NEWIMAGE",
"OLDIMAGE"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/cli/cmd/docker.go#L95-L110 |
139,368 | control-center/serviced | facade/publicendpoint.go | checkPort | func checkPort(network string, laddr string) error {
glog.V(2).Infof("Checking %s port %s", network, laddr)
listener, err := net.Listen(network, laddr)
if err != nil {
// Port isn't available.
glog.V(2).Infof("Port Listen failed; something else is using this port.")
return err
} else {
// Port was opened. M... | go | func checkPort(network string, laddr string) error {
glog.V(2).Infof("Checking %s port %s", network, laddr)
listener, err := net.Listen(network, laddr)
if err != nil {
// Port isn't available.
glog.V(2).Infof("Port Listen failed; something else is using this port.")
return err
} else {
// Port was opened. M... | [
"func",
"checkPort",
"(",
"network",
"string",
",",
"laddr",
"string",
")",
"error",
"{",
"glog",
".",
"V",
"(",
"2",
")",
".",
"Infof",
"(",
"\"",
"\"",
",",
"network",
",",
"laddr",
")",
"\n",
"listener",
",",
"err",
":=",
"net",
".",
"Listen",
... | // Try to open the port. If the port opens, we're good. Otherwise return the error. | [
"Try",
"to",
"open",
"the",
"port",
".",
"If",
"the",
"port",
"opens",
"we",
"re",
"good",
".",
"Otherwise",
"return",
"the",
"error",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/facade/publicendpoint.go#L132-L145 |
139,369 | control-center/serviced | facade/publicendpoint.go | RemovePublicEndpointPort | func (f *Facade) RemovePublicEndpointPort(ctx datastore.Context, serviceid, endpointName, portAddr string) error {
defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.RemovePublicEndpointPort"))
alog := f.auditLogger.Message(ctx, "Removing Public Endpoint Port").ID(serviceid).Action(audit.Update).
WithFields(logru... | go | func (f *Facade) RemovePublicEndpointPort(ctx datastore.Context, serviceid, endpointName, portAddr string) error {
defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.RemovePublicEndpointPort"))
alog := f.auditLogger.Message(ctx, "Removing Public Endpoint Port").ID(serviceid).Action(audit.Update).
WithFields(logru... | [
"func",
"(",
"f",
"*",
"Facade",
")",
"RemovePublicEndpointPort",
"(",
"ctx",
"datastore",
".",
"Context",
",",
"serviceid",
",",
"endpointName",
",",
"portAddr",
"string",
")",
"error",
"{",
"defer",
"ctx",
".",
"Metrics",
"(",
")",
".",
"Stop",
"(",
"c... | // Remove the port public endpoint from a service. | [
"Remove",
"the",
"port",
"public",
"endpoint",
"from",
"a",
"service",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/facade/publicendpoint.go#L148-L184 |
139,370 | control-center/serviced | facade/publicendpoint.go | SetAddressConfig | func (f *Facade) SetAddressConfig(ctx datastore.Context, serviceid, endpointName string, sa servicedefinition.AddressResourceConfig) error {
defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.SetAddressConfig"))
svc, err := f.GetService(ctx, serviceid)
if err != nil {
return err
}
alog := f.auditLogger... | go | func (f *Facade) SetAddressConfig(ctx datastore.Context, serviceid, endpointName string, sa servicedefinition.AddressResourceConfig) error {
defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.SetAddressConfig"))
svc, err := f.GetService(ctx, serviceid)
if err != nil {
return err
}
alog := f.auditLogger... | [
"func",
"(",
"f",
"*",
"Facade",
")",
"SetAddressConfig",
"(",
"ctx",
"datastore",
".",
"Context",
",",
"serviceid",
",",
"endpointName",
"string",
",",
"sa",
"servicedefinition",
".",
"AddressResourceConfig",
")",
"error",
"{",
"defer",
"ctx",
".",
"Metrics",... | // SetAddressConfig sets the AddressConfig to the endpoint | [
"SetAddressConfig",
"sets",
"the",
"AddressConfig",
"to",
"the",
"endpoint"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/facade/publicendpoint.go#L187-L212 |
139,371 | control-center/serviced | zzk/connection.go | InitializeLocalClient | func InitializeLocalClient(client *client.Client) {
managerLock.Lock()
defer managerLock.Unlock()
manager[local] = &zclient{
client: client,
connectionsLock: sync.RWMutex{},
connections: make(map[string]*zconn),
}
} | go | func InitializeLocalClient(client *client.Client) {
managerLock.Lock()
defer managerLock.Unlock()
manager[local] = &zclient{
client: client,
connectionsLock: sync.RWMutex{},
connections: make(map[string]*zconn),
}
} | [
"func",
"InitializeLocalClient",
"(",
"client",
"*",
"client",
".",
"Client",
")",
"{",
"managerLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"managerLock",
".",
"Unlock",
"(",
")",
"\n",
"manager",
"[",
"local",
"]",
"=",
"&",
"zclient",
"{",
"client",
... | // InitializeLocalClient initializes the local zookeeper client | [
"InitializeLocalClient",
"initializes",
"the",
"local",
"zookeeper",
"client"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/zzk/connection.go#L69-L77 |
139,372 | control-center/serviced | zzk/connection.go | GetLocalConnection | func GetLocalConnection(path string) (client.Connection, error) {
managerLock.RLock()
localclient, ok := manager[local]
managerLock.RUnlock()
if !ok || localclient.client == nil {
glog.Fatalf("zClient has not been initialized!")
}
return localclient.GetConnection(path)
} | go | func GetLocalConnection(path string) (client.Connection, error) {
managerLock.RLock()
localclient, ok := manager[local]
managerLock.RUnlock()
if !ok || localclient.client == nil {
glog.Fatalf("zClient has not been initialized!")
}
return localclient.GetConnection(path)
} | [
"func",
"GetLocalConnection",
"(",
"path",
"string",
")",
"(",
"client",
".",
"Connection",
",",
"error",
")",
"{",
"managerLock",
".",
"RLock",
"(",
")",
"\n",
"localclient",
",",
"ok",
":=",
"manager",
"[",
"local",
"]",
"\n",
"managerLock",
".",
"RUnl... | // GetLocalConnection acquires a connection from the local zookeeper client | [
"GetLocalConnection",
"acquires",
"a",
"connection",
"from",
"the",
"local",
"zookeeper",
"client"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/zzk/connection.go#L80-L88 |
139,373 | control-center/serviced | zzk/connection.go | InitializeRemoteClient | func InitializeRemoteClient(client *client.Client) {
managerLock.Lock()
defer managerLock.Unlock()
manager[remote] = &zclient{
client: client,
connectionsLock: sync.RWMutex{},
connections: make(map[string]*zconn),
}
} | go | func InitializeRemoteClient(client *client.Client) {
managerLock.Lock()
defer managerLock.Unlock()
manager[remote] = &zclient{
client: client,
connectionsLock: sync.RWMutex{},
connections: make(map[string]*zconn),
}
} | [
"func",
"InitializeRemoteClient",
"(",
"client",
"*",
"client",
".",
"Client",
")",
"{",
"managerLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"managerLock",
".",
"Unlock",
"(",
")",
"\n",
"manager",
"[",
"remote",
"]",
"=",
"&",
"zclient",
"{",
"client",... | // InitializeRemoteClient initializes the remote zookeeper client | [
"InitializeRemoteClient",
"initializes",
"the",
"remote",
"zookeeper",
"client"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/zzk/connection.go#L91-L99 |
139,374 | control-center/serviced | zzk/connection.go | GetRemoteConnection | func GetRemoteConnection(path string) (client.Connection, error) {
managerLock.RLock()
remoteclient, ok := manager[remote]
managerLock.RUnlock()
if !ok || remoteclient.client == nil {
return nil, ErrNotInitialized
}
return remoteclient.GetConnection(path)
} | go | func GetRemoteConnection(path string) (client.Connection, error) {
managerLock.RLock()
remoteclient, ok := manager[remote]
managerLock.RUnlock()
if !ok || remoteclient.client == nil {
return nil, ErrNotInitialized
}
return remoteclient.GetConnection(path)
} | [
"func",
"GetRemoteConnection",
"(",
"path",
"string",
")",
"(",
"client",
".",
"Connection",
",",
"error",
")",
"{",
"managerLock",
".",
"RLock",
"(",
")",
"\n",
"remoteclient",
",",
"ok",
":=",
"manager",
"[",
"remote",
"]",
"\n",
"managerLock",
".",
"R... | // GetRemoteConnection acquires a connection from the remote zookeeper client | [
"GetRemoteConnection",
"acquires",
"a",
"connection",
"from",
"the",
"remote",
"zookeeper",
"client"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/zzk/connection.go#L102-L111 |
139,375 | control-center/serviced | zzk/connection.go | Connect | func Connect(path string, getConnection GetConnection) <-chan client.Connection {
connc := make(chan client.Connection, 1)
go func() {
if c, err := getConnection(path); err == ErrNotInitialized {
// (remote) connection not initialized, so don't send anything
return
} else if err != nil {
close(connc)
}... | go | func Connect(path string, getConnection GetConnection) <-chan client.Connection {
connc := make(chan client.Connection, 1)
go func() {
if c, err := getConnection(path); err == ErrNotInitialized {
// (remote) connection not initialized, so don't send anything
return
} else if err != nil {
close(connc)
}... | [
"func",
"Connect",
"(",
"path",
"string",
",",
"getConnection",
"GetConnection",
")",
"<-",
"chan",
"client",
".",
"Connection",
"{",
"connc",
":=",
"make",
"(",
"chan",
"client",
".",
"Connection",
",",
"1",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"if... | // Connect generates a client connection asynchronously | [
"Connect",
"generates",
"a",
"client",
"connection",
"asynchronously"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/zzk/connection.go#L114-L127 |
139,376 | control-center/serviced | zzk/connection.go | ShutdownConnections | func ShutdownConnections() {
managerLock.Lock()
defer managerLock.Unlock()
for _, client := range manager {
client.Shutdown()
}
} | go | func ShutdownConnections() {
managerLock.Lock()
defer managerLock.Unlock()
for _, client := range manager {
client.Shutdown()
}
} | [
"func",
"ShutdownConnections",
"(",
")",
"{",
"managerLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"managerLock",
".",
"Unlock",
"(",
")",
"\n",
"for",
"_",
",",
"client",
":=",
"range",
"manager",
"{",
"client",
".",
"Shutdown",
"(",
")",
"\n",
"}",
... | // ShutdownConnections closes all local and remote zookeeper connections | [
"ShutdownConnections",
"closes",
"all",
"local",
"and",
"remote",
"zookeeper",
"connections"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/zzk/connection.go#L130-L136 |
139,377 | control-center/serviced | zzk/connection.go | GetConnection | func (zclient *zclient) GetConnection(path string) (client.Connection, error) {
zclient.connectionsLock.Lock()
defer zclient.connectionsLock.Unlock()
if _, ok := zclient.connections[path]; !ok {
zclient.connections[path] = newzconn(zclient.client, path)
}
zconn := zclient.connections[path]
return zconn.connect(... | go | func (zclient *zclient) GetConnection(path string) (client.Connection, error) {
zclient.connectionsLock.Lock()
defer zclient.connectionsLock.Unlock()
if _, ok := zclient.connections[path]; !ok {
zclient.connections[path] = newzconn(zclient.client, path)
}
zconn := zclient.connections[path]
return zconn.connect(... | [
"func",
"(",
"zclient",
"*",
"zclient",
")",
"GetConnection",
"(",
"path",
"string",
")",
"(",
"client",
".",
"Connection",
",",
"error",
")",
"{",
"zclient",
".",
"connectionsLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"zclient",
".",
"connectionsLock",
... | // GetConnection creates a new path-based connection or acquires a stored connection | [
"GetConnection",
"creates",
"a",
"new",
"path",
"-",
"based",
"connection",
"or",
"acquires",
"a",
"stored",
"connection"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/zzk/connection.go#L139-L147 |
139,378 | control-center/serviced | zzk/connection.go | Shutdown | func (zclient *zclient) Shutdown() {
zclient.connectionsLock.RLock()
defer zclient.connectionsLock.RUnlock()
for _, zconn := range zclient.connections {
zconn.shutdown()
}
} | go | func (zclient *zclient) Shutdown() {
zclient.connectionsLock.RLock()
defer zclient.connectionsLock.RUnlock()
for _, zconn := range zclient.connections {
zconn.shutdown()
}
} | [
"func",
"(",
"zclient",
"*",
"zclient",
")",
"Shutdown",
"(",
")",
"{",
"zclient",
".",
"connectionsLock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"zclient",
".",
"connectionsLock",
".",
"RUnlock",
"(",
")",
"\n",
"for",
"_",
",",
"zconn",
":=",
"range"... | // Shutdown shuts down all open connections for a client | [
"Shutdown",
"shuts",
"down",
"all",
"open",
"connections",
"for",
"a",
"client"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/zzk/connection.go#L150-L156 |
139,379 | control-center/serviced | zzk/connection.go | newzconn | func newzconn(zclient *client.Client, path string) *zconn {
zconn := &zconn{
client: zclient,
connC: make(chan chan<- client.Connection),
shutdownC: make(chan struct{}),
}
go zconn.monitor(path)
return zconn
} | go | func newzconn(zclient *client.Client, path string) *zconn {
zconn := &zconn{
client: zclient,
connC: make(chan chan<- client.Connection),
shutdownC: make(chan struct{}),
}
go zconn.monitor(path)
return zconn
} | [
"func",
"newzconn",
"(",
"zclient",
"*",
"client",
".",
"Client",
",",
"path",
"string",
")",
"*",
"zconn",
"{",
"zconn",
":=",
"&",
"zconn",
"{",
"client",
":",
"zclient",
",",
"connC",
":",
"make",
"(",
"chan",
"chan",
"<-",
"client",
".",
"Connect... | // newzconn instantiates a new connection listener | [
"newzconn",
"instantiates",
"a",
"new",
"connection",
"listener"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/zzk/connection.go#L159-L168 |
139,380 | control-center/serviced | zzk/connection.go | monitor | func (zconn *zconn) monitor(path string) {
var (
connC chan<- client.Connection
conn client.Connection
err error
d *client.Backoff
)
defer func() {
if conn != nil {
conn.Close()
}
}()
d = newDelay(time.Second)
for {
// wait for someone to request a connection, or shutdown
select {
c... | go | func (zconn *zconn) monitor(path string) {
var (
connC chan<- client.Connection
conn client.Connection
err error
d *client.Backoff
)
defer func() {
if conn != nil {
conn.Close()
}
}()
d = newDelay(time.Second)
for {
// wait for someone to request a connection, or shutdown
select {
c... | [
"func",
"(",
"zconn",
"*",
"zconn",
")",
"monitor",
"(",
"path",
"string",
")",
"{",
"var",
"(",
"connC",
"chan",
"<-",
"client",
".",
"Connection",
"\n",
"conn",
"client",
".",
"Connection",
"\n",
"err",
"error",
"\n",
"d",
"*",
"client",
".",
"Back... | // monitor checks for changes in a path-based connection | [
"monitor",
"checks",
"for",
"changes",
"in",
"a",
"path",
"-",
"based",
"connection"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/zzk/connection.go#L171-L223 |
139,381 | control-center/serviced | zzk/connection.go | connect | func (zconn *zconn) connect(timeout time.Duration) (client.Connection, error) {
connC := make(chan client.Connection, 1)
zconn.connC <- connC
select {
case conn := <-connC:
return conn, nil
case <-time.After(timeout):
glog.Warningf("timed out waiting for connection")
return nil, ErrTimeout
case <-zconn.shut... | go | func (zconn *zconn) connect(timeout time.Duration) (client.Connection, error) {
connC := make(chan client.Connection, 1)
zconn.connC <- connC
select {
case conn := <-connC:
return conn, nil
case <-time.After(timeout):
glog.Warningf("timed out waiting for connection")
return nil, ErrTimeout
case <-zconn.shut... | [
"func",
"(",
"zconn",
"*",
"zconn",
")",
"connect",
"(",
"timeout",
"time",
".",
"Duration",
")",
"(",
"client",
".",
"Connection",
",",
"error",
")",
"{",
"connC",
":=",
"make",
"(",
"chan",
"client",
".",
"Connection",
",",
"1",
")",
"\n",
"zconn",... | // connect returns a connection object or times out trying | [
"connect",
"returns",
"a",
"connection",
"object",
"or",
"times",
"out",
"trying"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/zzk/connection.go#L226-L239 |
139,382 | control-center/serviced | facade/instance.go | getInstance | func (f *Facade) getInstance(ctx datastore.Context, hst host.Host, svc service.Service, imageUUID string, state zkservice.State) (*service.Instance, error) {
logger := plog.WithFields(log.Fields{
"hostid": state.HostID,
"serviceid": state.ServiceID,
"instanceid": state.InstanceID,
})
// get the current s... | go | func (f *Facade) getInstance(ctx datastore.Context, hst host.Host, svc service.Service, imageUUID string, state zkservice.State) (*service.Instance, error) {
logger := plog.WithFields(log.Fields{
"hostid": state.HostID,
"serviceid": state.ServiceID,
"instanceid": state.InstanceID,
})
// get the current s... | [
"func",
"(",
"f",
"*",
"Facade",
")",
"getInstance",
"(",
"ctx",
"datastore",
".",
"Context",
",",
"hst",
"host",
".",
"Host",
",",
"svc",
"service",
".",
"Service",
",",
"imageUUID",
"string",
",",
"state",
"zkservice",
".",
"State",
")",
"(",
"*",
... | // getInstance calculates the fields of the service instance object. | [
"getInstance",
"calculates",
"the",
"fields",
"of",
"the",
"service",
"instance",
"object",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/facade/instance.go#L219-L261 |
139,383 | control-center/serviced | facade/instance.go | getImageUUID | func (f *Facade) getImageUUID(ctx datastore.Context, imageName string) (string, error) {
logger := plog.WithField("imagename", imageName)
if imageName == "" {
logger.Debug("Image name not specified")
return "", nil
}
imageID, err := commons.ParseImageID(imageName)
if err != nil {
logger.WithError(err).Debu... | go | func (f *Facade) getImageUUID(ctx datastore.Context, imageName string) (string, error) {
logger := plog.WithField("imagename", imageName)
if imageName == "" {
logger.Debug("Image name not specified")
return "", nil
}
imageID, err := commons.ParseImageID(imageName)
if err != nil {
logger.WithError(err).Debu... | [
"func",
"(",
"f",
"*",
"Facade",
")",
"getImageUUID",
"(",
"ctx",
"datastore",
".",
"Context",
",",
"imageName",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"logger",
":=",
"plog",
".",
"WithField",
"(",
"\"",
"\"",
",",
"imageName",
")",
"... | // getImageUUID returns the hash of the latest image given the name | [
"getImageUUID",
"returns",
"the",
"hash",
"of",
"the",
"latest",
"image",
"given",
"the",
"name"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/facade/instance.go#L264-L289 |
139,384 | control-center/serviced | facade/instance.go | getInstanceHealth | func (f *Facade) getInstanceHealth(svch *service.ServiceHealth, instanceID int) map[string]health.Status {
hstats := make(map[string]health.Status)
for name := range svch.HealthChecks {
key := health.HealthStatusKey{
ServiceID: svch.ID,
InstanceID: instanceID,
HealthCheckName: name,
}
result... | go | func (f *Facade) getInstanceHealth(svch *service.ServiceHealth, instanceID int) map[string]health.Status {
hstats := make(map[string]health.Status)
for name := range svch.HealthChecks {
key := health.HealthStatusKey{
ServiceID: svch.ID,
InstanceID: instanceID,
HealthCheckName: name,
}
result... | [
"func",
"(",
"f",
"*",
"Facade",
")",
"getInstanceHealth",
"(",
"svch",
"*",
"service",
".",
"ServiceHealth",
",",
"instanceID",
"int",
")",
"map",
"[",
"string",
"]",
"health",
".",
"Status",
"{",
"hstats",
":=",
"make",
"(",
"map",
"[",
"string",
"]"... | // getInstanceHealth returns the health of the instance of a given service | [
"getInstanceHealth",
"returns",
"the",
"health",
"of",
"the",
"instance",
"of",
"a",
"given",
"service"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/facade/instance.go#L385-L401 |
139,385 | control-center/serviced | facade/instance.go | GetHostStrategyInstances | func (f *Facade) GetHostStrategyInstances(ctx datastore.Context, hosts []host.Host) ([]*service.StrategyInstance, error) {
defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.GetHostStrategyInstances"))
svcMap := make(map[string]service.StrategyInstance)
insts := make([]*service.StrategyInstance, 0)
for _, host ... | go | func (f *Facade) GetHostStrategyInstances(ctx datastore.Context, hosts []host.Host) ([]*service.StrategyInstance, error) {
defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.GetHostStrategyInstances"))
svcMap := make(map[string]service.StrategyInstance)
insts := make([]*service.StrategyInstance, 0)
for _, host ... | [
"func",
"(",
"f",
"*",
"Facade",
")",
"GetHostStrategyInstances",
"(",
"ctx",
"datastore",
".",
"Context",
",",
"hosts",
"[",
"]",
"host",
".",
"Host",
")",
"(",
"[",
"]",
"*",
"service",
".",
"StrategyInstance",
",",
"error",
")",
"{",
"defer",
"ctx",... | // GetHostStrategyInstances returns the strategy objects of all the instances
// running on a host. | [
"GetHostStrategyInstances",
"returns",
"the",
"strategy",
"objects",
"of",
"all",
"the",
"instances",
"running",
"on",
"a",
"host",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/facade/instance.go#L405-L457 |
139,386 | control-center/serviced | facade/instance.go | StopServiceInstance | func (f *Facade) StopServiceInstance(ctx datastore.Context, serviceID string, instanceID int) error {
defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.StopServiceInstance"))
logger := plog.WithFields(log.Fields{
"serviceid": serviceID,
"instanceid": instanceID,
})
svc, err := f.serviceStore.Get(ctx, servi... | go | func (f *Facade) StopServiceInstance(ctx datastore.Context, serviceID string, instanceID int) error {
defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.StopServiceInstance"))
logger := plog.WithFields(log.Fields{
"serviceid": serviceID,
"instanceid": instanceID,
})
svc, err := f.serviceStore.Get(ctx, servi... | [
"func",
"(",
"f",
"*",
"Facade",
")",
"StopServiceInstance",
"(",
"ctx",
"datastore",
".",
"Context",
",",
"serviceID",
"string",
",",
"instanceID",
"int",
")",
"error",
"{",
"defer",
"ctx",
".",
"Metrics",
"(",
")",
".",
"Stop",
"(",
"ctx",
".",
"Metr... | // StopServiceInstance stops a particular service instance | [
"StopServiceInstance",
"stops",
"a",
"particular",
"service",
"instance"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/facade/instance.go#L460-L480 |
139,387 | control-center/serviced | facade/instance.go | LocateServiceInstance | func (f *Facade) LocateServiceInstance(ctx datastore.Context, serviceID string, instanceID int) (*service.LocationInstance, error) {
defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.LocateServiceInstance"))
logger := plog.WithFields(log.Fields{
"serviceid": serviceID,
"instanceid": instanceID,
})
svc, err... | go | func (f *Facade) LocateServiceInstance(ctx datastore.Context, serviceID string, instanceID int) (*service.LocationInstance, error) {
defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.LocateServiceInstance"))
logger := plog.WithFields(log.Fields{
"serviceid": serviceID,
"instanceid": instanceID,
})
svc, err... | [
"func",
"(",
"f",
"*",
"Facade",
")",
"LocateServiceInstance",
"(",
"ctx",
"datastore",
".",
"Context",
",",
"serviceID",
"string",
",",
"instanceID",
"int",
")",
"(",
"*",
"service",
".",
"LocationInstance",
",",
"error",
")",
"{",
"defer",
"ctx",
".",
... | // LocateServiceInstance returns host and container information about a service
// instance | [
"LocateServiceInstance",
"returns",
"host",
"and",
"container",
"information",
"about",
"a",
"service",
"instance"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/facade/instance.go#L484-L509 |
139,388 | control-center/serviced | facade/instance.go | SendDockerAction | func (f *Facade) SendDockerAction(ctx datastore.Context, serviceID string, instanceID int, action string, args []string) error {
defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.SendDockerAction"))
logger := plog.WithFields(log.Fields{
"serviceid": serviceID,
"instanceID": instanceID,
"action": action,... | go | func (f *Facade) SendDockerAction(ctx datastore.Context, serviceID string, instanceID int, action string, args []string) error {
defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.SendDockerAction"))
logger := plog.WithFields(log.Fields{
"serviceid": serviceID,
"instanceID": instanceID,
"action": action,... | [
"func",
"(",
"f",
"*",
"Facade",
")",
"SendDockerAction",
"(",
"ctx",
"datastore",
".",
"Context",
",",
"serviceID",
"string",
",",
"instanceID",
"int",
",",
"action",
"string",
",",
"args",
"[",
"]",
"string",
")",
"error",
"{",
"defer",
"ctx",
".",
"... | // SendDockerAction locates a service instance and sends an action to it | [
"SendDockerAction",
"locates",
"a",
"service",
"instance",
"and",
"sends",
"an",
"action",
"to",
"it"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/facade/instance.go#L512-L565 |
139,389 | control-center/serviced | logging/logging.go | PackageLogger | func PackageLogger() *logri.Logger {
pc := make([]uintptr, 3, 3)
count := runtime.Callers(2, pc)
for i := 0; i < count; i++ {
fu := runtime.FuncForPC(pc[i])
name := fu.Name()
if strings.Contains(name, prefix) {
return logri.GetLogger(pkgFromFunc(name))
}
}
return logri.GetLogger("")
} | go | func PackageLogger() *logri.Logger {
pc := make([]uintptr, 3, 3)
count := runtime.Callers(2, pc)
for i := 0; i < count; i++ {
fu := runtime.FuncForPC(pc[i])
name := fu.Name()
if strings.Contains(name, prefix) {
return logri.GetLogger(pkgFromFunc(name))
}
}
return logri.GetLogger("")
} | [
"func",
"PackageLogger",
"(",
")",
"*",
"logri",
".",
"Logger",
"{",
"pc",
":=",
"make",
"(",
"[",
"]",
"uintptr",
",",
"3",
",",
"3",
")",
"\n",
"count",
":=",
"runtime",
".",
"Callers",
"(",
"2",
",",
"pc",
")",
"\n",
"for",
"i",
":=",
"0",
... | // PackageLogger returns a logger for a given package. | [
"PackageLogger",
"returns",
"a",
"logger",
"for",
"a",
"given",
"package",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/logging/logging.go#L27-L38 |
139,390 | control-center/serviced | utils/tcp.go | UnpackTCPAddress | func UnpackTCPAddress(packed []byte) (ip string, port uint16) {
// Read off the port
buf := bytes.NewBuffer(packed)
binary.Read(buf, endian, &port)
// Read off the IP
ipbytes := make([]byte, 4)
buf.Read(ipbytes)
ip = net.IP(ipbytes).String()
return
} | go | func UnpackTCPAddress(packed []byte) (ip string, port uint16) {
// Read off the port
buf := bytes.NewBuffer(packed)
binary.Read(buf, endian, &port)
// Read off the IP
ipbytes := make([]byte, 4)
buf.Read(ipbytes)
ip = net.IP(ipbytes).String()
return
} | [
"func",
"UnpackTCPAddress",
"(",
"packed",
"[",
"]",
"byte",
")",
"(",
"ip",
"string",
",",
"port",
"uint16",
")",
"{",
"// Read off the port",
"buf",
":=",
"bytes",
".",
"NewBuffer",
"(",
"packed",
")",
"\n",
"binary",
".",
"Read",
"(",
"buf",
",",
"e... | // UnpackTCPAddress unpacks a 6-byte representation of a TCP address produced
// by PackTCPAddress into an IP and port | [
"UnpackTCPAddress",
"unpacks",
"a",
"6",
"-",
"byte",
"representation",
"of",
"a",
"TCP",
"address",
"produced",
"by",
"PackTCPAddress",
"into",
"an",
"IP",
"and",
"port"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/utils/tcp.go#L70-L82 |
139,391 | control-center/serviced | rpc/master/volume_client.go | GetVolumeStatus | func (c *Client) GetVolumeStatus() (*volume.Statuses, error) {
response := &volume.Statuses{}
if err := c.call("GetVolumeStatus", empty, response); err != nil {
return nil, err
}
return response, nil
} | go | func (c *Client) GetVolumeStatus() (*volume.Statuses, error) {
response := &volume.Statuses{}
if err := c.call("GetVolumeStatus", empty, response); err != nil {
return nil, err
}
return response, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetVolumeStatus",
"(",
")",
"(",
"*",
"volume",
".",
"Statuses",
",",
"error",
")",
"{",
"response",
":=",
"&",
"volume",
".",
"Statuses",
"{",
"}",
"\n",
"if",
"err",
":=",
"c",
".",
"call",
"(",
"\"",
"\""... | // GetVolumeStatus gets status information for the given volume or nil | [
"GetVolumeStatus",
"gets",
"status",
"information",
"for",
"the",
"given",
"volume",
"or",
"nil"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/rpc/master/volume_client.go#L21-L27 |
139,392 | control-center/serviced | facade/servicepath_cache.go | RemoveIfParentChanged | func (sc *serviceCache) RemoveIfParentChanged(serviceID string, parentID string) bool {
cachedSvc, ok := sc.lookUpService(serviceID)
if !ok || cachedSvc.parentID == parentID {
return false
}
sc.mutex.Lock()
defer sc.mutex.Unlock()
for key, value := range sc.paths {
if strings.HasPrefix(value.servicePath, cac... | go | func (sc *serviceCache) RemoveIfParentChanged(serviceID string, parentID string) bool {
cachedSvc, ok := sc.lookUpService(serviceID)
if !ok || cachedSvc.parentID == parentID {
return false
}
sc.mutex.Lock()
defer sc.mutex.Unlock()
for key, value := range sc.paths {
if strings.HasPrefix(value.servicePath, cac... | [
"func",
"(",
"sc",
"*",
"serviceCache",
")",
"RemoveIfParentChanged",
"(",
"serviceID",
"string",
",",
"parentID",
"string",
")",
"bool",
"{",
"cachedSvc",
",",
"ok",
":=",
"sc",
".",
"lookUpService",
"(",
"serviceID",
")",
"\n",
"if",
"!",
"ok",
"||",
"... | // RemoveIfParentChanged will remove all entries from the cache for this service and its children if the
// specified service's parentID is different from the cached value.
// Returns true if one or more entries was removed from the cache; false otherwise. | [
"RemoveIfParentChanged",
"will",
"remove",
"all",
"entries",
"from",
"the",
"cache",
"for",
"this",
"service",
"and",
"its",
"children",
"if",
"the",
"specified",
"service",
"s",
"parentID",
"is",
"different",
"from",
"the",
"cached",
"value",
".",
"Returns",
... | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/facade/servicepath_cache.go#L88-L102 |
139,393 | control-center/serviced | commons/subprocess/instance.go | New | func New(sigtermTimeout time.Duration, env []string, command string, args ...string) (*Instance, chan error, error) {
s := &Instance{
command: command,
args: args,
env: env,
commandExit: make(chan error, 1),
sigtermTimeout: sigtermTimeout,
signalChan: make(chan os.Signal,... | go | func New(sigtermTimeout time.Duration, env []string, command string, args ...string) (*Instance, chan error, error) {
s := &Instance{
command: command,
args: args,
env: env,
commandExit: make(chan error, 1),
sigtermTimeout: sigtermTimeout,
signalChan: make(chan os.Signal,... | [
"func",
"New",
"(",
"sigtermTimeout",
"time",
".",
"Duration",
",",
"env",
"[",
"]",
"string",
",",
"command",
"string",
",",
"args",
"...",
"string",
")",
"(",
"*",
"Instance",
",",
"chan",
"error",
",",
"error",
")",
"{",
"s",
":=",
"&",
"Instance"... | // New creates a subprocess.Instance | [
"New",
"creates",
"a",
"subprocess",
".",
"Instance"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/commons/subprocess/instance.go#L40-L51 |
139,394 | control-center/serviced | commons/subprocess/instance.go | Notify | func (s *Instance) Notify(sig os.Signal) {
glog.V(1).Infof("Notify: sending signal %v", sig)
select {
case s.signalChan <- sig:
glog.V(1).Infof("Notify: sent signal %v", sig)
default:
// This may happen if we're trying to kill a process that has already died. The controller will first send
// SIGTERM, then it... | go | func (s *Instance) Notify(sig os.Signal) {
glog.V(1).Infof("Notify: sending signal %v", sig)
select {
case s.signalChan <- sig:
glog.V(1).Infof("Notify: sent signal %v", sig)
default:
// This may happen if we're trying to kill a process that has already died. The controller will first send
// SIGTERM, then it... | [
"func",
"(",
"s",
"*",
"Instance",
")",
"Notify",
"(",
"sig",
"os",
".",
"Signal",
")",
"{",
"glog",
".",
"V",
"(",
"1",
")",
".",
"Infof",
"(",
"\"",
"\"",
",",
"sig",
")",
"\n",
"select",
"{",
"case",
"s",
".",
"signalChan",
"<-",
"sig",
":... | // Notify sends the sig to the subprocess instance. | [
"Notify",
"sends",
"the",
"sig",
"to",
"the",
"subprocess",
"instance",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/commons/subprocess/instance.go#L54-L64 |
139,395 | control-center/serviced | commons/subprocess/instance.go | Close | func (s *Instance) Close() error {
if s == nil {
return nil
}
s.closeLock.Lock()
defer s.closeLock.Unlock()
if s.closing == nil {
return errors.New("subprocess instance already closed")
}
errc := make(chan error)
s.closing <- errc
err := <-errc
s.closing = nil
return err
} | go | func (s *Instance) Close() error {
if s == nil {
return nil
}
s.closeLock.Lock()
defer s.closeLock.Unlock()
if s.closing == nil {
return errors.New("subprocess instance already closed")
}
errc := make(chan error)
s.closing <- errc
err := <-errc
s.closing = nil
return err
} | [
"func",
"(",
"s",
"*",
"Instance",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"s",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"s",
".",
"closeLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"closeLock",
".",
"Unlock",
"(",
")",... | // Close signals the subprocess to shutdown via sigterm. If sigterm fails to shutdown
// withing the s.timeout, a sigkill is issued. | [
"Close",
"signals",
"the",
"subprocess",
"to",
"shutdown",
"via",
"sigterm",
".",
"If",
"sigterm",
"fails",
"to",
"shutdown",
"withing",
"the",
"s",
".",
"timeout",
"a",
"sigkill",
"is",
"issued",
"."
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/commons/subprocess/instance.go#L68-L82 |
139,396 | control-center/serviced | rpc/master/servicetemplate_client.go | RemoveServiceTemplate | func (c *Client) RemoveServiceTemplate(serviceTemplateID string) error {
if err := c.call("RemoveServiceTemplate", serviceTemplateID, nil); err != nil {
return err
}
return nil
} | go | func (c *Client) RemoveServiceTemplate(serviceTemplateID string) error {
if err := c.call("RemoveServiceTemplate", serviceTemplateID, nil); err != nil {
return err
}
return nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"RemoveServiceTemplate",
"(",
"serviceTemplateID",
"string",
")",
"error",
"{",
"if",
"err",
":=",
"c",
".",
"call",
"(",
"\"",
"\"",
",",
"serviceTemplateID",
",",
"nil",
")",
";",
"err",
"!=",
"nil",
"{",
"return... | // Remove a service Template | [
"Remove",
"a",
"service",
"Template"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/rpc/master/servicetemplate_client.go#L39-L45 |
139,397 | control-center/serviced | rpc/master/servicetemplate_client.go | DeployTemplate | func (c *Client) DeployTemplate(request servicetemplate.ServiceTemplateDeploymentRequest) (tenantIDs []string, err error){
response := []string{}
if err := c.call("DeployTemplate", request, &response); err != nil {
return nil, err
}
return response, nil
} | go | func (c *Client) DeployTemplate(request servicetemplate.ServiceTemplateDeploymentRequest) (tenantIDs []string, err error){
response := []string{}
if err := c.call("DeployTemplate", request, &response); err != nil {
return nil, err
}
return response, nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"DeployTemplate",
"(",
"request",
"servicetemplate",
".",
"ServiceTemplateDeploymentRequest",
")",
"(",
"tenantIDs",
"[",
"]",
"string",
",",
"err",
"error",
")",
"{",
"response",
":=",
"[",
"]",
"string",
"{",
"}",
"\... | // Deploy a service Template | [
"Deploy",
"a",
"service",
"Template"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/rpc/master/servicetemplate_client.go#L48-L55 |
139,398 | control-center/serviced | dfs/backup.go | savePipe | func savePipe(do func(w io.Writer) error) (*io.PipeReader, <-chan error) {
r, w := io.Pipe()
errchan := make(chan error)
go func() {
err := do(w)
w.Close()
errchan <- err
}()
return r, errchan
} | go | func savePipe(do func(w io.Writer) error) (*io.PipeReader, <-chan error) {
r, w := io.Pipe()
errchan := make(chan error)
go func() {
err := do(w)
w.Close()
errchan <- err
}()
return r, errchan
} | [
"func",
"savePipe",
"(",
"do",
"func",
"(",
"w",
"io",
".",
"Writer",
")",
"error",
")",
"(",
"*",
"io",
".",
"PipeReader",
",",
"<-",
"chan",
"error",
")",
"{",
"r",
",",
"w",
":=",
"io",
".",
"Pipe",
"(",
")",
"\n",
"errchan",
":=",
"make",
... | // savePipe is a generic io pipe that returns the reader | [
"savePipe",
"is",
"a",
"generic",
"io",
"pipe",
"that",
"returns",
"the",
"reader"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dfs/backup.go#L178-L187 |
139,399 | control-center/serviced | dfs/backup.go | dockerSavePipe | func (dfs *DistributedFilesystem) dockerSavePipe(images ...string) (*io.PipeReader, <-chan error) {
return savePipe(func(w io.Writer) error {
return dfs.docker.SaveImages(images, w)
})
} | go | func (dfs *DistributedFilesystem) dockerSavePipe(images ...string) (*io.PipeReader, <-chan error) {
return savePipe(func(w io.Writer) error {
return dfs.docker.SaveImages(images, w)
})
} | [
"func",
"(",
"dfs",
"*",
"DistributedFilesystem",
")",
"dockerSavePipe",
"(",
"images",
"...",
"string",
")",
"(",
"*",
"io",
".",
"PipeReader",
",",
"<-",
"chan",
"error",
")",
"{",
"return",
"savePipe",
"(",
"func",
"(",
"w",
"io",
".",
"Writer",
")"... | // dockerSavePipe streams the tar archive output by Docker to pipe's stdout | [
"dockerSavePipe",
"streams",
"the",
"tar",
"archive",
"output",
"by",
"Docker",
"to",
"pipe",
"s",
"stdout"
] | 7028f598e6a224b4d421e09cb9b582ad7d000304 | https://github.com/control-center/serviced/blob/7028f598e6a224b4d421e09cb9b582ad7d000304/dfs/backup.go#L190-L194 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.