mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
Restore handling of disk_device domain setting (#1365)
Re-enable handling of the disk_device domain volume setting to ensure it can be overridden from the default of vda to a value chosen. Provide a disk resolver to resolve devices after the box has been downloaded so that initial devices can be correctly allocated and avoid conflicts with additional disks added that would otherwise get assigned the same device. Removes hack for destroy domain when more than one disk, as now devices in the config are only present if provided by the configuration. Fixes: #1353
This commit is contained in:
@@ -33,7 +33,6 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
|
||||
allow(connection).to receive(:volumes).and_return(volumes)
|
||||
allow(volumes).to receive(:all).and_return([domain_volume])
|
||||
allow(domain_volume).to receive(:pool_name).and_return('default')
|
||||
allow(domain_volume).to receive(:[]).with('name').and_return('vagrant-test_default.img')
|
||||
allow(domain_volume).to receive(:path).and_return('/var/lib/libvirt/images/vagrant-test_default.img')
|
||||
allow(machine).to receive_message_chain("box.name") { 'vagrant-libvirt/test' }
|
||||
|
||||
@@ -117,6 +116,48 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with custom disk device setting' do
|
||||
let(:domain_xml_file) { 'custom_disk_settings.xml' }
|
||||
let(:vagrantfile_providerconfig) {
|
||||
<<-EOF
|
||||
libvirt.disk_device = 'sda'
|
||||
EOF
|
||||
}
|
||||
|
||||
it 'should set the domain device' do
|
||||
expect(ui).to receive(:info).with(/ -- Image\(sda\):.*/)
|
||||
expect(servers).to receive(:create).with(xml: domain_xml).and_return(machine)
|
||||
|
||||
expect(subject.call(env)).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'with two domain disks' do
|
||||
let(:domain_xml_file) { 'two_disk_settings.xml' }
|
||||
let(:domain_volume_2) { double('domain_volume 2') }
|
||||
|
||||
before do
|
||||
expect(volumes).to receive(:all).and_return([domain_volume])
|
||||
expect(volumes).to receive(:all).and_return([domain_volume_2])
|
||||
expect(domain_volume_2).to receive(:pool_name).and_return('default')
|
||||
expect(domain_volume_2).to receive(:path).and_return('/var/lib/libvirt/images/vagrant-test_default_1.img')
|
||||
|
||||
env[:box_volumes].push({
|
||||
:path=>"/test/box_1.img",
|
||||
:name=>"test_vagrant_box_image_1.1.1_1.img",
|
||||
:virtual_size=> ByteNumber.new(5),
|
||||
})
|
||||
end
|
||||
|
||||
it 'should correctly assign device entries' do
|
||||
expect(ui).to receive(:info).with(/ -- Image\(vda\):.*/)
|
||||
expect(ui).to receive(:info).with(/ -- Image\(vdb\):.*/)
|
||||
expect(servers).to receive(:create).with(xml: domain_xml).and_return(machine)
|
||||
|
||||
expect(subject.call(env)).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'no default pool' do
|
||||
|
||||
Reference in New Issue
Block a user