mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
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:
parent
bdadfe7339
commit
22acaebf61
@ -35,8 +35,10 @@ module VagrantPlugins
|
||||
|
||||
domain = env[:machine].provider.driver.connection.servers.get(env[:machine].id.to_s)
|
||||
|
||||
if env[:machine].provider_config.disks.empty?
|
||||
# if using default configuration of disks
|
||||
if env[:machine].provider_config.disks.empty? and
|
||||
env[:machine].provider_config.cdroms.empty?
|
||||
# if using default configuration of disks and cdroms
|
||||
# cdroms are consider volumes, but cannot be destroyed
|
||||
domain.destroy(destroy_volumes: true)
|
||||
else
|
||||
domain.destroy(destroy_volumes: false)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user