Skip to content

Commit

Permalink
Add hardware's custom finder and vm's check_changed
Browse files Browse the repository at this point in the history
Add hardware's custom finder and vm's check_changed
  • Loading branch information
Ladas committed Jan 9, 2017
1 parent b12cca1 commit c8c0ee2
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ def init_data(model_class, attributes, extra_attributes)

def vms_init_data(extra_attributes = {})
attributes = {
:association => :vms,
:association => :vms,
# TODO(lsmola) replace genealogy_parent with db relation and do computing of genealogyparent in a separate queued
# job. Then we can check for changed? again, otherwise the after save hood on vmOrTemplate will not fire and
# the association to genealogy_parent will not populate, if list of templates changed (like allowing collection
# of public images )
:check_changed => false

}

init_data(::ManageIQ::Providers::Amazon::CloudManager::Vm, attributes, extra_attributes)
Expand Down Expand Up @@ -55,10 +61,16 @@ def hardwares_init_data(extra_attributes = {})
:association => :hardwares
}

if extra_attributes[:strategy] == :local_db_cache_all
case extra_attributes[:strategy]
when :local_db_cache_all
attributes[:custom_manager_uuid] = lambda do |hardware|
[hardware.vm_or_template.ems_ref]
end
when :find_missing_in_local_db
attributes[:custom_db_finder] = lambda do |inventory_collection, hash_uuid_by_ref|
inventory_collection.parent.send(inventory_collection.association).references(:vm_or_template).where(
:vms => {:ems_ref => hash_uuid_by_ref[:vm_or_template]}).first
end
end

init_data(::Hardware, attributes, extra_attributes)
Expand Down

0 comments on commit c8c0ee2

Please sign in to comment.