Skip to content

Commit

Permalink
Fix event linking to a disconnected VM
Browse files Browse the repository at this point in the history
When linking events to a VM we first try [ems_id, ems_ref] which fails
to find a disconnected VM because the ems_id is nullified.  Next we try
by uid_ems but no one was setting the field that we were using so this
standardizes on an event key :vm_uid_ems (similar to :vm_location) which
can be set by the EventParser to allow events to be connected to VMs
after they are disconnected.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1538996
  • Loading branch information
agrare committed Jan 29, 2018
1 parent 40b6f3d commit f1e873b
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions app/models/ems_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,11 @@ def self.process_object_in_event!(klass, event, options = {})
def self.process_vm_in_event!(event, options = {})
prefix = options[:prefix]
options[:id_key] = "#{prefix}vm_or_template_id".to_sym
uid_ems = event.delete(:vm_uid_ems)
process_object_in_event!(Vm, event, options)

if options[:id_key] == :vm_or_template_id && event[:vm_or_template_id].nil?
# uid_ems is used for non-VC events, and should be nil for VC events.
uid_ems = event.fetch_path(:full_data, :vm, :uid_ems)
vm = VmOrTemplate.find_by(:uid_ems => uid_ems) unless uid_ems.nil?

vm = VmOrTemplate.find_by(:uid_ems => uid_ems) unless uid_ems.nil?
unless vm.nil?
event[:vm_or_template_id] = vm.id
event[:vm_name] ||= vm.name
Expand Down

0 comments on commit f1e873b

Please sign in to comment.