---
src/app/models/instance_event.rb | 5 +++++
src/dbomatic/dbomatic | 19 ++++++++++++++++---
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/src/app/models/instance_event.rb b/src/app/models/instance_event.rb
index 5076f8a..e5c619a 100644
--- a/src/app/models/instance_event.rb
+++ b/src/app/models/instance_event.rb
@@ -23,4 +23,9 @@ class InstanceEvent < ActiveRecord::Base
validates_presence_of :instance_id
validates_presence_of :event_type
+
+ EVENT_TYPE_STARTED = 'InstanceStarted'
+ EVENT_TYPE_STOPPED = 'InstanceStopped'
+ EVENT_TYPES = [EVENT_TYPE_STARTED, EVENT_TYPE_STOPPED]
+
end
diff --git a/src/dbomatic/dbomatic b/src/dbomatic/dbomatic
index 7434d36..88dad26 100755
--- a/src/dbomatic/dbomatic
+++ b/src/dbomatic/dbomatic
@@ -61,6 +61,16 @@ end
CONDOR_EVENT_LOG_FILE = "#{condor_event_log_dir}/EventLog"
EVENT_LOG_POS_FILE = "#{dbomatic_run_dir}/event_log_position"
+# Simple translation helper, map condor event types to dbomatic ones
+def condor_event_to_dbomatic_event(condor_event)
+ case condor_event
+ when 'ExecuteEvent' then InstanceEvent::EVENT_TYPE_STARTED
+ when 'JobTerminted' then InstanceEvent::EVENT_TYPE_STOPPED
+ # when 'JobAdInformationEvent' then ...
+ else nil
+ end
+end
+
# Handle the event log's xml
class CondorEventLog < Nokogiri::XML::SAX::Document
attr_accessor :tag, :event_type, :event_cmd, :event_time
@@ -94,9 +104,12 @@ class CondorEventLog < Nokogiri::XML::SAX::Document
puts "Unexpected nil instance, skipping..."
else
puts "Instance event #{inst.name} #...@event_type} #...@event_time}"
- InstanceEvent.create! :instance => inst,
- :event_type => @event_type,
- :event_time => @event_time
+ @event_type = condor_event_to_dbomatic_event(@event_type)
+ unless @event_type.nil?
+ InstanceEvent.create! :instance => inst,
+ :event_type => @event_type,
+ :event_time => @event_time
+ end
end
@tag = @event_type = @event_cmd = @event_time = nil
end
--
1.7.2.1
_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel