// AutoDiscoverHypervisorFromClusters retrieves the list of child AutoDiscoverHypervisorFromClusters of the VCenterCluster
322671
func (o *VCenterCluster) AutoDiscoverHypervisorFromClusters(info *bambou.FetchingInfo) (AutoDiscoverHypervisorFromClustersList, *bambou.Error) {

	var list AutoDiscoverHypervisorFromClustersList
	err := bambou.CurrentSession().FetchChildren(o, AutoDiscoverHypervisorFromClusterIdentity, &list, info)
	return list, err
}
245585
func (k *kubernetesClient) GetClusterMetadata(storageClass string) (*caas.ClusterMetadata, error) {
	var result caas.ClusterMetadata
	var err error
	result.Cloud, result.Regions, err = k.listHostCloudRegions()
	if err != nil {
		return nil, errors.Annotate(err, "cannot determine cluster region")
	}

	if storageClass != "" {
		sc, err := k.client().StorageV1().StorageClasses().Get(storageClass, v1.GetOptions{IncludeUninitialized: true})
		if err != nil && !k8serrors.IsNotFound(err) {
			return nil, errors.Trace(err)
		}
		if err == nil {
			result.NominatedStorageClass = &caas.StorageProvisioner{
				Name:        sc.Name,
				Provisioner: sc.Provisioner,
				Parameters:  sc.Parameters,
			}
			if sc.ReclaimPolicy != nil {
				result.NominatedStorageClass.ReclaimPolicy = string(*sc.ReclaimPolicy)
			}
		}
	}

	// We may have the workload storage but still need to look for operator storage.
	preferredOperatorStorage, havePreferredOperatorStorage := jujuPreferredOperatorStorage[result.Cloud]
	storageClasses, err := k.client().StorageV1().StorageClasses().List(v1.ListOptions{})
	if err != nil {
		return nil, errors.Annotate(err, "listing storage classes")
	}

	var (
		possibleWorkloadStorage []storage.StorageClass
		possibleOperatorStorage []*caas.StorageProvisioner
		defaultOperatorStorage  *caas.StorageProvisioner
	)
	for _, sc := range storageClasses.Items {
		if havePreferredOperatorStorage {
			maybeOperatorStorage := &caas.StorageProvisioner{
				Name:        sc.Name,
				Provisioner: sc.Provisioner,
				Parameters:  sc.Parameters,
			}
			if sc.ReclaimPolicy != nil {
				maybeOperatorStorage.ReclaimPolicy = string(*sc.ReclaimPolicy)
			}
			if err := storageClassMatches(preferredOperatorStorage, maybeOperatorStorage); err == nil {
				possibleOperatorStorage = append(possibleOperatorStorage, maybeOperatorStorage)
				if isDefaultStorageClass(sc) {
					defaultOperatorStorage = maybeOperatorStorage
				}
			}
		}
		if result.NominatedStorageClass != nil {
			continue
		}
		if isDefaultStorageClass(sc) {
			result.NominatedStorageClass = &caas.StorageProvisioner{
				Name:        sc.Name,
				Provisioner: sc.Provisioner,
				Parameters:  sc.Parameters,
			}
			if sc.ReclaimPolicy != nil {
				result.NominatedStorageClass.ReclaimPolicy = string(*sc.ReclaimPolicy)
			}
			break
		}
		possibleWorkloadStorage = append(possibleWorkloadStorage, sc)
	}

	// Prefer operator storage from the default storage class.
	if defaultOperatorStorage != nil {
		result.OperatorStorageClass = defaultOperatorStorage
	} else if len(possibleOperatorStorage) > 0 {
		result.OperatorStorageClass = possibleOperatorStorage[0]
	}

	// Even if no storage class was marked as default for the cluster, if there's only
	// one of them, use it for workload storage.
	if result.NominatedStorageClass == nil && len(possibleWorkloadStorage) == 1 {
		sc := possibleWorkloadStorage[0]
		result.NominatedStorageClass = &caas.StorageProvisioner{
			Name:        sc.Name,
			Provisioner: sc.Provisioner,
			Parameters:  sc.Parameters,
		}
		if sc.ReclaimPolicy != nil {
			result.NominatedStorageClass.ReclaimPolicy = string(*sc.ReclaimPolicy)
		}
	}
	return &result, nil
}
724126
func (c *Client) GetClusterVersions() (map[string]string, error) {
	versions := make(map[string]string)
	statuses, err := c.GetClusterStatus()
	if err != nil {
		return versions, err
	}

	for ep, status := range statuses {
		versions[ep] = status.Version
	}
	return versions, nil
}
610860
func FindAutoscalingGroups(c ALICloud) ([]ess.ScalingGroupItemType, error) {
	var sgs []ess.ScalingGroupItemType
	var relsult []ess.ScalingGroupItemType
	var clusterName string

	clusterName, ok := c.GetClusterTags()[TagClusterName]
	if !ok {
		return nil, errors.New("error describing ScalingGroups:can not get clusterName")
	}

	glog.V(2).Infof("Listing all Autoscaling groups matching clusterName")

	request := &ess.DescribeScalingGroupsArgs{
		RegionId: common.Region(c.Region()),
	}
	for {
		resp, page, err := c.EssClient().DescribeScalingGroups(request)
		if err != nil {
			return nil, fmt.Errorf("error describing ScalingGroups: %v", err)
		}
		sgs = append(sgs, resp...)

		if page.NextPage() == nil {
			break
		}
		request.Pagination = *(page.NextPage())
	}
	for _, sg := range sgs {
		if strings.HasSuffix(sg.ScalingGroupName, clusterName) {
			relsult = append(relsult, sg)
		}
	}

	return relsult, nil
}
158164
func (c *Client) ListDedicatedClusters(p *ListDedicatedClustersParameter) ([]*DedicatedCluster, error) {
	obj, err := c.Request("listDedicatedClusters", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.([]*DedicatedCluster), err
}
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
}
1293871
func (v *Vibranium) ListNodeContainers(ctx context.Context, opts *pb.GetNodeOptions) (*pb.Containers, error) {
	containers, err := v.cluster.ListNodeContainers(ctx, opts.Nodename)
	if err != nil {
		return nil, err
	}
	return &pb.Containers{Containers: toRPCContainers(ctx, containers, nil)}, nil
}
89972
func GetActiveMapFromClusterDomainInfos(clusterDomainInfos []*ClusterDomainInfo) types.ClusterDomainsActiveMap {
	activeMap := make(types.ClusterDomainsActiveMap)
	for _, clusterDomainInfo := range clusterDomainInfos {
		activeMap[clusterDomainInfo.Name] = clusterDomainInfo.State
	}
	return activeMap
}
1318266
func (s *ClusterService) DedicateCluster(p *DedicateClusterParams) (*DedicateClusterResponse, error) {
	resp, err := s.cs.newRequest("dedicateCluster", p.toURLValues())
	if err != nil {
		return nil, err
	}

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

	// If we have a async client, we need to wait for the async result
	if s.cs.async {
		b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)
		if err != nil {
			if err == AsyncTimeoutErr {
				return &r, err
			}
			return nil, err
		}

		b, err = getRawValue(b)
		if err != nil {
			return nil, err
		}

		if err := json.Unmarshal(b, &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
}
376764
func filterClustersByName(clusterNames []string, clusters []*api.Cluster) ([]*api.Cluster, error) {
	if len(clusterNames) != 0 {
		// Build a map as we want to return them in the same order as args
		m := make(map[string]*api.Cluster)
		for _, c := range clusters {
			m[c.ObjectMeta.Name] = c
		}
		var filtered []*api.Cluster
		for _, clusterName := range clusterNames {
			c := m[clusterName]
			if c == nil {
				return nil, fmt.Errorf("cluster not found %q", clusterName)
			}

			filtered = append(filtered, c)
		}
		return filtered, nil
	}

	return clusters, nil
}
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
}
620722
func (s *ClusterService) NewAddClusterParams(clustername string, clustertype string, hypervisor string, podid string, zoneid string) *AddClusterParams {
	p := &AddClusterParams{}
	p.p = make(map[string]interface{})
	p.p["clustername"] = clustername
	p.p["clustertype"] = clustertype
	p.p["hypervisor"] = hypervisor
	p.p["podid"] = podid
	p.p["zoneid"] = zoneid
	return p
}
688897
func NewClusterRoleInformer(client kubernetes.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
	return NewFilteredClusterRoleInformer(client, resyncPeriod, indexers, nil)
}
529142
func ClusterToSelectableFields(obj *kops.Cluster) fields.Set {
	return generic.ObjectMetaFieldsSet(&obj.ObjectMeta, true)
}
218138
func (p *propDisks) GetDiskIDs() []int64 {

	ids := []int64{}
	for _, disk := range p.Disks {
		ids = append(ids, disk.ID)
	}
	return ids

}
66162
func findUnusuedGKEClusterByName(clusterMap *Map, leaseMap *leases.Map, clusterRegex string) (*container.Cluster, error) {
	regex, err := regexp.Compile(clusterRegex)
	if err != nil {
		return nil, err
	}
	for _, clusterName := range clusterMap.Names() {
		if regex.MatchString(clusterName) {
			cluster, err := checkLease(clusterMap, leaseMap, clusterName)
			if err == nil {
				return cluster, nil
			}
		}
	}
	return nil, errUnusedGKEClusterNotFound
}