Skip to content

Commit

Permalink
Merge pull request #195 from mansam/fix-event-target-parser-paths
Browse files Browse the repository at this point in the history
Correct the paths that event target IDs are parsed from
(cherry picked from commit 9b1c62b)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1535154
  • Loading branch information
aufi authored and simaishi committed Jan 16, 2018
1 parent 1c1ba1a commit 9fd685e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,30 +46,30 @@ def add_target(target_collection, association, ref)
end

def collect_compute_instance_references!(target_collection, ems_event)
instance_id = ems_event.full_data.fetch_path(:payload, 'instance_id')
instance_id = ems_event.full_data.fetch_path(:content, 'payload', 'instance_id')
add_target(target_collection, :vms, instance_id) if instance_id
end

def collect_image_references!(target_collection, ems_event)
resource_id = ems_event.full_data.fetch_path(:payload, 'resource_id')
resource_id = ems_event.full_data.fetch_path(:content, 'payload', 'resource_id')
add_target(target_collection, :images, resource_id) if resource_id
end

def collect_identity_tenant_references!(target_collection, ems_event)
tenant_id = ems_event.full_data.fetch_path(:payload, 'tenant_id') || ems_event.full_data.fetch_path(:payload, 'project_id') || ems_event.full_data.fetch_path(:payload, 'initiator', 'project_id')
tenant_id = ems_event.full_data.fetch_path(:content, 'payload', 'tenant_id') || ems_event.full_data.fetch_path(:content, 'payload', 'project_id') || ems_event.full_data.fetch_path(:content, 'payload', 'initiator', 'project_id')
add_target(target_collection, :cloud_tenants, tenant_id) if tenant_id
end

def collect_orchestration_stack_references!(target_collection, ems_event)
stack_id = ems_event.full_data.fetch_path(:payload, 'stack_id')
tenant_id = ems_event.full_data.fetch_path(:payload, 'tenant_id')
stack_id = ems_event.full_data.fetch_path(:content, 'payload', 'stack_id')
tenant_id = ems_event.full_data.fetch_path(:content, 'payload', 'tenant_id')
target_collection.add_target(:association => :orchestration_stacks, :manager_ref => {:ems_ref => stack_id}, :options => {:tenant_id => tenant_id})
end

def collect_host_aggregate_references!(target_collection, ems_event)
# aggregate events from ceilometer don't have an id field for the aggregate,
# but they do have a "service" field in the form of "aggregate.<id>"
aggregate_id = ems_event.full_data.fetch_path(:payload, 'service')
aggregate_id = ems_event.full_data.fetch_path(:content, 'payload', 'service')
aggregate_id&.sub!('aggregate.', '')
add_target(target_collection, :host_aggregates, aggregate_id) if aggregate_id
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ def parse_ems_event_targets(ems_event)
:security_groups
end

resource_id = ems_event.full_data.fetch_path(:payload, 'resource_id')
resource_id = ems_event.full_data.fetch_path(:content, 'payload', 'resource_id')
add_target(target_collection, target_type, resource_id) if resource_id

target_collection.targets
end

def collect_identity_tenant_references!(target_collection, ems_event)
tenant_id = ems_event.full_data.fetch_path(:payload, 'tenant_id') || ems_event.full_data.fetch_path(:payload, 'project_id') || ems_event.full_data.fetch_path(:payload, 'initiator', 'project_id')
tenant_id = ems_event.full_data.fetch_path(:content, 'payload', 'tenant_id') || ems_event.full_data.fetch_path(:content, 'payload', 'project_id') || ems_event.full_data.fetch_path(:content, 'payload', 'initiator', 'project_id')
add_target(target_collection, :cloud_tenants, tenant_id) if tenant_id
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def create_ems_event(event_type, payload)
:message => payload,
:timestamp => "2016-03-13T16:59:01.760000",
:username => "",
:full_data => {:payload => payload },
:full_data => {:content => {'payload' => payload}},
:ems_id => @ems.id
}
EmsEvent.add(@ems.id, event_hash)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def create_ems_event(event_type, payload)
:message => payload,
:timestamp => "2016-03-13T16:59:01.760000",
:username => "",
:full_data => {:payload => payload },
:full_data => {:content => {'payload' => payload}},
:ems_id => @ems.network_manager.id
}
EmsEvent.add(@ems.network_manager.id, event_hash)
Expand Down

0 comments on commit 9fd685e

Please sign in to comment.