Skip to content

Commit

Permalink
Merge pull request #17240 from agrare/save_inventory_log_vm_or_template
Browse files Browse the repository at this point in the history
Log Vm or Template for Create/Update
  • Loading branch information
bdunne authored Apr 2, 2018
2 parents 1b18fb1 + d63413b commit 00be65b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/models/ems_refresh/save_inventory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,12 @@ def save_vms_inventory(ems, hashes, target = nil, disconnect = true)
found = found_dups if found.empty?
end
end
found = found.first

type = h[:template] ? "Template" : "Vm"

found = found.first
if found.nil?
_log.info("#{log_header} Creating Vm [#{h[:name]}] location: [#{h[:location]}] storage id: [#{h[:storage_id]}] uid_ems: [#{h[:uid_ems]}] ems_ref: [#{h[:ems_ref]}]")
_log.info("#{log_header} Creating #{type} [#{h[:name]}] location: [#{h[:location]}] storage id: [#{h[:storage_id]}] uid_ems: [#{h[:uid_ems]}] ems_ref: [#{h[:ems_ref]}]")

# Handle the off chance that we are adding an "unknown" Vm to the db
h[:location] = "unknown" if h[:location].blank?
Expand All @@ -120,7 +122,7 @@ def save_vms_inventory(ems, hashes, target = nil, disconnect = true)
vms_by_uid_ems[h[:uid_ems]].delete(found)
h.delete(:type)

_log.info("#{log_header} Updating Vm [#{found.name}] id: [#{found.id}] location: [#{found.location}] storage id: [#{found.storage_id}] uid_ems: [#{found.uid_ems}] ems_ref: [#{h[:ems_ref]}]")
_log.info("#{log_header} Updating #{type} [#{found.name}] id: [#{found.id}] location: [#{found.location}] storage id: [#{found.storage_id}] uid_ems: [#{found.uid_ems}] ems_ref: [#{h[:ems_ref]}]")
found.update_attributes!(h)
disconnects_index.delete(found)
end
Expand Down

0 comments on commit 00be65b

Please sign in to comment.