// registrationInfo returns a ServiceRegistration populated with vcsim's OptionManager settings.
// The complete list can be captured using: govc sso.service.ls -dump
775985
func registrationInfo() []types.LookupServiceRegistrationInfo {
	vc := simulator.Map.Get(vim25.ServiceInstance).(*simulator.ServiceInstance)
	setting := simulator.Map.OptionManager().Setting
	sm := simulator.Map.SessionManager()
	opts := make(map[string]string, len(setting))

	for _, o := range setting {
		opt := o.GetOptionValue()
		if val, ok := opt.Value.(string); ok {
			opts[opt.Key] = val
		}
	}

	trust := []string{""}
	if sm.TLSCert != nil {
		trust[0] = sm.TLSCert()
	}
	sdk := opts["vcsim.server.url"] + vim25.Path
	admin := opts["config.vpxd.sso.default.admin"]
	owner := opts["config.vpxd.sso.solutionUser.name"]
	instance := opts["VirtualCenter.InstanceName"]

	// Real PSC has 30+ services by default, we just provide a few that are useful for vmomi interaction..
	return []types.LookupServiceRegistrationInfo{
		{
			LookupServiceRegistrationCommonServiceInfo: types.LookupServiceRegistrationCommonServiceInfo{
				LookupServiceRegistrationMutableServiceInfo: types.LookupServiceRegistrationMutableServiceInfo{
					ServiceVersion: lookup.Version,
					ServiceEndpoints: []types.LookupServiceRegistrationEndpoint{
						{
							Url: opts["config.vpxd.sso.sts.uri"],
							EndpointType: types.LookupServiceRegistrationEndpointType{
								Protocol: "wsTrust",
								Type:     "com.vmware.cis.cs.identity.sso",
							},
							SslTrust: trust,
						},
					},
				},
				OwnerId: admin,
				ServiceType: types.LookupServiceRegistrationServiceType{
					Product: "com.vmware.cis",
					Type:    "sso:sts",
				},
			},
			ServiceId: siteID + ":" + uuid.New().String(),
			SiteId:    siteID,
		},
		{
			LookupServiceRegistrationCommonServiceInfo: types.LookupServiceRegistrationCommonServiceInfo{
				LookupServiceRegistrationMutableServiceInfo: types.LookupServiceRegistrationMutableServiceInfo{
					ServiceVersion: vim25.Version,
					ServiceEndpoints: []types.LookupServiceRegistrationEndpoint{
						{
							Url: sdk,
							EndpointType: types.LookupServiceRegistrationEndpointType{
								Protocol: "vmomi",
								Type:     "com.vmware.vim",
							},
							SslTrust: trust,
							EndpointAttributes: []types.LookupServiceRegistrationAttribute{
								{
									Key:   "cis.common.ep.localurl",
									Value: sdk,
								},
							},
						},
					},
					ServiceAttributes: []types.LookupServiceRegistrationAttribute{
						{
							Key:   "com.vmware.cis.cm.GroupInternalId",
							Value: "com.vmware.vim.vcenter",
						},
						{
							Key:   "com.vmware.vim.vcenter.instanceName",
							Value: instance,
						},
						{
							Key:   "com.vmware.cis.cm.ControlScript",
							Value: "service-control-default-vmon",
						},
						{
							Key:   "com.vmware.cis.cm.HostId",
							Value: uuid.New().String(),
						},
					},
					ServiceNameResourceKey:        "AboutInfo.vpx.name",
					ServiceDescriptionResourceKey: "AboutInfo.vpx.name",
				},
				OwnerId: owner,
				ServiceType: types.LookupServiceRegistrationServiceType{
					Product: "com.vmware.cis",
					Type:    "vcenterserver",
				},
				NodeId: uuid.New().String(),
			},
			ServiceId: vc.Content.About.InstanceUuid,
			SiteId:    siteID,
		},
	}
}
1266241
func registerUnregisterService(root string) (bool, error) {

	if unregisterServiceFlag {
		if registerServiceFlag {
			return true, errors.New("--register-service and --unregister-service cannot be used together")
		}
		return true, unregisterService()
	}

	if registerServiceFlag {
		return true, registerService()
	}

	if runServiceFlag {
		if err := initPanicFile(filepath.Join(root, "panic.log")); err != nil {
			return true, err
		}

		interactive, err := svc.IsAnInteractiveSession()
		if err != nil {
			return true, err
		}

		var log *eventlog.Log
		if !interactive {
			log, err = eventlog.Open(serviceNameFlag)
			if err != nil {
				return true, err
			}
		}

		logrus.AddHook(&etwHook{log})
		logrus.SetOutput(ioutil.Discard)

	}
	return false, nil
}
1004695
func Register(plugins *admission.Plugins) {
	plugins.Register(PluginName, func(config io.Reader) (admission.Interface, error) {
		serviceAccountAdmission := NewServiceAccount()
		return serviceAccountAdmission, nil
	})
}
10676
func RegisterService(m ResourceMetadata) error {
	data, err := json.Marshal(m)
	if err != nil {
		return errors.New("Error marshaling ResourceMetadata")
	}

	response, err := http.Post(
		RegistryURL, ContentTypeJSON, bytes.NewBuffer(data),
	)
	if err != nil {
		return errors.New("Error posting ResourceMetadata to registerService")
	}

	if response.Body == nil {
		return errors.New("No JSON body returned from registerService")
	}

	b, err := ioutil.ReadAll(response.Body)
	if err != nil {
		return errors.New("Error reading JSON body returned from registerService")
	}

	// Throw 400 if we cannot unmarshal the body as a valid InputMsg.
	var rm RegisterServiceMsg
	if err := json.Unmarshal(b, &rm); err != nil {
		return errors.New("Error unmarshaling RegisterServiceMsg")
	}
	log.Println("RegisterService received resourceId=" + rm.ResourceID)

	return nil
}
14840
func (s *Service) AppSetupInfo(ctx context.Context, appSetupIdentity string) (*AppSetup, error) {
	var appSetup AppSetup
	return &appSetup, s.Get(ctx, &appSetup, fmt.Sprintf("/app-setups/%v", appSetupIdentity), nil, nil)
}
590349
func (s *Service) RegisterSDK(r *Registry) {
	if s.ServeMux == nil {
		s.ServeMux = http.NewServeMux()
	}

	s.sdk[r.Path] = r
	s.ServeMux.HandleFunc(r.Path, s.ServeSDK)
}
1039968
func (c *ServiceWorker) UpdateRegistration(scopeURL string) (*gcdmessage.ChromeResponse, error) {
	var v ServiceWorkerUpdateRegistrationParams
	v.ScopeURL = scopeURL
	return c.UpdateRegistrationWithParams(&v)
}
141853
func (c *ExtensionManagerClient) RegisterExtension(info *osquery.InternalExtensionInfo, registry osquery.ExtensionRegistry) (*osquery.ExtensionStatus, error) {
	return c.Client.RegisterExtension(context.Background(), info, registry)
}
151292
func Registry(r registry.Registry) Option {
	return func(o *Options) {
		o.Registry = r
	}
}
526937
func (s *Service) DomainInfo(ctx context.Context, appIdentity string, domainIdentity string) (*Domain, error) {
	var domain Domain
	return &domain, s.Get(ctx, &domain, fmt.Sprintf("/apps/%v/domains/%v", appIdentity, domainIdentity), nil, nil)
}
410783
func Register(instance, service, domain string, port int, text []string, iface *net.Interface) (*Server, error) {
	entry := NewServiceEntry(instance, service, domain)
	entry.Port = port
	entry.Text = text

	if entry.Instance == "" {
		return nil, fmt.Errorf("Missing service instance name")
	}
	if entry.Service == "" {
		return nil, fmt.Errorf("Missing service name")
	}
	if entry.Domain == "" {
		entry.Domain = "local"
	}
	if entry.Port == 0 {
		return nil, fmt.Errorf("Missing port")
	}

	var err error
	if entry.HostName == "" {
		entry.HostName, err = os.Hostname()
		if err != nil {
			return nil, fmt.Errorf("Could not determine host")
		}
	}
	entry.HostName = fmt.Sprintf("%s.", trimDot(entry.HostName))

	addrs, err := net.LookupIP(entry.HostName)
	if err != nil {
		// Try appending the host domain suffix and lookup again
		// (required for Linux-based hosts)
		tmpHostName := fmt.Sprintf("%s%s.", entry.HostName, entry.Domain)
		addrs, err = net.LookupIP(tmpHostName)
		if err != nil {
			return nil, fmt.Errorf("Could not determine host IP addresses for %s", entry.HostName)
		}
	}
	for i := 0; i < len(addrs); i++ {
		if ipv4 := addrs[i].To4(); ipv4 != nil {
			entry.AddrIPv4 = addrs[i]
		} else if ipv6 := addrs[i].To16(); ipv6 != nil {
			entry.AddrIPv6 = addrs[i]
		}
	}

	s, err := newServer(iface)
	if err != nil {
		return nil, err
	}

	s.service = entry
	go s.mainloop()
	go s.probe()

	return s, nil
}
1073261
func (c *Client) Register(procedure string, fn MethodHandler, options map[string]interface{}) error {
	id := NewID()
	c.registerListener(id)
	register := &Register{
		Request:   id,
		Options:   options,
		Procedure: URI(procedure),
	}
	if err := c.Send(register); err != nil {
		return err
	}

	// wait to receive REGISTERED message
	msg, err := c.waitOnListener(id)
	if err != nil {
		return err
	} else if e, ok := msg.(*Error); ok {
		return fmt.Errorf("error registering procedure '%v': %v", procedure, e.Error)
	} else if registered, ok := msg.(*Registered); !ok {
		return fmt.Errorf(formatUnexpectedMessage(msg, REGISTERED))
	} else {
		// register the event handler with this registration
		c.procedures[registered.Registration] = &procedureDesc{procedure, fn}
	}
	return nil
}
227456
func (i *Infrastructure) RegisterService(name string, s Service) error {
	i.Lock.RLock()
	if _, ok := i.Services[name]; ok {
		i.Lock.RUnlock()
		return ErrServiceExists
	}
	i.Lock.RUnlock()
	i.Lock.Lock()
	if s.Name == "" {
		s.Name = name
	}
	i.Services[name] = &s
	i.Lock.Unlock()

	return nil
}
1028751
func (tsv *TabletServer) Register() {
	for _, f := range RegisterFunctions {
		f(tsv)
	}
	tsv.registerDebugHealthHandler()
	tsv.registerQueryzHandler()
	tsv.registerStreamQueryzHandlers()
	tsv.registerTwopczHandler()
}
652214
func RegisterVCS(vcs Vcs) {
	registerSync.Lock()
	defer registerSync.Unlock()

	vcsRegistry = append(vcsRegistry, vcs)
}
1188043
func (r *RegisterMonitor) register() {
	catalog := r.Client.Catalog()
	serviceID := r.serviceID()
	serviceName := r.serviceName()

	// Determine the current state of this service in Consul
	var currentService *api.CatalogService
	services, _, err := catalog.Service(
		serviceName, "",
		&api.QueryOptions{AllowStale: true})
	if err == nil {
		for _, service := range services {
			if serviceID == service.ServiceID {
				currentService = service
				break
			}
		}
	}

	// If we have a matching service, then we verify if we need to reregister
	// by comparing if it matches what we expect.
	if currentService != nil &&
		currentService.ServiceAddress == r.LocalAddress &&
		currentService.ServicePort == r.LocalPort {
		r.Logger.Printf("[DEBUG] proxy: service already registered, not re-registering")
		return
	}

	// If we're here, then we're registering the service.
	err = r.Client.Agent().ServiceRegister(&api.AgentServiceRegistration{
		Kind:    api.ServiceKindConnectProxy,
		ID:      serviceID,
		Name:    serviceName,
		Address: r.LocalAddress,
		Port:    r.LocalPort,
		Proxy: &api.AgentServiceConnectProxyConfig{
			DestinationServiceName: r.Service,
		},
		Check: &api.AgentServiceCheck{
			CheckID: r.checkID(),
			Name:    "proxy heartbeat",
			TTL:     "30s",
			Notes:   "Built-in proxy will heartbeat this check.",
			Status:  "passing",
		},
	})
	if err != nil {
		r.Logger.Printf("[WARN] proxy: Failed to register Consul service: %s", err)
		return
	}

	r.Logger.Printf("[INFO] proxy: registered Consul service: %s", serviceID)
}
482123
func RegisterService(name string, port int, ttl int) {
	go registerService(name, port, ttl)
}