cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [49/50] git commit: updated refs/heads/master to 1290e10
Date Mon, 22 Sep 2014 19:44:48 GMT
CLOUDSTACK-7143: attempt to be safer when cleaning up


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ba009ed5
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ba009ed5
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ba009ed5

Branch: refs/heads/master
Commit: ba009ed51a12a8ff3a31b150d488bd632bc10803
Parents: e43e083
Author: Leo Simons <lsimons@schubergphilis.com>
Authored: Mon Sep 22 18:10:56 2014 +0200
Committer: Rohit Yadav <rohit.yadav@shapeblue.com>
Committed: Mon Sep 22 21:38:17 2014 +0200

----------------------------------------------------------------------
 tools/appliance/build.sh         |  9 +++----
 tools/appliance/vbox_vm_clean.rb | 51 ++++++++++++++++++-----------------
 2 files changed, 31 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ba009ed5/tools/appliance/build.sh
----------------------------------------------------------------------
diff --git a/tools/appliance/build.sh b/tools/appliance/build.sh
index 7880a1f..fd24a43 100755
--- a/tools/appliance/build.sh
+++ b/tools/appliance/build.sh
@@ -276,7 +276,7 @@ function stop_vbox() {
 
 function clean_vbox() {
   log INFO "deleting all virtualbox vms and disks for ${USER}"
-  bundle exec ./vbox_vm_clean.rb --delete
+  bundle exec ./vbox_vm_clean.rb --delete --kill
   bundle exec ./vbox_disk_clean.rb
 }
 
@@ -502,10 +502,10 @@ function hyperv_export() {
 function main() {
   prepare
   if [ "${clean_vbox}" == "1" ]; then
-    clean_vbox --delete
-    add_on_exit clean_vbox --delete
+    clean_vbox
+    add_on_exit clean_vbox
   else
-    stop_vbox # some extra encouragement for virtualbox to stop things
+    stop_vbox
   fi
   create_definition
   veewee_destroy # in case of left-over cruft from failed build
@@ -513,7 +513,6 @@ function main() {
   veewee_build
   save_mac_address
   veewee_halt
-  stop_vbox # some extra encouragement for virtualbox to stop things
   retry 10 check_appliance_shutdown
   retry 10 check_appliance_disk_ready
   retry 10 remove_shares

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ba009ed5/tools/appliance/vbox_vm_clean.rb
----------------------------------------------------------------------
diff --git a/tools/appliance/vbox_vm_clean.rb b/tools/appliance/vbox_vm_clean.rb
index a0e34e6..0c0c27a 100755
--- a/tools/appliance/vbox_vm_clean.rb
+++ b/tools/appliance/vbox_vm_clean.rb
@@ -8,6 +8,7 @@ require 'sys/proctable'
 include Sys
 
 do_delete = (ARGV.include? 'delete' or ARGV.include? '--delete' or ARGV.include? '-d')
+do_kill = (ARGV.include? 'kill' or ARGV.include? '--kill' or ARGV.include? '-k')
 
 lines = `VBoxManage list vms`
 vms = lines.split(/\n/)
@@ -26,29 +27,31 @@ vms.each do |vmline|
     `#{cmd}`
   end
 
-  sleep(1)
-  # ps x | grep VBoxHeadless | grep systemvm64template-4.4.0 | egrep -o '^\s*[0-9]+' | xargs
kill
-  ProcTable.ps { |p|
-    next unless p.cmdline.include? "VBoxHeadless"
-    next unless p.cmdline.include? vm_name
-    # not all rubies / proctables expose ruid
-    if defined? p.ruid
-      # VBoxManage should only list _our_ vms, but just to be safe...
-      next unless p.ruid == Process.uid
-    end
-
-    puts "kill -SIGKILL #{p.pid}"
-    begin
-      Process.kill("KILL", p.pid)
-    rescue => exception
-      puts exception.backtrace
-    end
-    sleep(5)
-    puts "kill -SIGTERM #{p.pid}"
-    begin
-      Process.kill("TERM", p.pid)
-    rescue => exception
-      puts exception.backtrace
+  if do_kill
+    sleep(1)
+    # ps x | grep VBoxHeadless | grep systemvm64template-4.4.0 | egrep -o '^\s*[0-9]+' |
xargs kill
+    ProcTable.ps do |p|
+      next unless p.cmdline.include? "VBoxHeadless"
+      next unless p.cmdline.include? vm_name
+      # not all rubies / proctables expose ruid
+      if defined? p.ruid
+        # VBoxManage should only list _our_ vms, but just to be safe...
+        next unless p.ruid == Process.uid
+      end
+
+      puts "kill -SIGKILL #{p.pid}"
+      begin
+        Process.kill("KILL", p.pid)
+      rescue => exception
+        puts exception.backtrace
+      end
+      sleep(5)
+      puts "kill -SIGTERM #{p.pid}"
+      begin
+        Process.kill("TERM", p.pid)
+      rescue => exception
+        puts exception.backtrace
+      end
     end
-  }
+  end
 end


Mime
View raw message