-
Notifications
You must be signed in to change notification settings - Fork 898
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
Refactor refresh new target to use save_ems_inventory #14247
Conversation
This pull request is not mergeable. Please rebase and repush. |
055482f
to
0de059d
Compare
7d1e5a1
to
addf634
Compare
@Fryguy this replaces |
This pull request is not mergeable. Please rebase and repush. |
303cdc2
to
f303838
Compare
It feels quite invasive, so I'm not sure. I can't see any other way to accomplish what you are trying to do though, so I'm good with it. |
f303838
to
90cfdc4
Compare
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.
Looks great, from what I understand :)
TODO: need to rework the RHEV EventParser.parse_new_target to return the correct hash format
so, only RHV is using this currently anyway, right? Could we trigger them to produce a spec for their use case in order to have this PR here failing? I think their refresh_new_target
would fail with this merged, right?
@@ -1,5 +1,5 @@ | |||
module EmsRefresh::SaveInventory | |||
def save_ems_inventory(ems, hashes, target = nil) | |||
def save_ems_inventory(ems, hashes, target = nil, mode = :refresh) |
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.
how about a new method e.g. save_ems_inventory_no_disconnect
which just calls save_ems_inventory
with a mode other than :refresh
. This would save you from a 4-ary method signature like
save_ems_inventory(ems, target_hash, nil, :refresh_new_target)
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.
Good idea :) I'll give that a try, should clean this up a lot
I'm planning on using it for #14460 as well
YES! I'm planning on adding a RHEV save_new_target spec using one of their events
Correct this cannot be merged until we update their event parser to work with this format |
This pull request is not mergeable. Please rebase and repush. |
90cfdc4
to
dd55039
Compare
Here is the associated ovirt PR ManageIQ/manageiq-providers-ovirt#13 |
2907054
to
dae48ee
Compare
@blomquisg bump |
def save_resource_pools_inventory(ems, hashes, target = nil) | ||
target = ems if target.nil? | ||
def save_resource_pools_inventory(ems, hashes, target = nil, disconnect = true) | ||
target = ems if target.nil? && disconnect |
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.
Why && disconnect
here and not elsewhere?
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 seems vmware doesnt have |
40fbcf2
to
4a451ff
Compare
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.
One small quibble on a method name. Otherwise, I can understand what's going on here, which is saying quite a bit :)
dc = Datacenter.find_by(:ems_ref => dc_hash[:ems_ref], :ems_id => ems.id) | ||
dc.add_cluster(cluster) | ||
dc.save! | ||
def disconnect_using_association(ems, target, disconnect = true) |
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 method name makes it sound like it's going to do the disconnect.
What about:
calculate_disconnects
determine_disconnects
find_disconnects
(but that has an AR overlap)
Something like that?
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.
Hmm good point, how about determine_deletes_using_association
? Most callers set deletes = ...
so deletes
might be better than disconnects
anyway.
4a451ff
to
bf433bb
Compare
Checked commits agrare/manageiq@4444d75~...bf433bb with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
Now that ManageIQ/manageiq#14247 is merged we can enable the refresh_new_target test for the vmware refresher
After ManageIQ/manageiq#14247 was merged there are no more callers of obj_update_to_hash so it can be removed
By adding the ability for
save_ems_inventory
to work with a nil target we can delete the specializedsave_new_target
method which only worked for RHEV VMs and replace it with the generalsave_ems_inventory
method.Now any links that the caller wants to be made can be made, and any linked inventory that doesn't exist will be created just like a normal save_inventory would, so we can get rid of the specific calls to find or create linked inventory here
manageiq/app/models/ems_refresh/save_inventory_helper.rb
Lines 157 to 164 in c9e9ae1
Update RHV
parse_new_event
(Update parse_new_target to standard refresh hashes manageiq-providers-ovirt#13)Update VMware
obj_update_to_hash
Update for new refresh_new_target arguments manageiq-providers-vmware#55