Skip to content

Commit

Permalink
Merge pull request #671 from agrare/fix_event_target_parser_event_str…
Browse files Browse the repository at this point in the history
…ing_keys

Fix EventTargetParser looking for string keys
  • Loading branch information
Fryguy authored Jun 28, 2024
2 parents 147386e + fea643f commit c7ce32d
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,29 @@ def initialize(ems_event)
def parse
target_collection = InventoryRefresh::TargetCollection.new(:manager => ems_event.ext_management_system, :event => ems_event)

data = ems_event.full_data
data = ems_event.full_data.deep_symbolize_keys

add_vm_target(target_collection, data["vm"]) if data["vm"].present?
add_template_target(target_collection, data["template"]) if data["template"].present?
add_cluster_target(target_collection, data["cluster"]) if data["cluster"].present?
add_vm_target(target_collection, data[:vm]) if data[:vm].present?
add_template_target(target_collection, data[:template]) if data[:template].present?
add_cluster_target(target_collection, data[:cluster]) if data[:cluster].present?

target_collection.targets
end

private

def add_vm_target(target_collection, vm_data)
ems_ref = ManageIQ::Providers::Ovirt::InfraManager.make_ems_ref(vm_data["href"])
ems_ref = ManageIQ::Providers::Ovirt::InfraManager.make_ems_ref(vm_data[:href])
target_collection.add_target(:association => :vms, :manager_ref => {:ems_ref => ems_ref})
end

def add_template_target(target_collection, template_data)
ems_ref = ManageIQ::Providers::Ovirt::InfraManager.make_ems_ref(template_data["href"])
ems_ref = ManageIQ::Providers::Ovirt::InfraManager.make_ems_ref(template_data[:href])
target_collection.add_target(:association => :miq_templates, :manager_ref => {:ems_ref => ems_ref})
end

def add_cluster_target(target_collection, cluster_data)
ems_ref = ManageIQ::Providers::Ovirt::InfraManager.make_ems_ref(cluster_data["href"])
ems_ref = ManageIQ::Providers::Ovirt::InfraManager.make_ems_ref(cluster_data[:href])
target_collection.add_target(:association => :ems_clusters, :manager_ref => {:ems_ref => ems_ref})
end
end

0 comments on commit c7ce32d

Please sign in to comment.