-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #36940 - Add necessary migration for host_config tftp directory
- Loading branch information
Showing
4 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
config/foreman-proxy-content.migrations/240531091300_foreman_proxy_tftp_host_config.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
if answers['foreman_proxy'].is_a?(Hash) | ||
root = answers['foreman_proxy']['tftp_root'] | ||
if root && answers['foreman_proxy']['tftp_dirs'] | ||
dirs = answers['foreman_proxy']['tftp_dirs'] | ||
dirs << "#{root}/bootloader-universe" | ||
dirs << "#{root}/bootloader-universe/pxegrub2" | ||
dirs << "#{root}/host-config" | ||
dirs.uniq! | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
config/foreman.migrations/20240531091300_foreman_proxy_tftp_host_config.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
if answers['foreman_proxy'] | ||
root = answers['foreman_proxy']['tftp_root'] | ||
if answers['foreman_proxy']['tftp_dirs'] | ||
dirs = answers['foreman_proxy']['tftp_dirs'] | ||
dirs << "#{root}/bootloader-universe" | ||
dirs << "#{root}/bootloader-universe/pxegrub2" | ||
dirs << "#{root}/host-config" | ||
dirs.uniq! | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
config/katello.migrations/240531091300_foreman_proxy_tftp_host_config.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
if answers['foreman_proxy'] | ||
root = answers['foreman_proxy']['tftp_root'] | ||
if answers['foreman_proxy']['tftp_dirs'] | ||
dirs = answers['foreman_proxy']['tftp_dirs'] | ||
dirs << "#{root}/bootloader-universe" | ||
dirs << "#{root}/bootloader-universe/pxegrub2" | ||
dirs << "#{root}/host-config" | ||
dirs.uniq! | ||
end | ||
end |
50 changes: 50 additions & 0 deletions
50
spec/migrations/20240531091300_foreman_proxy_tftp_host_config_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
require 'spec_helper' | ||
|
||
migration '20240531091300_foreman_proxy_tftp_host_config' do | ||
scenarios %w[foreman katello foreman-proxy-content] do | ||
context 'host-config in tftp_dirs missing' do | ||
let(:answers) do | ||
{ | ||
'foreman_proxy' => { | ||
'tftp_root' => '/var/lib/tftpboot', | ||
'tftp_dirs' => [ | ||
'/var/lib/tftpboot/pxelinux.cfg', | ||
'/var/lib/tftpboot/grub', | ||
'/var/lib/tftpboot/grub2', | ||
'/var/lib/tftpboot/boot', | ||
'/var/lib/tftpboot/ztp.cfg', | ||
'/var/lib/tftpboot/poap.cfg', | ||
], | ||
}, | ||
} | ||
end | ||
|
||
it 'adds bootloader-universe to tftp_dirs' do | ||
expect(migrated_answers['foreman_proxy']['tftp_dirs']).to include '/var/lib/tftpboot/bootloader-universe' | ||
end | ||
|
||
it 'adds bootloader-universe/pxegrub2 to tftp_dirs' do | ||
expect(migrated_answers['foreman_proxy']['tftp_dirs']).to include '/var/lib/tftpboot/bootloader-universe/pxegrub2' | ||
end | ||
|
||
it 'adds host-config to tftp_dirs' do | ||
expect(migrated_answers['foreman_proxy']['tftp_dirs']).to include '/var/lib/tftpboot/host-config' | ||
end | ||
end | ||
|
||
context 'tftp_dirs empty' do | ||
let(:answers) do | ||
{ | ||
'foreman_proxy' => { | ||
'tftp_root' => '/var/lib/tftpboot', | ||
'tftp_dirs' => nil, | ||
}, | ||
} | ||
end | ||
|
||
it 'keeps tftp_dirs unchanged' do | ||
expect(migrated_answers['foreman_proxy']['tftp_dirs']).to eq answers['foreman_proxy']['tftp_dirs'] | ||
end | ||
end | ||
end | ||
end |