also renamed 'dbomatic.rb' executable to 'dbomatic'
---
 conf/deltacloud-dbomatic      |   75 ++++++++++++++++++++++++++
 deltacloud-aggregator.spec.in |    5 ++
 src/dbomatic/dbomatic         |  115 +++++++++++++++++++++++++++++++++++++++++
 src/dbomatic/dbomatic.rb      |  114 ----------------------------------------
 4 files changed, 195 insertions(+), 114 deletions(-)
 create mode 100755 conf/deltacloud-dbomatic
 create mode 100755 src/dbomatic/dbomatic
 delete mode 100644 src/dbomatic/dbomatic.rb

diff --git a/conf/deltacloud-dbomatic b/conf/deltacloud-dbomatic
new file mode 100755
index 0000000..2f59378
--- /dev/null
+++ b/conf/deltacloud-dbomatic
@@ -0,0 +1,75 @@
+#!/bin/bash
+#
+#
+# deltacloud-dbomatic       startup script for deltacloud-dbomatic
+#
+# chkconfig: - 97 03
+# description: deltacloud-dbomatic populates the Deltacloud Aggregator
+#    db from the Deltacloud scheduler's output.
+
+DELTACLOUD_DIR="${DELTACLOUD_DIR:-/usr/share/deltacloud-aggregator}"
+DBOMATIC_LOG="${DBOMATIC_LOG:-/var/log/deltacloud-aggregator/dbomatic.log}"
+DBOMATIC_PID="${DBOMATIC_PID:-/var/run/deltacloud-aggregator/dbomatic.pid}"
+DBOMATIC_LOCKFILE="${DBOMATIC_LOCKFILE:-/var/lock/subsys/deltacloud-dbomatic }"
+USER="${USER:-dcloud}"
+GROUP="${GROUP:-dcloud}"
+
+DBOMATIC_PATH=/usr/share/deltacloud-aggregator/dbomatic
+DBOMATIC_PROC=dbomatic
+
+. /etc/init.d/functions
+
+start() {
+    echo -n "Starting deltacloud-dbomatic: "
+
+    $DBOMATIC_PATH/$DBOMATIC_PROC&
+    RETVAL=$?
+    if [ $RETVAL -eq 0 ] && touch $DBOMATIC_LOCKFILE ; then
+      echo_success
+      echo
+    else
+      echo_failure
+      echo
+    fi
+}
+
+stop() {
+    echo -n "Shutting down deltacloud-dbomatic: "
+    killall $DBOMATIC_PROC
+    RETVAL=$?
+    if [ $RETVAL -eq 0 ] && rm -f $DBOMATIC_LOCKFILE ; then
+      echo_success
+      echo
+    else
+      echo_failure
+      echo
+    fi
+}
+
+case "$1" in
+    start)
+      start
+           ;;
+    stop)
+      stop
+      ;;
+    restart)
+      stop
+      start
+      ;;
+    reload)
+      ;;
+    force-reload)
+      restart
+      ;;
+    status)
+           status $DBOMATIC_PROG
+           RETVAL=$?
+           ;;
+    *)
+      echo "Usage: deltacloud-dbomatic {start|stop|restart|status}"
+      exit 1
+  ;;
+esac
+
+exit $RETVAL
diff --git a/deltacloud-aggregator.spec.in b/deltacloud-aggregator.spec.in
index 38df894..f952fa5 100644
--- a/deltacloud-aggregator.spec.in
+++ b/deltacloud-aggregator.spec.in
@@ -84,6 +84,7 @@ mv %{buildroot}/%{app_root}/doc %{buildroot}/%{app_root}/test 
%{buildroot}/%{doc
 
 # copy over init scripts and various config
 %{__cp} conf/deltacloud-aggregator %{buildroot}%{_initrddir}
+%{__cp} conf/deltacloud-dbomatic %{buildroot}%{_initrddir}
 %{__cp} conf/deltacloud-portal.conf 
%{buildroot}%{_sysconfdir}/httpd/conf.d/deltacloud-aggregator.conf
 %{__cp} conf/deltacloud-portal.logrotate 
%{buildroot}%{_sysconfdir}/logrotate.d/deltacloud-aggregator
 %{__cp} conf/deltacloud-aggregator.sysconf 
%{buildroot}%{_sysconfdir}/sysconfig/deltacloud-aggregator
@@ -150,6 +151,7 @@ fi
 %files daemons
 %defattr(-,root,root,-)
 %{_initrddir}/deltacloud-aggregator
+%{_initrddir}/deltacloud-dbomatic
 %config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
 %config(noreplace) %{_sysconfdir}/sysconfig/deltacloud-aggregator
 %config(noreplace) %{_sysconfdir}/sysconfig/deltacloud-rails
@@ -165,6 +167,9 @@ fi
 %doc README AUTHORS COPYING
 
 %changelog
+* Tue Sep 07 2010 Mohammed Morsi <mmo...@redhat.com> - 0.0.2-3
+- added dbomatic init script
+
 * Sat Mar 6 2010 Ian Main <im...@redhat.com> - 0.0.2-2
 - removed taskomatic from packaging.
 
diff --git a/src/dbomatic/dbomatic b/src/dbomatic/dbomatic
new file mode 100755
index 0000000..22415ec
--- /dev/null
+++ b/src/dbomatic/dbomatic
@@ -0,0 +1,115 @@
+#!/usr/bin/ruby
+# Copyright (C) 2010 Red Hat, Inc.
+# Written by Mohammed Morsi <mmo...@redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA  02110-1301, USA.  A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+
+$: << File.join(File.dirname(__FILE__), "../dutils")
+require 'dutils'
+require 'nokogiri'
+require 'rb-inotify'
+
+CONDOR_EVENT_LOG_DIR    =   "/var/log/condor"
+CONDOR_EVENT_LOG_FILE   =   "#{CONDOR_EVENT_LOG_DIR}/EventLog"
+EVENT_LOG_POS_FILE      =   "/var/run/dbomatic/event_log_position"
+
+# Handle the event log's xml
+class CondorEventLog < Nokogiri::XML::SAX::Document
+  attr_accessor :tag, :event_type, :event_cmd, :event_time
+
+  # Store the name of the event log attribute we're looking at
+  def start_element(element, attributes)
+    @tag = attributes[1] if element == "a"
+  end
+
+  # Store the value of the event log attribute we're looking at
+  def characters(string)
+    unless string.strip == ""
+      if @tag == "MyType"
+        @event_type = string
+      elsif @tag == "Cmd"
+        @event_cmd = string
+      elsif @tag == "EventTime"
+        @event_time = string
+      end
+    end
+  end
+
+  # Create a new entry for events which we have all the neccessary data for
+  def end_element(element)
+    if element == "c" && !...@event_cmd.nil?
+      # Condor may write to event log before condormatic returns and instance
+      # table is updated. Extract instance name from event_cmd and query on 
that
+      inst_name = @event_cmd[4,@event_cmd.size-4].gsub(/_[0-9]*$/, '')
+      inst = Instance.find(:first, :conditions => ['name = ?', inst_name])
+      puts "Instance event #{inst.name} #...@event_type} #...@event_time}"
+      InstanceEvent.create! :instance => inst,
+                            :event_type => @event_type,
+                            :event_time => @event_time
+      @tag = @event_type = @event_cmd = @event_time = nil
+    end
+  end
+end
+parser = Nokogiri::XML::SAX::PushParser.new(CondorEventLog.new)
+
+# XXX hack, condor event log doesn't seem to have a top level element
+# enclosing everything else in the doc (as standards conforming xml must).
+# Create one for parsing purposes.
+parser << "<events>"
+
+def parse_log_file(log_file, parser)
+  while s = log_file.gets
+    parser << s
+  end
+  File.open(EVENT_LOG_POS_FILE, 'w') { |f| f.write log_file.pos.to_s }
+end
+
+notifier = INotify::Notifier.new
+log_file = nil
+
+if File.exists? CONDOR_EVENT_LOG_FILE
+  log_file = File.open(CONDOR_EVENT_LOG_FILE)
+
+  # persistantly store log position in filesystem
+  # incase of dbomatic restarts
+  if File.exists?(EVENT_LOG_POS_FILE)
+    File.open(EVENT_LOG_POS_FILE, 'r') { |f| log_file.pos = f.read.to_i }
+  end
+
+  # Setup inotify watch for condor event log
+  notifier.watch(CONDOR_EVENT_LOG_FILE, :modify){ |event|
+    parse_log_file log_file, parser
+  }
+
+# if log file doesn't exist wait until it does
+else
+  notifier.watch(CONDOR_EVENT_LOG_DIR, :create){ |event|
+    if event.name == "EventLog"
+      log_file = File.open(CONDOR_EVENT_LOG_FILE)
+      parse_log_file log_file, parser
+
+      # Setup inotify watch for condor event log
+      notifier.watch(CONDOR_EVENT_LOG_FILE, :modify){ |event|
+        parse_log_file log_file, parser
+      }
+    end
+  }
+end
+
+notifier.run
+
+parser << "</events>"
+parser.finish
diff --git a/src/dbomatic/dbomatic.rb b/src/dbomatic/dbomatic.rb
deleted file mode 100644
index 1fd8948..0000000
--- a/src/dbomatic/dbomatic.rb
+++ /dev/null
@@ -1,114 +0,0 @@
-# Copyright (C) 2010 Red Hat, Inc.
-# Written by Mohammed Morsi <mmo...@redhat.com>
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-# MA  02110-1301, USA.  A copy of the GNU General Public License is
-# also available at http://www.gnu.org/copyleft/gpl.html.
-
-$: << File.join(File.dirname(__FILE__), "../dutils")
-require 'dutils'
-require 'nokogiri'
-require 'rb-inotify'
-
-CONDOR_EVENT_LOG_DIR    =   "/var/log/condor"
-CONDOR_EVENT_LOG_FILE   =   "#{CONDOR_EVENT_LOG_DIR}/EventLog"
-EVENT_LOG_POS_FILE      =   "/var/run/dbomatic/event_log_position"
-
-# Handle the event log's xml
-class CondorEventLog < Nokogiri::XML::SAX::Document
-  attr_accessor :tag, :event_type, :event_cmd, :event_time
-
-  # Store the name of the event log attribute we're looking at
-  def start_element(element, attributes)
-    @tag = attributes[1] if element == "a"
-  end
-
-  # Store the value of the event log attribute we're looking at
-  def characters(string)
-    unless string.strip == ""
-      if @tag == "MyType"
-        @event_type = string
-      elsif @tag == "Cmd"
-        @event_cmd = string
-      elsif @tag == "EventTime"
-        @event_time = string
-      end
-    end
-  end
-
-  # Create a new entry for events which we have all the neccessary data for
-  def end_element(element)
-    if element == "c" && !...@event_cmd.nil?
-      # Condor may write to event log before condormatic returns and instance
-      # table is updated. Extract instance name from event_cmd and query on 
that
-      inst_name = @event_cmd[4,@event_cmd.size-4].gsub(/_[0-9]*$/, '')
-      inst = Instance.find(:first, :conditions => ['name = ?', inst_name])
-      puts "Instance event #{inst.name} #...@event_type} #...@event_time}"
-      InstanceEvent.create! :instance => inst,
-                            :event_type => @event_type,
-                            :event_time => @event_time
-      @tag = @event_type = @event_cmd = @event_time = nil
-    end
-  end
-end
-parser = Nokogiri::XML::SAX::PushParser.new(CondorEventLog.new)
-
-# XXX hack, condor event log doesn't seem to have a top level element
-# enclosing everything else in the doc (as standards conforming xml must).
-# Create one for parsing purposes.
-parser << "<events>"
-
-def parse_log_file(log_file, parser)
-  while s = log_file.gets
-    parser << s
-  end
-  File.open(EVENT_LOG_POS_FILE, 'w') { |f| f.write log_file.pos.to_s }
-end
-
-notifier = INotify::Notifier.new
-log_file = nil
-
-if File.exists? CONDOR_EVENT_LOG_FILE
-  log_file = File.open(CONDOR_EVENT_LOG_FILE)
-
-  # persistantly store log position in filesystem
-  # incase of dbomatic restarts
-  if File.exists?(EVENT_LOG_POS_FILE)
-    File.open(EVENT_LOG_POS_FILE, 'r') { |f| log_file.pos = f.read.to_i }
-  end
-
-  # Setup inotify watch for condor event log
-  notifier.watch(CONDOR_EVENT_LOG_FILE, :modify){ |event|
-    parse_log_file log_file, parser
-  }
-
-# if log file doesn't exist wait until it does
-else
-  notifier.watch(CONDOR_EVENT_LOG_DIR, :create){ |event|
-    if event.name == "EventLog"
-      log_file = File.open(CONDOR_EVENT_LOG_FILE)
-      parse_log_file log_file, parser
-
-      # Setup inotify watch for condor event log
-      notifier.watch(CONDOR_EVENT_LOG_FILE, :modify){ |event|
-        parse_log_file log_file, parser
-      }
-    end
-  }
-end
-
-notifier.run
-
-parser << "</events>"
-parser.finish
-- 
1.7.2.1

_______________________________________________
deltacloud-devel mailing list
deltacloud-devel@lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/deltacloud-devel

Reply via email to