Use explicit removal of disk volumes if CDROM attached

Use the more conservative path if either disks or cdroms present for
the domain configuration.

Domain destroy including volumes will attempt to delete any attached
CDROM images as they are registered as volumes. Resulting in the
following error message:

    fog-libvirt-0.0.3/lib/fog/libvirt/requests/compute/volume_action.rb:6:in
    `delete': Call to virStorageVol Delete failed: cannot unlink file
    '<path-to-iso>': Success (Libvirt::Error)

Co-Authored-By: Darragh Bailey <dbailey@hpe.com>
Change-Id: Ia497aef0e871de88e65c46afe071b2618fda5588
This commit is contained in:
Michael Kerrin
2015-08-13 16:03:59 +01:00
committed by Darragh Bailey
parent bdadfe7339
commit 22acaebf61
2 changed files with 25 additions and 2 deletions

View File

@@ -70,6 +70,27 @@ describe VagrantPlugins::ProviderLibvirt::Action::DestroyDomain do
expect(subject.call(env)).to be_nil
end
end
context "when has CDROMs attached" do
let(:vagrantfile) { <<-EOF
Vagrant.configure('2') do |config|
config.vm.define :test
config.vm.provider :libvirt do |libvirt|
libvirt.storage :file, :device => :cdrom
end
end
EOF
}
it "uses explicit removal of disks" do
allow(libvirt_domain).to receive(:name).and_return("test")
allow(domain).to receive(:volumes).and_return([root_disk])
expect(domain).to_not receive(:destroy).with(:destroy_volumes => true)
expect(root_disk).to receive(:destroy) # root disk remove
expect(subject.call(env)).to be_nil
end
end
end
end
end