// CellAZsByUnusednes sorts the availability zones in order of whether this cluster is using them or not
// An AZ that is not being used at all will be early in the result.
// All known AZs are included in the result
func (step AddNode) sortCellAZsByUnusedness(existingNodes []*structs.Node, cells cells.Cells) (vs *utils.ValSorter) {
	azUsageData := map[string]int{}
	for _, az := range cells.AllAvailabilityZones() {
		azUsageData[az] = 0
	}
	for _, existingNode := range existingNodes {
		if az, err := cells.AvailabilityZone(existingNode.CellGUID); err == nil {
			azUsageData[az] += 1
		}
	}
	vs = utils.NewValSorter(azUsageData)
	vs.Sort()
	return
}
// Perform runs the Step action to modify the Cluster
func (step AddNode) prioritizeCellsByHealth(existingNodes []*structs.Node, cells cells.Cells) (cellsToTry cells.Cells, err error) {
	// Prioritize availableCells into [unused AZs, used AZs, used cells]
	health, err := cells.InspectHealth()
	if err != nil {
		return
	}
	vs := utils.NewValSorter(health)
	vs.Sort()
	for _, nextCellID := range vs.Keys {
		for _, cellAPI := range cells {
			if cellAPI.GUID == nextCellID {
				cellsToTry = append(cellsToTry, cellAPI)
				break
			}
		}
	}

	return
}