Skip to content

Commit

Permalink
Merge pull request #12931 from agrare/vmware/infra/bz_1397951_auto_pl…
Browse files Browse the repository at this point in the history
…acement_free_space

Fix auto-placement for hosts without a datastore that can hold the new VM
(cherry picked from commit 28ea141)

https://bugzilla.redhat.com/show_bug.cgi?id=1404455
  • Loading branch information
gmcculloug authored and chessbyte committed Dec 13, 2016
1 parent 23d82c6 commit 2e6dc7d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Expand Up @@ -19,7 +19,8 @@
nvms = h.vms.length

if min_registered_vms.nil? || nvms < min_registered_vms
s = h.writable_storages.max_by(&:free_space)
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.max_by(&:free_space)
unless s.nil?
host = h
storage = s
Expand Down
Expand Up @@ -19,7 +19,8 @@
next unless h.power_state == "on"
nvms = h.vms.length
if min_registered_vms.nil? || nvms < min_registered_vms
s = h.writable_storages.sort { |a, b| a.free_space <=> b.free_space }.last
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.max_by(&:free_space)
unless s.nil?
host = h
storage = s
Expand Down

0 comments on commit 2e6dc7d

Please sign in to comment.