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 Physical Disks save inventory #17972

Merged
merged 1 commit into from
Sep 18, 2018

Conversation

EsdrasVP
Copy link
Member

This PR is able to:

  • Fix the save inventory for Physical Disks to use multi instead of single

@EsdrasVP EsdrasVP changed the title Fix Physical Disks save inventory [WIP] Fix Physical Disks save inventory Sep 11, 2018
@miq-bot miq-bot added the wip label Sep 11, 2018
@EsdrasVP EsdrasVP force-pushed the fix_disks_save_inventory branch from 7f140ea to df8626c Compare September 11, 2018 14:21
@EsdrasVP EsdrasVP force-pushed the fix_disks_save_inventory branch from df8626c to 13d88e1 Compare September 17, 2018 13:52
@EsdrasVP EsdrasVP changed the title [WIP] Fix Physical Disks save inventory Fix Physical Disks save inventory Sep 17, 2018
@miq-bot miq-bot removed the wip label Sep 17, 2018
@rodneyhbrown7
Copy link

Request related to RFE: https://bugzilla.redhat.com/show_bug.cgi?id=1629900

save_inventory_single(:physical_disk, parent, hash)
def save_physical_disks_inventory(physical_storage, hashes, target = nil)
return if hashes.nil?
deletes = target == physical_storage ? :use_association : []
Copy link
Member

Choose a reason for hiding this comment

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

For these child collections you should just use the association as long as the target type cannot an instance of this collection.
Unless you expect to actually get physical_storage as a top-level refresh target just pass :use_association into save_inventory_multi

Copy link
Member

Choose a reason for hiding this comment

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

The end result of this will be that no physical_disks will ever be deleted, because the target will always be the EMS.

Copy link
Member Author

Choose a reason for hiding this comment

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

For these child collections you should just use the association as long as the target type cannot an instance of this collection.
Unless you expect to actually get physical_storage as a top-level refresh target just pass :use_association into save_inventory_multi

@agrare I changed it to use :use_association unless PhysicalStorage is assigned as the target since these disks are related to physical storage units, this also solves the deletion problem. Though I'm still thinking if it's interesting to use EMS instead of PhysicalStorage as default in case other providers decide to use this model. What do you think?

@EsdrasVP EsdrasVP force-pushed the fix_disks_save_inventory branch from 13d88e1 to 3251e00 Compare September 18, 2018 15:46
def save_physical_disks_inventory(physical_storage, hashes, target = nil)
return if hashes.nil?
target = physical_storage if target.nil?
deletes = target == physical_storage ? :use_association : []
Copy link
Member

Choose a reason for hiding this comment

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

Actually since these are only under a physical storage, there is no case where you wouldn't want to :use_association
This is usually meant for top level collections (e.g. if you had ems.physical_disks and you target e.g. a physical_host not the full ems).

Just take this out and pass :use_association to save_inventory_multi

Copy link
Member Author

Choose a reason for hiding this comment

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

@agrare Ok, got it, I changed it to pass :use_association directly to save_inventory_multi.

@EsdrasVP EsdrasVP force-pushed the fix_disks_save_inventory branch from 3251e00 to 2f83774 Compare September 18, 2018 19:33
@miq-bot
Copy link
Member

miq-bot commented Sep 18, 2018

Checked commit EsdrasVP@2f83774 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 merged commit cfacaf1 into ManageIQ:master Sep 18, 2018
@agrare agrare added this to the Sprint 95 Ending Sep 24, 2018 milestone Sep 18, 2018
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