-
Notifications
You must be signed in to change notification settings - Fork 120
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
Fixed quota calculations for multiple vms in requested method. #128
Fixed quota calculations for multiple vms in requested method. #128
Conversation
@tinaafitz |
@billfitzgerald0120 Looks good. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gmcculloug Looks good, please review.
@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, 3072) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency 3072
should be 3.kilobytes
.
def cloud_number_of_cpus(args_hash) | ||
return unless args_hash[:flavor] | ||
$evm.log(:info, "Retrieving cloud flavor #{args_hash[:flavor].name} cpus => #{args_hash[:flavor].cpus}") | ||
default_option((args_hash[:flavor].cpus * args_hash[:number_of_vms]), args_hash[:options_array]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two comments that apply to the 3 cloud calculation methods update in this PR.
- The methods
cloud_number_of_cpus
,cloud_vm_memory
andcloud_storage
all start with the conditionreturn unless args_hash[:flavor]
. These methods are only called from one methodcloud_value
.
I would move this check into the caller and the methods can assume that they are being called only when a flavor is present in the hash.
- Constantly dereferencing
args_hash[:flavor]
is not efficient and makes the logic harder to read. Change the methods to set the variableflavor
at the top of the methods.
As an example, with these two changes the cloud_vm_memory
method would become:
def cloud_vm_memory(args_hash)
flavor = args_hash[:flavor]
$evm.log(:info, "Retrieving flavor #{flavor.name} memory => #{flavor.memory}")
default_option((flavor.memory * args_hash[:number_of_vms]), args_hash[:options_array])
end
Note: Since the other two args_hash
values are only referenced once I did not assign them to variables.
3b0cb5d
to
7107a26
Compare
@gmcculloug @tinaafitz Made all changes except for cloud_storage which doesn't use flavor for Google. |
@billfitzgerald0120 @tinaafitz Is there a valid use-case where we are evaluating quota without the flavor selected? Understanding that Google does not need it for storage does it make sense doing the storage calculation for any of the cloud providers if we know memory and cpu values will be Also want to note that -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' Just trying to rationalize the need for the added complexity. |
7107a26
to
f123b98
Compare
cloud_vm_memory(args_hash[:flavor], args_hash[:options_array]) | ||
when :storage | ||
cloud_storage(args_hash[:flavor], args_hash[:options_array], args_hash[:resource]) | ||
if args_hash[:flavor] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@billfitzgerald0120 I would prefer this be an early return
like the unless args_hash[:cloud]
check above and avoid wrapping the case
statement in a condition block.
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
f123b98
to
88a75a6
Compare
Checked commit billfitzgerald0120@88a75a6 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
@gmcculloug @tinaafitz Made changes as requested. |
@tinaafitz Can you give this one more quick review after the last round of changes? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@billfitzgerald0120 @gmcculloug Looks good.
Euwe backport (to manageiq repo) details:
|
Fixed quota calculations for multiple vms in requested method. (cherry picked from commit 85dd441) https://bugzilla.redhat.com/show_bug.cgi?id=1465087
Fine backport details:
|
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
@miq-bot add_label bug, fine/yes, euwe/yes