-
Notifications
You must be signed in to change notification settings - Fork 897
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
Conversation
7f140ea
to
df8626c
Compare
df8626c
to
13d88e1
Compare
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 : [] |
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 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
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.
The end result of this will be that no physical_disks will ever be deleted, because the target will always be the EMS.
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 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
intosave_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?
13d88e1
to
3251e00
Compare
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 : [] |
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.
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
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.
@agrare Ok, got it, I changed it to pass :use_association
directly to save_inventory_multi
.
3251e00
to
2f83774
Compare
Checked commit EsdrasVP@2f83774 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
This PR is able to: