// GetTenant returns the Tenant configuration for all specified tenants
176372
func (client *QuobyteClient) GetTenant(tenantIDs []string) (GetTenantResponse, error) {
	request := &getTenantRequest{TenantIDs: tenantIDs}

	var response GetTenantResponse
	err := client.sendRequest("getTenant", request, &response)
	if err != nil {
		return response, err
	}

	return response, nil
}
475994
func (_m *FacadeInterface) GetUser(ctx datastore.Context, userName string) (user.User, error) {
	ret := _m.Called(ctx, userName)

	var r0 user.User
	if rf, ok := ret.Get(0).(func(datastore.Context, string) user.User); ok {
		r0 = rf(ctx, userName)
	} else {
		r0 = ret.Get(0).(user.User)
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(datastore.Context, string) error); ok {
		r1 = rf(ctx, userName)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
961114
func GetPrefixTransformers(config *apiserverconfig.ResourceConfiguration) ([]value.PrefixTransformer, error) {
	var result []value.PrefixTransformer
	for _, provider := range config.Providers {
		found := false

		var transformer value.PrefixTransformer
		var err error

		if provider.AESGCM != nil {
			transformer, err = GetAESPrefixTransformer(provider.AESGCM, aestransformer.NewGCMTransformer, aesGCMTransformerPrefixV1)
			if err != nil {
				return result, err
			}
			found = true
		}

		if provider.AESCBC != nil {
			if found == true {
				return result, fmt.Errorf("more than one provider specified in a single element, should split into different list elements")
			}
			transformer, err = GetAESPrefixTransformer(provider.AESCBC, aestransformer.NewCBCTransformer, aesCBCTransformerPrefixV1)
			found = true
		}

		if provider.Secretbox != nil {
			if found == true {
				return result, fmt.Errorf("more than one provider specified in a single element, should split into different list elements")
			}
			transformer, err = GetSecretboxPrefixTransformer(provider.Secretbox)
			found = true
		}

		if provider.Identity != nil {
			if found == true {
				return result, fmt.Errorf("more than one provider specified in a single element, should split into different list elements")
			}
			transformer = value.PrefixTransformer{
				Transformer: identity.NewEncryptCheckTransformer(),
				Prefix:      []byte{},
			}
			found = true
		}

		if provider.KMS != nil {
			if found == true {
				return nil, fmt.Errorf("more than one provider specified in a single element, should split into different list elements")
			}

			// Ensure the endpoint is provided.
			if len(provider.KMS.Endpoint) == 0 {
				return nil, fmt.Errorf("remote KMS provider can't use empty string as endpoint")
			}

			timeout := kmsPluginConnectionTimeout
			if provider.KMS.Timeout != nil {
				if provider.KMS.Timeout.Duration <= 0 {
					return nil, fmt.Errorf("could not configure KMS plugin %q, timeout should be a positive value", provider.KMS.Name)
				}
				timeout = provider.KMS.Timeout.Duration
			}

			// Get gRPC client service with endpoint.
			envelopeService, err := envelopeServiceFactory(provider.KMS.Endpoint, timeout)
			if err != nil {
				return nil, fmt.Errorf("could not configure KMS plugin %q, error: %v", provider.KMS.Name, err)
			}

			transformer, err = getEnvelopePrefixTransformer(provider.KMS, envelopeService, kmsTransformerPrefixV1)
			found = true
		}

		if err != nil {
			return result, err
		}
		result = append(result, transformer)

		if found == false {
			return result, fmt.Errorf("invalid provider configuration: at least one provider must be specified")
		}
	}
	return result, nil
}
365053
func (e *environ) GetLeaseManagerInAPIServer() corelease.Manager {
	st, err := e.state()
	if err != nil {
		panic(err)
	}
	return st.leaseManager
}
1009813
func (c *Client) GetInitiator(id string, name string) (Initiator, error) {
	i, err := c.api.GetInitiator(id, name)
	if err != nil {
		return nil, err
	}

	return i.Content, nil
}
380287
func (d *DeviceMapperDriver) GetTenantStorageStats() ([]volume.TenantStorageStats, error) {
	var result []volume.TenantStorageStats
	status := d.DeviceSet.Status()
	// If this is loop-lvm, the metadata device will be in status.MetadataFile
	mdDevice := status.MetadataFile
	if mdDevice == "" {
		// It's direct-lvm, so build the metadata device from the pool name
		mdDevice = fmt.Sprintf("/dev/mapper/%s_tmeta", status.PoolName)
	}
	// CC-2418: Disabling block stats gathering until a kernel bug in dm-thin
	// is fixed
	/*
		blockstats, err := d.getDeviceBlockStats(status.PoolName, mdDevice)
		if err != nil {
			return nil, err
		}
	*/

	for _, tenant := range d.ListTenants() {
		var devInfo devInfo
		vol, err := d.getVolume(tenant, false)
		if err != nil {
			return nil, err
		}
		if err := d.readDeviceInfo(vol.Metadata.CurrentDevice(), &devInfo); err != nil {
			return nil, err
		}
		// CC-2417
		//if stats, ok := blockstats[devInfo.DeviceID]; ok {
		tss := volume.TenantStorageStats{TenantID: tenant, VolumePath: vol.Path()}
		// CC-2417
		//tss.DeviceAllocatedBlocks = stats.diet.Total()
		tss.NumberSnapshots = len(vol.Metadata.snapshotMetadata.Snapshots)
		dev := vol.Metadata.CurrentDevice()
		// This will activate the device
		if _, err := d.DeviceSet.GetDeviceStatus(dev); err != nil {
			return nil, err
		}
		devicename := fmt.Sprintf("/dev/mapper/%s-%s", d.DevicePrefix, dev)
		total, used, free, err := getFilesystemStats(devicename)
		if err != nil {
			return nil, err
		}
		size, err := getDeviceSize(devicename)
		if err != nil {
			return nil, err
		}
		tss.FilesystemTotal = total
		tss.FilesystemAvailable = free
		tss.FilesystemUsed = used
		tss.DeviceTotalBlocks = volume.BytesToBlocks(size)
		tss.DeviceName = devicename

		//tss.DeviceUnallocatedBlocks = tss.DeviceTotalBlocks - tss.DeviceAllocatedBlocks
		/* CC-2417
				last := stats
				for _, device := range vol.Metadata.snapshotMetadata.Snapshots {
					if err := d.readDeviceInfo(device, &devInfo); err != nil {
						return nil, err
					}
					if snapstats, ok := blockstats[devInfo.DeviceID]; ok {
						tss.SnapshotAllocatedBlocks += snapstats.UniqueBlocks(last)
						last = snapstats
					}
				}
				/*
				if volume.BytesToBlocks(tss.FilesystemUsed) < tss.DeviceAllocatedBlocks {
					tss.Errors = append(tss.Errors, fmt.Sprintf(` !	Note: %s of blocks are allocated to an application virtual device but
		are unused by the filesystem. This is not a problem; however, if you want
		the thin pool to reclaim the space for use by snapshots or another
		application, run:

			$ fstrim %s`, volume.BlocksToBytes(tss.DeviceAllocatedBlocks-volume.BytesToBlocks(tss.FilesystemUsed)), vol.Path()))
				}
		*/
		result = append(result, tss)
		/* CC-2417
		} else {
			// There is no device matching the tenant
			return nil, fmt.Errorf("Tenant %s DFS has not yet been initialized", tenant)
		}
		*/
	}
	return result, nil
}
993646
func (_m *Facade) GetTenantIDs(ctx datastore.Context) ([]string, error) {
	ret := _m.Called(ctx)

	var r0 []string
	if rf, ok := ret.Get(0).(func(datastore.Context) []string); ok {
		r0 = rf(ctx)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).([]string)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(datastore.Context) error); ok {
		r1 = rf(ctx)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
315250
func (c *ServerContext) GetAgent() agent.Agent {
	c.RLock()
	defer c.RUnlock()
	return c.agent
}
1164465
func (f *Facade) GetTenantIDs(ctx datastore.Context) ([]string, error) {
	defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.GetTenantIDs"))
	plog.Debug("Started Facade.GetTenantIDs")
	defer plog.Debug("Finished Facade.GetTenantIDs")

	svcs, err := f.GetServiceDetailsByParentID(ctx, "", 0)
	if err != nil {
		plog.WithError(err).Error("Could not get tenant IDs")
		return nil, err
	}
	tenantIDs := []string{}
	for _, tenant := range svcs {
		tenantIDs = append(tenantIDs, tenant.ID)
	}
	return tenantIDs, nil
}
1090139
func (f *Facade) validateServiceTenant(ctx datastore.Context, serviceA, serviceB string) error {
	defer ctx.Metrics().Stop(ctx.Metrics().Start("Facade.validateServiceTenant"))
	if serviceA == "" || serviceB == "" {
		return ErrTenantDoesNotMatch
	}
	tenantA, err := f.GetTenantID(ctx, serviceA)
	if err != nil {
		glog.Errorf("Could not look up tenant for service %s: %s", serviceA, err)
		return err
	}
	tenantB, err := f.GetTenantID(ctx, serviceB)
	if err != nil {
		glog.Errorf("Could not look up tenant for service %s: %s", serviceB, err)
		return err
	}
	if tenantA != tenantB {
		return ErrTenantDoesNotMatch
	}
	return nil
}
1058335
func httpGetTenant(w http.ResponseWriter, r *http.Request, vars map[string]string) (interface{}, error) {
	log.Debugf("Received httpGetTenant: %+v", vars)

	key := vars["key"]

	collections.tenantMutex.Lock()
	defer collections.tenantMutex.Unlock()
	obj := collections.tenants[key]
	if obj == nil {
		log.Infof("tenant %s not found", key)
		return nil, errors.New("tenant not found")
	}

	// Return the obj
	return obj, nil
}
563013
func (c *client) getAuthUser() string {
	switch {
	case c.opts.Nkey != "":
		return fmt.Sprintf("Nkey %q", c.opts.Nkey)
	case c.opts.Username != "":
		return fmt.Sprintf("User %q", c.opts.Username)
	default:
		return `User "N/A"`
	}
}
68714
func NewShowTenant(config tenantConfig) CodebaseInitTenantProvider {
	return func(ctx context.Context) (*tenant.TenantSingle, error) {
		return ShowTenant(ctx, config)
	}
}
1050542
func (g *Cloud) GetLoadBalancer(ctx context.Context, clusterName string, svc *v1.Service) (*v1.LoadBalancerStatus, bool, error) {
	loadBalancerName := g.GetLoadBalancerName(ctx, clusterName, svc)
	fwd, err := g.GetRegionForwardingRule(loadBalancerName, g.region)
	if err == nil {
		status := &v1.LoadBalancerStatus{}
		status.Ingress = []v1.LoadBalancerIngress{{IP: fwd.IPAddress}}

		return status, true, nil
	}
	return nil, false, ignoreNotFound(err)
}
747819
func NewTenantService(config tenantConfig) service.TenantService {
	return &tenantServiceImpl{config: config, doer: rest.DefaultHttpDoer()}
}
605080
func (p *ProjectCard) GetContentURL() string {
	if p == nil || p.ContentURL == nil {
		return ""
	}
	return *p.ContentURL
}
1108372
func (s *BatchServiceStateManager) AddTenant(tenantID string) error {
	s.lock.Lock()
	defer s.lock.Unlock()

	// We can't start the queue loop if we have been shutdown, so don't allow adding a tenant
	if s.shutdown == nil {
		return ErrNotRunning
	}

	select {
	case <-s.shutdown:
		return ErrNotRunning
	default:
	}

	if _, ok := s.TenantQueues[tenantID]; ok {
		return ErrDuplicateTenantID
	}

	shutdown := make(chan int)
	s.TenantQueues[tenantID] = make(map[service.DesiredState]*ServiceStateQueue)
	s.TenantQueues[tenantID][service.SVCRun] = NewServiceStateQueue(s.Facade)
	s.TenantQueues[tenantID][service.SVCStop] = NewServiceStateQueue(s.Facade)
	s.TenantShutDowns[tenantID] = shutdown
	for t, q := range s.TenantQueues[tenantID] {
		go s.queueLoop(tenantID, t.String(), q, shutdown)
	}

	plog.WithField("tenantid", tenantID).Debug("Added tenant to service state manager")

	return nil
}