// EnableServiceForOrg enables access for the given service in a specific org.
501277
func (actor Actor) EnableServiceForOrg(serviceName, orgName, brokerName string) (Warnings, error) {
	servicePlans, allWarnings, err := actor.GetServicePlansForService(serviceName, brokerName)
	if err != nil {
		return allWarnings, err
	}

	org, orgWarnings, err := actor.GetOrganizationByName(orgName)
	allWarnings = append(allWarnings, orgWarnings...)
	if err != nil {
		return allWarnings, err
	}

	for _, plan := range servicePlans {
		if plan.Public != true {
			_, warnings, err := actor.CloudControllerClient.CreateServicePlanVisibility(plan.GUID, org.GUID)
			allWarnings = append(allWarnings, warnings...)
			if _, alreadyExistsError := err.(ccerror.ServicePlanVisibilityExistsError); alreadyExistsError {
				return allWarnings, nil
			}
			if err != nil {
				return allWarnings, err
			}
		}
	}

	return allWarnings, nil
}
524229
func (i *Handle) IsServicePresent(s *Service) bool {
	return nil == i.doCmd(s, nil, ipvsCmdGetService)
}
73866
func (s *SidecarApi) oneServiceHandler(response http.ResponseWriter, req *http.Request, params map[string]string) {
	defer req.Body.Close()

	response.Header().Set("Access-Control-Allow-Origin", "*")
	response.Header().Set("Access-Control-Allow-Methods", "GET")
	response.Header().Set("Content-Type", "application/json")

	if params["extension"] != "json" {
		sendJsonError(response, 404, "Not Found - Invalid content type extension")
		return
	}

	name, ok := params["name"]
	if !ok {
		sendJsonError(response, 404, "Not Found - No service name provided")
		return
	}

	if s.state == nil {
		sendJsonError(response, 500, "Internal Server Error - Something went terribly wrong")
		return
	}

	var instances []*service.Service
	// Enter critical section
	s.state.RLock()
	defer s.state.RUnlock()
	s.state.EachService(func(hostname *string, id *string, svc *service.Service) {
		if svc.Name == name {
			instances = append(instances, svc)
		}
	})

	// Did we have any entries for this service in the catalog?
	if len(instances) == 0 {
		sendJsonError(response, 404, fmt.Sprintf("no instances of %s found", name))
		return
	}

	clusterName := ""
	if s.list != nil {
		clusterName = s.list.ClusterName()
	}

	// Everything went fine, we found entries for this service.
	// Send the json back.
	svcInstances := make(map[string][]*service.Service)
	svcInstances[name] = instances
	result := ApiServices{
		Services:    svcInstances,
		ClusterName: clusterName,
	}

	jsonBytes, err := json.MarshalIndent(&result, "", "  ")
	if err != nil {
		log.Errorf("Error marshaling state in oneServiceHandler: %s", err.Error())
		sendJsonError(response, 500, "Internal server error")
		return
	}

	response.Write(jsonBytes)
}
297467
func (s *SimpleMonitor) EnableNofitySlack(incomingWebhooksURL string) {
	s.Settings.SimpleMonitor.NotifySlack = createSimpleMonitorNotifySlack(incomingWebhooksURL)
}
200686
func (s *Store) EnsureService(idx uint64, node string, svc *structs.NodeService) error {
	tx := s.db.Txn(true)
	defer tx.Abort()

	// Call the service registration upsert
	if err := s.ensureServiceTxn(tx, idx, node, svc); err != nil {
		return err
	}

	tx.Commit()
	return nil
}
183289
func (client *Client) EnableScalingGroup(args *EnableScalingGroupArgs) (resp *EnableScalingGroupResponse, err error) {
	response := EnableScalingGroupResponse{}
	err = client.InvokeByFlattenMethod("EnableScalingGroup", args, &response)

	if err != nil {
		return nil, err
	}
	return &response, nil
}
138502
func (sc *serviceRegistryCache) GetRegistryForService(serviceID string) *serviceRegistry {
	registry, ok := sc.registry[serviceID]
	if !ok {
		registry = &serviceRegistry{
			ServiceID:   serviceID,
			PublicPorts: make(map[zkr.PublicPortKey]zkr.PublicPort, 0),
			VHosts:      make(map[zkr.VHostKey]zkr.VHost, 0),
		}
		sc.registry[serviceID] = registry
	}
	return registry
}
446311
func (f *Facade) EnablePublicEndpointPort(ctx datastore.Context, serviceid, endpointName, portAddr string, isEnabled bool) error {
	defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.EnablePublicEndpointPort"))
	var auditMsg string
	if isEnabled {
		auditMsg = "Enabling Public Endpoint Port"
	} else {
		auditMsg = "Disabling Public Endpoing Port"
	}
	alog := f.auditLogger.Message(ctx, auditMsg).Action(audit.Update).ID(serviceid).
		WithFields(logrus.Fields{
			"endpointname": endpointName,
			"portaddr":     portAddr,
		})
	// Scrub the port for all checks, as this is what gets stored against the service.
	portAddr = service.ScrubPortString(portAddr)

	// Get the service for this service id.
	svc, err := f.GetService(ctx, serviceid)
	if err != nil {
		err = fmt.Errorf("Could not find service %s: %s", serviceid, err)
		glog.Error(err)
		return alog.Error(err)
	}
	alog = alog.Entity(svc)

	// Find the port so we can check the current enabled state.
	port := svc.GetPort(endpointName, portAddr)
	if port == nil {
		err = fmt.Errorf("Port %s not found in service %s:%s", portAddr, svc.ID, svc.Name)
		glog.Error(err)
		return alog.Error(err)
	}

	// If the port is already in the same state, don't do anything.
	if port.Enabled == isEnabled {
		err = fmt.Errorf("Port %s enabled state is already set to %t for service (%s).", portAddr, isEnabled, svc.Name)
		glog.Warning(err)
		return alog.Error(err)
	}

	glog.V(0).Infof("Setting enabled=%t for service (%s) port %s", isEnabled, svc.Name, portAddr)

	// If they're trying to enable the port, check to make sure the port is valid and available.
	if isEnabled {
		// Validate the port number
		portParts := strings.Split(portAddr, ":")
		if len(portParts) < 2 {
			err = fmt.Errorf("Invalid port address. Port address must be \":[PORT NUMBER]\" or \"[IP ADDRESS]:[PORT NUMBER]\"")
			glog.Error(err)
			return alog.Error(err)
		}

		if portAddr == "0" || strings.HasSuffix(portAddr, ":0") {
			err = fmt.Errorf("Invalid port address. Port 0 is invalid.")
			glog.Error(err)
			return alog.Error(err)
		}

		if err = checkPort("tcp", fmt.Sprintf("%s", portAddr)); err != nil {
			glog.Error(err)
			return alog.Error(err)
		}
	}

	err = svc.EnablePort(endpointName, portAddr, isEnabled)
	if err != nil {
		err = fmt.Errorf("error setting enabled=%t for port %s, service (%s): %v", isEnabled, portAddr, svc.Name, err)
		return alog.Error(err)
	}

	glog.V(2).Infof("Port (%s) enable state set to %t for service (%s)", portAddr, isEnabled, svc.Name)

	if err = f.UpdateService(ctx, *svc); err != nil {
		glog.Error(err)
		return alog.Error(err)
	}

	glog.V(2).Infof("Service (%s) updated", svc.Name)
	alog.Succeeded()
	return nil
}
516144
func (SystemdStrategy) enableSwarming(ctx context.Context) error {
	if err := exec.Command("systemctl", "daemon-reload").Run(); err != nil {
		return err
	}
	return exec.Command("systemctl", "enable", "swarming-start-bot").Run()
}
115673
func (actor Actor) DisablePlanForOrg(serviceName, servicePlanName, orgName, brokerName string) (Warnings, error) {
	servicePlans, allWarnings, err := actor.GetServicePlansForService(serviceName, brokerName)
	if err != nil {
		return allWarnings, err
	}

	org, orgWarnings, err := actor.GetOrganizationByName(orgName)
	allWarnings = append(allWarnings, orgWarnings...)
	if err != nil {
		return allWarnings, err
	}

	planFound := false
	for _, plan := range servicePlans {
		if plan.Name == servicePlanName {
			warnings, err := actor.removeOrgLevelServicePlanVisibilities(plan.GUID, org.GUID)
			allWarnings = append(allWarnings, warnings...)
			if err != nil {
				return allWarnings, err
			}
			planFound = true
			break
		}
	}

	if planFound == false {
		return allWarnings, actionerror.ServicePlanNotFoundError{PlanName: servicePlanName, ServiceName: serviceName}
	}
	return allWarnings, nil
}
744424
func (f *Facade) GetServiceConfig(ctx datastore.Context, fileID string) (*servicedefinition.ConfigFile, error) {
	defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.GetServiceConfig"))
	logger := plog.WithField("fileid", fileID)

	file := &serviceconfigfile.SvcConfigFile{}
	if err := f.configStore.Get(ctx, serviceconfigfile.Key(fileID), file); err != nil {
		logger.WithError(err).Debug("Could not get service config file")
		return nil, err
	}

	return &file.ConfFile, nil
}
113383
func (_class PoolClass) EnableExternalAuth(sessionID SessionRef, pool PoolRef, config map[string]string, serviceName string, authType string) (_err error) {
	_method := "pool.enable_external_auth"
	_sessionIDArg, _err := convertSessionRefToXen(fmt.Sprintf("%s(%s)", _method, "session_id"), sessionID)
	if _err != nil {
		return
	}
	_poolArg, _err := convertPoolRefToXen(fmt.Sprintf("%s(%s)", _method, "pool"), pool)
	if _err != nil {
		return
	}
	_configArg, _err := convertStringToStringMapToXen(fmt.Sprintf("%s(%s)", _method, "config"), config)
	if _err != nil {
		return
	}
	_serviceNameArg, _err := convertStringToXen(fmt.Sprintf("%s(%s)", _method, "service_name"), serviceName)
	if _err != nil {
		return
	}
	_authTypeArg, _err := convertStringToXen(fmt.Sprintf("%s(%s)", _method, "auth_type"), authType)
	if _err != nil {
		return
	}
	_, _err =  _class.client.APICall(_method, _sessionIDArg, _poolArg, _configArg, _serviceNameArg, _authTypeArg)
	return
}
610503
func (s *AccountService) EnableAccount(p *EnableAccountParams) (*EnableAccountResponse, error) {
	resp, err := s.cs.newRequest("enableAccount", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r EnableAccountResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	return &r, nil
}
1242683
func (m *GossipMessage) IsOrgRestricted() bool {
	return m.Tag == GossipMessage_CHAN_AND_ORG || m.Tag == GossipMessage_ORG_ONLY
}
1244498
func (m *ClientMetrics) EnableClientHandlingTimeHistogram(opts ...HistogramOption) {
	for _, o := range opts {
		o(&m.clientHandledHistogramOpts)
	}
	if !m.clientHandledHistogramEnabled {
		m.clientHandledHistogram = prom.NewHistogramVec(
			m.clientHandledHistogramOpts,
			[]string{"grpc_type", "grpc_service", "grpc_method"},
		)
	}
	m.clientHandledHistogramEnabled = true
}
1020764
func (c *Client) CreateServiceOffering(p *CreateServiceOfferingParameter) (*ServiceOffering, error) {
	obj, err := c.Request("createServiceOffering", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.(*ServiceOffering), err
}
390225
func (e *Enforcer) AddRoleForUser(user string, role string) bool {
	return e.AddGroupingPolicy(user, role)
}