Ensure boot order is preserved unless overridden (#1560)

Add boot_order to the merge function to ensure that provider config
sections will persist the value if defined in earlier blocks. However to
ensure it is possible to override, definitions in latter sections will
replace the earlier definitions, but only if provided.

Fixes: #937
This commit is contained in:
Darragh Bailey 2022-08-25 18:46:33 +01:00 committed by GitHub
parent 3f1f2e79b3
commit f19478b050
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 1 deletions

View File

@ -196,7 +196,9 @@ end
* `boot` - Change the boot order and enables the boot menu. Possible options * `boot` - Change the boot order and enables the boot menu. Possible options
are "hd", "network", "cdrom". Defaults to "hd" with boot menu disabled. When are "hd", "network", "cdrom". Defaults to "hd" with boot menu disabled. When
"network" is set without "hd", only all NICs will be tried; see below for "network" is set without "hd", only all NICs will be tried; see below for
more detail. more detail. Defining this in subsequent provider blocks or latter Vagrantfile's
(see [Load Order and Merging](https://www.vagrantup.com/docs/vagrantfile)) will
result in the definition in the last block being used.
* `nic_adapter_count` - Defaults to '8'. Only use case for increasing this * `nic_adapter_count` - Defaults to '8'. Only use case for increasing this
count is for VMs that virtualize switches such as Cumulus Linux. Max value count is for VMs that virtualize switches such as Cumulus Linux. Max value
for Cumulus Linux VMs is 33. for Cumulus Linux VMs is 33.

View File

@ -1089,6 +1089,8 @@ module VagrantPlugins
def merge(other) def merge(other)
super.tap do |result| super.tap do |result|
result.boot_order = other.boot_order != [] ? other.boot_order : boot_order
c = disks.dup c = disks.dup
c += other.disks c += other.disks
result.disks = c result.disks = c

View File

@ -869,5 +869,23 @@ describe VagrantPlugins::ProviderLibvirt::Config do
) )
end end
end end
context 'boot_order' do
it 'should merge' do
one.boot 'network'
subject.finalize!
expect(subject.boot_order).to eq(['network'])
end
it 'should have last definition win' do
one.boot 'network'
two.boot 'hd'
two.boot 'cdrom'
subject.finalize!
expect(subject.boot_order).to eq(['hd', 'cdrom'])
end
end
end end
end end