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

Save mappings to options hash when calculated #18194

Merged
merged 2 commits into from
Nov 13, 2018

Conversation

ghost
Copy link

@ghost ghost commented Nov 13, 2018

When calculating the network mappings and virtv2v disks, we add them to the task options hash for future consumption, such as when building the virt-v2v-wrapper options. This PR effectively save the options hash, when previous code only changed the in-memory value.

Associated RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1649020

@ghost
Copy link
Author

ghost commented Nov 13, 2018

@miq-bot add-label transformation, bug, hammer/yes, blocker
@miq-bot add-reviewer agrare

:weight => disk.size.to_f / source.allocated_disk_storage.to_f * 100
}
options[:virtv2v_disks] ||= calculate_virtv2v_disks.tap do |disks|
update_attributes(:options => options.merge(:virtv2v_disks => disks))
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about just

return options[:virtv2v_disks] if options[:virtv2v_disks].present?

options[:virtv2v_disks] = calculate_virtv2v_disks
save!

options[:virtv2v_disks]

@miq-bot
Copy link
Member

miq-bot commented Nov 13, 2018

Checked commits fabiendupont/manageiq@b823e91~...2698585 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
1 file checked, 0 offenses detected
Everything looks fine. 🍰

@agrare agrare self-assigned this Nov 13, 2018
@agrare agrare requested a review from jameswnl November 13, 2018 17:58
@agrare
Copy link
Member

agrare commented Nov 13, 2018

@jameswnl PTAL

@jameswnl
Copy link
Contributor

Looks ok to me. Just not sure if breaking into 2 new methods is doing any good

end
return options[:virtv2v_disks] if options[:virtv2v_disks].present?

options[:virtv2v_disks] = calculate_virtv2v_disks
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you would need to do self.options[...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually no need. the reference is unambiguous enough to hitting the record's attribute

Copy link
Contributor

@jameswnl jameswnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@agrare agrare merged commit 3b7f61a into ManageIQ:master Nov 13, 2018
@agrare agrare added this to the Sprint 99 Ending Nov 19, 2018 milestone Nov 13, 2018
simaishi pushed a commit that referenced this pull request Nov 13, 2018
…rst_call

Save mappings to options hash when calculated

(cherry picked from commit 3b7f61a)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1649020
@simaishi
Copy link
Contributor

Hammer backport details:

$ git log -1
commit 03b81fd750b7ee20987d696739948ac794755133
Author: Adam Grare <agrare@redhat.com>
Date:   Tue Nov 13 14:58:02 2018 -0500

    Merge pull request #18194 from fdupont-redhat/v2v_save_mappings_on_first_call
    
    Save mappings to options hash when calculated
    
    (cherry picked from commit 3b7f61a40822d7953a35924e37e63903ac143b68)
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1649020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants