Skip to content

Commit

Permalink
Fixes #36940 - Add necessary migration for host_config tftp directory
Browse files Browse the repository at this point in the history
  • Loading branch information
goarsna committed Nov 28, 2024
1 parent 7d8f3f6 commit 562729a
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 0 deletions.
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
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
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
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

0 comments on commit 562729a

Please sign in to comment.