Skip to content

Commit

Permalink
Fixed quota calculations for multiple vms in requested method.
Browse files Browse the repository at this point in the history
Values for cloud providers were incorrect when multiple vms were selected.
Included Azure to cloud providers which was missing.

https://bugzilla.redhat.com/show_bug.cgi?id=1455844
  • Loading branch information
billfitzgerald0120 committed Jun 21, 2017
1 parent 706f32c commit 88a75a6
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 16 deletions.
Expand Up @@ -9,7 +9,7 @@ def request_info
end

def cloud?(prov_type)
%w(amazon openstack google).include?(prov_type)
%w(amazon openstack google azure).include?(prov_type)
end

def calculate_requested(options_hash = {})
Expand Down Expand Up @@ -224,39 +224,40 @@ def provision_type(resource)
end
end

def cloud_storage(flavor, dialog_array, resource)
return unless flavor

storage = if provision_type(resource) == 'google'
get_option_value(resource, :boot_disk_size).gigabytes
def cloud_storage(args_hash)
flavor = args_hash[:flavor]
storage = if provision_type(args_hash[:resource]) == 'google'
get_option_value(args_hash[:resource], :boot_disk_size).gigabytes
else
flavor.root_disk_size.to_i + flavor.ephemeral_disk_size.to_i + flavor.swap_disk_size.to_i
end
default_option(storage, dialog_array)
$evm.log(:info, "Retrieving cloud storage #{storage}")
default_option((storage * args_hash[:number_of_vms]), args_hash[:options_array])
end

def cloud_number_of_cpus(flavor, dialog_array)
return unless flavor
def cloud_number_of_cpus(args_hash)
flavor = args_hash[:flavor]
$evm.log(:info, "Retrieving cloud flavor #{flavor.name} cpus => #{flavor.cpus}")
default_option(flavor.cpus, dialog_array)
default_option((flavor.cpus * args_hash[:number_of_vms]), args_hash[:options_array])
end

def cloud_vm_memory(flavor, dialog_array)
return unless flavor
def cloud_vm_memory(args_hash)
flavor = args_hash[:flavor]
$evm.log(:info, "Retrieving flavor #{flavor.name} memory => #{flavor.memory}")
default_option(flavor.memory, dialog_array)
default_option((flavor.memory * args_hash[:number_of_vms]), args_hash[:options_array])
end

def cloud_value(args_hash)
return false unless args_hash[:cloud]
return false unless args_hash[:flavor]

case args_hash[:prov_option]
when :number_of_cpus
cloud_number_of_cpus(args_hash[:flavor], args_hash[:options_array])
cloud_number_of_cpus(args_hash)
when :vm_memory
cloud_vm_memory(args_hash[:flavor], args_hash[:options_array])
cloud_vm_memory(args_hash)
when :storage
cloud_storage(args_hash[:flavor], args_hash[:options_array], args_hash[:resource])
cloud_storage(args_hash)
end
end

Expand Down
18 changes: 18 additions & 0 deletions spec/automation/unit/method_validation/calculate_requested_spec.rb
Expand Up @@ -76,6 +76,24 @@ def check_results(requested_hash, storage, cpu, vms, memory)
end
end

context "VM provisioning multiple vms quota" do
it "vmware calculate_requested number of vms 3" do
setup_model("vmware")
@miq_provision_request.options[:number_of_vms] = 3
@miq_provision_request.save
ws = run_automate_method(vm_attrs)
check_results(ws.root['quota_requested'], 1536.megabytes, 12, 3, 3.gigabytes)
end

it "google calculate_requested number of vms 3" do
setup_model("google")
@miq_provision_request.options[:number_of_vms] = 3
@miq_provision_request.save
ws = run_automate_method(vm_attrs)
check_results(ws.root['quota_requested'], 30.gigabytes, 12, 3, 3.kilobytes)
end
end

context "VmReconfig quota calculate_request" do
it "add 2 cpus and add 4096 memory " do
setup_model("vmware_reconfigure")
Expand Down

0 comments on commit 88a75a6

Please sign in to comment.