[PATCH aeolus-configure] BZ827562 - Upgrade from CloudForms 1.0 to CloudForms 1.0.1 requires additional data definition not provided by rails migration

Steve Linabery slinaber at redhat.com
Fri Jun 1 20:37:13 UTC 2012


We need a script to stop,start,restart aeolus services so that we
can stop them, insert data required by upgrade path, and restart.
The existing aeolus-services script appears deprecated and is used
nowhere else in the codebase for aeolus-configure or aeolus-conductor,
so we'll refactor it to be useful for this purpose.
---
 bin/aeolus-services |   74 +++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 69 insertions(+), 5 deletions(-)
 mode change 100644 => 100755 bin/aeolus-services

diff --git a/bin/aeolus-services b/bin/aeolus-services
old mode 100644
new mode 100755
index 76dbc5d..2becbfd
--- a/bin/aeolus-services
+++ b/bin/aeolus-services
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/env ruby
 
 #   Copyright 2011 Red Hat, Inc.
 #
@@ -14,7 +14,71 @@
 #   See the License for the specific language governing permissions and
 #   limitations under the License.
 
-puppet /usr/share/aeolus-configure/aeolus_stop_services.pp \
-       --modulepath=/usr/share/aeolus-configure/modules/ \
-       --logdest=/var/log/aeolus-configure/aeolus-services.log \
-       --logdest=console
+if ARGV.include?('-h') || ARGV.include?('--help')
+  puts "Usage: #{$0} stop|start|restart
+Stop, Start, or Restart Aeolus services.
+
+  -h, --help  display this help and exit
+
+To show status of aeolus services please use aeolus-check-services.
+"
+  exit
+end
+
+if !['stop','start','restart'].include?(ARGV[0])
+  puts "Usage: #{$0} stop|start|restart
+Stop, Start, or Restart Aeolus services.
+
+To show status of aeolus services please use aeolus-check-services.
+"
+  exit(1)
+end
+
+# ordered as in rc.d
+$services = %w(mongod iwhd postgresql httpd deltacloud-core libvirtd aeolus-conductor conductor-dbomatic imagefactory ntpd)
+
+def perform(action, svcs)
+  action = action.to_s
+  svcs.map do |script|
+    puts "\n#{action.capitalize}ing #{script} ..."
+    cmd = "service #{script} #{action}"
+    out = `#{cmd}`
+    if $?.to_i == 0
+      puts " \e[1;32mSuccess:\e[0m #{out.strip}"
+    else
+      puts " \e[1;31mFAILURE:\e[0m #{out.strip}"
+    end
+    $?.to_i
+  end
+end
+
+def mongod_cleanup_and_restart
+  if perform(:status, ['mongod']) == [1]
+    lockfile = '/var/lib/mongodb/mongod.lock'
+    if File.exists?(lockfile)
+      puts " \e[1;33mremoving\e[0m leftover #{lockfile}"
+      File.delete(lockfile)
+      perform :restart, %w(mongod iwhd)
+    end
+  end
+end
+
+def start
+  perform :start, $services
+  mongod_cleanup_and_restart
+end
+
+def stop
+  perform :stop, $services.reverse
+end
+
+def restart
+  stop
+  start
+end
+
+case ARGV[0]
+  when "start"   then start
+  when "stop"    then stop
+  when "restart" then restart
+end
-- 
1.7.6.5




More information about the aeolus-devel mailing list