# File lib/cloudmasterd.rb, line 226
    def destroy(name)
      Syncer::lock do
        Machine.find(:all, :conditions => "name = '#{name}'").each do |machine|
          # 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"`
 
          # Remove the yaml file and the cert
          Restr.delete("http://#{machine.repo}/genome/nodes/#{machine.node_name}.yaml")

          # Remove the system record
          _remove_cobbler_system(machine.name, machine.repo)

          # Delete the DB record
          machine.destroy
        end
      end

      redirect R(Status)
    end