Skip to content

Commit

Permalink
Replace sort_by.last with max_by and sort_by.first with min_by
Browse files Browse the repository at this point in the history
(transferred from ManageIQ/manageiq@4435c06)
  • Loading branch information
chessbyte committed Feb 24, 2017
1 parent a79fbd6 commit b8268d3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def self.miq_host_and_storage_least_utilized(obj, _inputs)
nvms = h.vms.collect { |v| v if v.power_state == "on" }.compact.length
if min_running_vms.nil? || nvms < min_running_vms
storages = h.writable_storages.find_all { |s| s.free_space > vm.provisioned_storage } # Filter out storages that do not have enough free space for the Vm
s = storages.sort_by(&:free_space).last
s = storages.max_by(&:free_space)
unless s.nil?
result["host"] = h
result["storage"] = s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
next unless h.power_state == "on"
nvms = h.vms.length
if min_registered_vms.nil? || nvms < min_registered_vms
s = h.storages.sort_by(&:free_space).last
s = h.storages.max_by(&:free_space)
unless s.nil?
host = h
storage = s
Expand Down

0 comments on commit b8268d3

Please sign in to comment.