mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
add sysinfo support (#1500)
For testing certain scenarios with vagrant-libvirt, need in the guest system a value for the systems serial number in the DMI/SMBIOS system information. The domain https://libvirt.org/formatdomain.html#smbios-system-information format of libvirt allows to specify those values. While adding `-smbios type=1,serial=$serial_value` to the `qemuargs` parameter of the libvirt provider is already able to achieve this, a dedicated provider config value adds native support from the `Vagrantfile` layering system. For example, in the .box included Vagrantfile a random serial number can be enforced by adding the following: require 'securerandom' Vagrant.configure("2") do |config| config.vm.provider :libvirt do |libvirt| libvirt.dmi_system_serial = SecureRandom.alphanumeric(8).upcase end end Then in an instance specific Vagrantfile this value can be overwritten by adding: Vagrant.configure("2") do |config| config.vm.provider :libvirt do |libvirt| libvirt.dmi_system_serial = "ABCDEFGH" end end Co-authored-by: Nils Ballmann <nils.ballmann.ext@siemens.com> Co-authored-by: Darragh Bailey <daragh.bailey@gmail.com>
This commit is contained in:
@@ -170,6 +170,70 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
|
||||
expect(subject.call(env)).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'sysinfo' do
|
||||
let(:domain_xml_file) { 'sysinfo.xml' }
|
||||
let(:vagrantfile_providerconfig) do
|
||||
<<-EOF
|
||||
libvirt.sysinfo = {
|
||||
'bios': {
|
||||
'vendor': 'Test Vendor',
|
||||
'version': '',
|
||||
},
|
||||
'system': {
|
||||
'manufacturer': 'Test Manufacturer',
|
||||
'version': '0.1.0',
|
||||
'serial': '',
|
||||
},
|
||||
'base board': {
|
||||
'manufacturer': 'Test Manufacturer',
|
||||
'version': '',
|
||||
},
|
||||
'chassis': {
|
||||
'manufacturer': 'Test Manufacturer',
|
||||
'serial': 'AABBCCDDEE',
|
||||
'asset': '',
|
||||
},
|
||||
'oem strings': [
|
||||
'app1: string1',
|
||||
'app1: string2',
|
||||
'app2: string1',
|
||||
'app2: string2',
|
||||
'',
|
||||
'',
|
||||
],
|
||||
}
|
||||
EOF
|
||||
end
|
||||
|
||||
it 'should populate sysinfo as expected' do
|
||||
expect(servers).to receive(:create).with(xml: domain_xml).and_return(machine)
|
||||
|
||||
expect(subject.call(env)).to be_nil
|
||||
end
|
||||
|
||||
context 'with block of empty entries' do
|
||||
let(:domain_xml_file) { 'sysinfo_only_required.xml' }
|
||||
let(:vagrantfile_providerconfig) do
|
||||
<<-EOF
|
||||
libvirt.sysinfo = {
|
||||
'bios': {
|
||||
'vendor': 'Test Vendor',
|
||||
},
|
||||
'system': {
|
||||
'serial': '',
|
||||
},
|
||||
}
|
||||
EOF
|
||||
end
|
||||
|
||||
it 'should skip outputting the surrounding tags' do
|
||||
expect(servers).to receive(:create).with(xml: domain_xml).and_return(machine)
|
||||
|
||||
expect(subject.call(env)).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'connection => qemu:///session' do
|
||||
|
||||
Reference in New Issue
Block a user