Skip to content

Commit

Permalink
Targeting host fails
Browse files Browse the repository at this point in the history
When ever a host is targeted event parsing fail since it is not possible to
build `vm_location`. We make sure that it is not calculated when targeting a host.

Bug-Url:
https://bugzilla.redhat.com/1520513
  • Loading branch information
pkliczewski committed Dec 6, 2017
1 parent f017be8 commit 8458734
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def self.event_to_hash(event, ems_id = nil)
vm_ref = template?(event.name) ? ems_ref_from_object_in_event(event.template) : ems_ref_from_object_in_event(event.vm)

# Build the event hash
{
hash = {
:event_type => event.name,
:source => 'RHEVM',
:message => event.description,
Expand All @@ -27,18 +27,23 @@ def self.event_to_hash(event, ems_id = nil)
:vm_ems_ref => vm_ref,
:host_ems_ref => ems_ref_from_object_in_event(event.host),
:ems_cluster_ems_ref => ems_ref_from_object_in_event(event.cluster),
:vm_location => vm_location(event.data_center, vm_ref)
}

add_vm_location(hash, event.data_center, vm_ref)
end

def self.vm_location(dc, vm_ref)
def self.add_vm_location(hash, dc, vm_ref)
return hash if vm_ref.nil?

uid_ems = ManageIQ::Providers::Redhat::InfraManager.extract_ems_ref_id(vm_ref)
location = "#{uid_ems}.ovf"
return location if dc.blank?

dc_ref = ems_ref_from_object_in_event(dc)
dc_uid = ManageIQ::Providers::Redhat::InfraManager.extract_ems_ref_id(dc_ref)
File.join('/rhev/data-center', dc_uid, 'mastersd/master/vms', uid_ems, location)

hash[:vm_location] = File.join('/rhev/data-center', dc_uid, 'mastersd/master/vms', uid_ems, location)
hash
end

def self.ems_ref_from_object_in_event(data)
Expand Down

0 comments on commit 8458734

Please sign in to comment.