diff --git a/content/automate/ManageIQ/System/CommonMethods/QuotaMethods.class/__methods__/requested.rb b/content/automate/ManageIQ/System/CommonMethods/QuotaMethods.class/__methods__/requested.rb index fbc980b6b..d2a77ceed 100644 --- a/content/automate/ManageIQ/System/CommonMethods/QuotaMethods.class/__methods__/requested.rb +++ b/content/automate/ManageIQ/System/CommonMethods/QuotaMethods.class/__methods__/requested.rb @@ -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 = {}) @@ -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 diff --git a/spec/automation/unit/method_validation/calculate_requested_spec.rb b/spec/automation/unit/method_validation/calculate_requested_spec.rb index beb196b0c..7c1d4b64e 100644 --- a/spec/automation/unit/method_validation/calculate_requested_spec.rb +++ b/spec/automation/unit/method_validation/calculate_requested_spec.rb @@ -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")