// VCenterClusters retrieves the list of child VCenterClusters of the VCenterDataCenter
185273
func (o *VCenterDataCenter) VCenterClusters(info *bambou.FetchingInfo) (VCenterClustersList, *bambou.Error) {

	var list VCenterClustersList
	err := bambou.CurrentSession().FetchChildren(o, VCenterClusterIdentity, &list, info)
	return list, err
}
616969
func (db *db) WatchClusters(ctx context.Context, callback func(*ClusterEvent)) error {
	listOpts := metav1.ListOptions{}
	labelSelector := labels.NewSelector()
	req, err := labels.NewRequirement(common.LabelKeySecretType, selection.Equals, []string{common.LabelValueSecretTypeCluster})
	if err != nil {
		return err
	}
	labelSelector = labelSelector.Add(*req)
	listOpts.LabelSelector = labelSelector.String()
	w, err := db.kubeclientset.CoreV1().Secrets(db.ns).Watch(listOpts)
	if err != nil {
		return err
	}

	localCls, err := db.GetCluster(ctx, common.KubernetesInternalAPIServerAddr)
	if err != nil {
		return err
	}

	defer w.Stop()
	done := make(chan bool)

	// trigger callback with event for local cluster since it always considered added
	callback(&ClusterEvent{Type: watch.Added, Cluster: localCls})

	go func() {
		for next := range w.ResultChan() {
			secret := next.Object.(*apiv1.Secret)
			cluster := secretToCluster(secret)

			// change local cluster event to modified or deleted, since it cannot be re-added or deleted
			if cluster.Server == common.KubernetesInternalAPIServerAddr {
				if next.Type == watch.Deleted {
					next.Type = watch.Modified
					cluster = &localCluster
				} else if next.Type == watch.Added {
					localCls = cluster
					next.Type = watch.Modified
				} else {
					localCls = cluster
				}
			}

			callback(&ClusterEvent{
				Type:    next.Type,
				Cluster: cluster,
			})
		}
		done <- true
	}()

	select {
	case <-done:
	case <-ctx.Done():
	}
	return nil
}
69604
func (s *ClusterService) NewListClustersParams() *ListClustersParams {
	p := &ListClustersParams{}
	p.p = make(map[string]interface{})
	return p
}
334482
func newCluster(conn Connection) (Cluster, error) {
	if conn == nil {
		return nil, WithStack(InvalidArgumentError{Message: "conn is nil"})
	}
	return &cluster{
		conn: conn,
	}, nil
}
485216
func NewCluster(site string) *Cluster {
	return &Cluster{
		Site:       site,
		BGPPeers:   make(map[string]*seesaw.Host),
		Nodes:      make(map[string]*seesaw.Node),
		VIPSubnets: make(map[string]*net.IPNet),
		Vservers:   make(map[string]*Vserver),
		VLANs:      make(map[uint16]*seesaw.VLAN),
		Status: seesaw.ConfigStatus{
			Warnings:   make([]string, 0),
			Attributes: make([]seesaw.ConfigMetadata, 0),
		},
	}
}
129074
func (o *VCenter) Autodiscovereddatacenters(info *bambou.FetchingInfo) (AutodiscovereddatacentersList, *bambou.Error) {

	var list AutodiscovereddatacentersList
	err := bambou.CurrentSession().FetchChildren(o, AutodiscovereddatacenterIdentity, &list, info)
	return list, err
}
1155408
func (s *ListClustersOutput) SetClusters(v []*string) *ListClustersOutput {
	s.Clusters = v
	return s
}
979226
func cluster(clusters []*Cluster, distancer ClusterDistancer, threshold float64) []*Cluster {
	if len(clusters) < 2 {
		return clusters
	}

	count := 0
	for _, cluster := range clusters {
		count += len(cluster.Pointers)
	}

	clusters, found := clusterClusters(
		clusters,
		// Default initialization, TODO: better bucketing/prefiltering will greatly increase performance.
		initClusterDistances(clusters, distancer, threshold),
		distancer,
		threshold,
	)

	result := make([]*Cluster, 0, found)
	for _, cluster := range clusters {
		if cluster != nil {
			result = append(result, cluster)
		}
	}

	return result
}
618121
func NewClusterService(name, namespace string) ClusterService {
	return ClusterService{
		Name:      name,
		Namespace: namespace,
		Frontends: map[string]PortConfiguration{},
		Backends:  map[string]PortConfiguration{},
		Labels:    map[string]string{},
		Selector:  map[string]string{},
	}
}
717308
func (s *ClusterService) ListDedicatedClusters(p *ListDedicatedClustersParams) (*ListDedicatedClustersResponse, error) {
	resp, err := s.cs.newRequest("listDedicatedClusters", p.toURLValues())
	if err != nil {
		return nil, err
	}

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

	return &r, nil
}
440545
func (g *Cloud) GetManagedClusters(ctx context.Context) ([]*container.Cluster, error) {
	managedClusters := []*container.Cluster{}

	if g.regional {
		var err error
		managedClusters, err = g.getClustersInLocation(g.region)
		if err != nil {
			return nil, err
		}
	} else if len(g.managedZones) >= 1 {
		for _, zone := range g.managedZones {
			clusters, err := g.getClustersInLocation(zone)
			if err != nil {
				return nil, err
			}
			managedClusters = append(managedClusters, clusters...)
		}
	} else {
		return nil, fmt.Errorf("no zones associated with this cluster(%s)", g.ProjectID())
	}

	return managedClusters, nil
}
826107
func (s *PresenceService) GetRemoteClusters(opts ...services.MarshalOption) ([]services.RemoteCluster, error) {
	startKey := backend.Key(remoteClustersPrefix)
	result, err := s.GetRange(context.TODO(), startKey, backend.RangeEnd(startKey), backend.NoLimit)
	if err != nil {
		return nil, trace.Wrap(err)
	}

	clusters := make([]services.RemoteCluster, len(result.Items))
	for i, item := range result.Items {
		cluster, err := services.UnmarshalRemoteCluster(item.Value,
			services.AddOptions(opts, services.WithResourceID(item.ID), services.WithExpires(item.Expires))...)
		if err != nil {
			return nil, trace.Wrap(err)
		}
		clusters[i] = cluster
	}
	return clusters, nil
}
128334
func (c *MemberlistManager) clusterStats() {
	primReady := 0
	primNotReady := 0
	secReady := 0
	secNotReady := 0
	queryReady := 0
	queryNotReady := 0
	partitions := make(map[int32]int)
	for _, p := range c.members {
		if p.Primary {
			if p.IsReady() {
				primReady++
			} else {
				primNotReady++
			}
		} else if p.Mode != ModeQuery {
			if p.IsReady() {
				secReady++
			} else {
				secNotReady++
			}
		} else {
			if p.IsReady() {
				queryReady++
			} else {
				queryNotReady++
			}
		}
		for _, partition := range p.Partitions {
			partitions[partition]++
		}
	}

	totalPrimaryReady.Set(primReady)
	totalPrimaryNotReady.Set(primNotReady)
	totalSecondaryReady.Set(secReady)
	totalSecondaryNotReady.Set(secNotReady)
	totalQueryReady.Set(queryReady)
	totalQueryNotReady.Set(queryNotReady)

	totalPartitions.Set(len(partitions))
}
740685
func (c *clusterClient) GetClusterConf() (*osdconfig.ClusterConfig, error) {
	config := new(osdconfig.ClusterConfig)
	request := c.c.Get().Resource(clusterPath + UriCluster)
	if err := request.Do().Unmarshal(config); err != nil {
		return nil, err
	}
	return config, nil
}
1294225
func ClusterGeoClusters(clusters []*Cluster, threshold float64) []*Cluster {
	if len(clusters) < 2 {
		return clusters
	}

	copiedClusters := make([]*Cluster, len(clusters), len(clusters))
	for i, cluster := range clusters {
		copiedClusters[i] = NewClusterWithCentroid(cluster.Centroid, cluster.Pointers...)
	}

	return geocluster(copiedClusters, threshold)
}
529390
func (manager *configManager) execClusterCallbacks(f CallbackClusterConfigFunc, data *data) {
	config := new(ClusterConfig)
	if err := json.Unmarshal(data.Value, config); err != nil {
		logrus.Error(err)
		return
	}

	f(config)
}
624017
func (o *Me) VCenterVRSConfigs(info *bambou.FetchingInfo) (VCenterVRSConfigsList, *bambou.Error) {

	var list VCenterVRSConfigsList
	err := bambou.CurrentSession().FetchChildren(o, VCenterVRSConfigIdentity, &list, info)
	return list, err
}