Skip to content

Commit

Permalink
Cleaning of the data persited in the full_data columm
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlleDaniel committed May 23, 2018
1 parent 8a1b36d commit 8985d7a
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class ManageIQ::Providers::Lenovo::PhysicalInfraManager::EventCatcher::Event

def initialize(data)
@data = data
end

def to_hash
{
:event_type => @data.msgID,
:ems_ref => @data.cn,
:source => "LenovoXclarity",
:message => @data.msg,
:timestamp => @data.timeStamp,
:component_id => @data.componentID,
:severity => @data.severity,
:severity_type => @data.severityText,
:sender_uuid => @data.senderUUID,
:sender_name => @data.systemName,
:sender_model => @data.systemTypeModelText,
:sender_type => @data.systemTypeText,
:type => @data.typeText
}
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def stop
def each_batch
$log.info('Starting collect of LXCA events ...')
while @collect_events
yield(events.collect { |e| ManageIQ::Providers::Lenovo::PhysicalInfraManager::EventParser.event_to_hash(e, @ems.id) })
yield(parse_events(events))
end
$log.info('Stopping collect of LXCA events ...')
end
Expand All @@ -27,12 +27,19 @@ def filter_fields
{ :operation => 'NOT', :field => 'eventClass', :value => '200' },
{ :operation => 'NOT', :field => 'eventClass', :value => '800' }
]
last_cn_event = get_last_cnn_from_events(@ems.id)
last_cn_event = get_last_ems_ref(@ems.id)
cn_operation = { :operation => 'GT', :field => 'cn', :value => last_cn_event.to_s }
fields.push(cn_operation) unless last_cn_event.nil?
fields
end

def parse_events(events)
events.collect do |data|
event = ManageIQ::Providers::Lenovo::PhysicalInfraManager::EventCatcher::Event.new(data).to_hash
ManageIQ::Providers::Lenovo::PhysicalInfraManager::EventParser.event_to_hash(event, @ems.id)
end
end

def events
expression = { :filterType => 'FIELDNOTREGEXAND', :fields => filter_fields }

Expand All @@ -54,7 +61,7 @@ def create_event_connection(ems)
:port => ems.endpoints.first.port)
end

def get_last_cnn_from_events(ems_id)
EventStream.where(:ems_id => ems_id).maximum('ems_ref') || 1
def get_last_ems_ref(ems_id)
EventStream.where(:ems_id => ems_id).maximum('CAST(ems_ref AS int)') || 1
end
end
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module ManageIQ::Providers::Lenovo::PhysicalInfraManager::EventParser
def self.event_to_hash(event, ems_id)
event_hash = {
:event_type => event.msgID,
:ems_ref => event.cn,
:source => "LenovoXclarity",
:physical_server_id => get_physical_server_id(event.componentID),
:message => event.msg,
:timestamp => event.timeStamp,
:full_data => event.to_hash,
:event_type => event[:event_type],
:ems_ref => event[:ems_ref],
:source => event[:source],
:physical_server_id => get_physical_server_id(event[:component_id]),
:message => event[:message],
:timestamp => event[:timestamp],
:full_data => event,
:ems_id => ems_id
}

Expand Down

0 comments on commit 8985d7a

Please sign in to comment.