summaryrefslogtreecommitdiffstats
path: root/cloudmasterd/lib
diff options
context:
space:
mode:
authorMatthew Hicks <mhicks@mhicks-host.usersys.redhat.com>2008-06-21 23:25:14 -0400
committerMatthew Hicks <mhicks@mhicks-host.usersys.redhat.com>2008-06-21 23:25:14 -0400
commita3a34a5b0c10a6136cea7d7343abf9dec62754e4 (patch)
tree56870ee7e6e2c9d685bdb5c0ee8236908121c977 /cloudmasterd/lib
parentfe3781030a1d4e8e59b7b1e679f6156d74516327 (diff)
downloadtools-a3a34a5b0c10a6136cea7d7343abf9dec62754e4.tar.gz
tools-a3a34a5b0c10a6136cea7d7343abf9dec62754e4.tar.xz
tools-a3a34a5b0c10a6136cea7d7343abf9dec62754e4.zip
Adding real instance cleanup
Diffstat (limited to 'cloudmasterd/lib')
-rw-r--r--cloudmasterd/lib/cloudmasterd.rb17
1 files changed, 14 insertions, 3 deletions
diff --git a/cloudmasterd/lib/cloudmasterd.rb b/cloudmasterd/lib/cloudmasterd.rb
index 88223c9..6cd9696 100644
--- a/cloudmasterd/lib/cloudmasterd.rb
+++ b/cloudmasterd/lib/cloudmasterd.rb
@@ -148,10 +148,21 @@ module Cloudmasterd::Controllers
def destroy(name)
puts "Destroying image #{name}"
Machine.find(:all, :conditions => "name = '#{name}'").each do |machine|
- if machine.state == "Missing" then
- # Don't try and remotely clean up anything, just remove the DB record
- machine.destroy
+ # If the machine is missing, don't bother remotely trying to cleanup
+ unless machine.state == "Missing" then
+ # Destroy the virtual machine
+ `func "#{machine.cloud}" call command run "virsh destroy #{machine.name}"`
+ `func "#{machine.cloud}" call command run "virsh undefine #{machine.name}"`
+
+ # Remove the auto start file if it exists
+ `func "#{machine.cloud}" call command run "rm -rf /etc/xen/auto/#{machine.name}"`
+
+ # Remove the image file
+ `func "#{machine.cloud}" call command run "rm -rf /images/#{machine.name}-disk0"`
end
+
+ # Delete the DB record
+ machine.destroy
end
redirect R(Cloud)
end