Class: Chef::Knife::KvmVmDelete

Inherits:
Chef::Knife show all
Includes:
KVMBase
Defined in:
lib/chef/knife/kvm_vm_delete.rb

Instance Method Summary collapse

Methods included from KVMBase

#connection, included, #locate_config_value, #upload_file

Instance Method Details

#runObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/chef/knife/kvm_vm_delete.rb', line 34

def run
  deleted = []
  connection.servers.all.each do |vm|
    @name_args.each do |vm_name|
      if vm_name == vm.name
        if config[:force_delete] != 'yes'
          confirm("Do you really want to delete this virtual machine '#{vm.name}'")
        end

        vm.destroy :destroy_volumes => true
        deleted << vm_name
        ui.warn("Deleted virtual machine #{vm.name}")
      end
    end
  end
  @name_args.each do |vm_name|
    ui.warn "Virtual Machine #{vm_name} not found" if not deleted.include?(vm_name)
  end
end