Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cloud provision quota memory and cpu counting #22517

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions app/models/mixins/miq_provision_quota_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,9 @@ def flavor(request)
end

def number_of_cpus(prov, cloud, flavor_obj)
return flavor_obj.try(:cpus) if cloud
num_cpus = flavor_obj.try(:cpus) if cloud
return num_cpus if num_cpus.present?

request = prov.kind_of?(MiqRequest) ? prov : prov.miq_request
num_cpus = request.get_option(:number_of_sockets).to_i * request.get_option(:cores_per_socket).to_i
num_cpus.zero? ? request.get_option(:number_of_cpus).to_i : num_cpus
Expand All @@ -384,7 +386,9 @@ def storage(prov, cloud, vendor, flavor_obj = nil)
end

def memory(prov, cloud, vendor, flavor_obj = nil)
return flavor_obj.try(:memory) if cloud
memory = flavor_obj.try(:memory) if cloud
return memory if memory.present?

request = prov.kind_of?(MiqRequest) ? prov : prov.miq_request
memory = request.get_option(:vm_memory).to_i
%w(amazon openstack google).include?(vendor) ? memory : memory.megabytes
Expand Down