Skip to content

Commit

Permalink
Add sort functions to client class resources
Browse files Browse the repository at this point in the history
  • Loading branch information
bmhughes committed Jul 8, 2024
1 parent af06d12 commit 11f9cfa
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ This file is used to list changes made in each version of isc_kea.

## Unreleased

- Add sort functions to `config_dhcp4_client_class` and `config_dhcp6_client_class`

## 1.4.4 - *2024-05-01*

- resolved cookstyle error: resources/config_dhcp4_subnet_pool_option_data.rb:56:11 refactor: `Chef/RedundantCode/UnnecessaryDesiredState`
Expand Down
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
supports 'scientific'
supports 'ubuntu'

depends 'chef_auto_accumulator', '~> 0.4'
depends 'chef_auto_accumulator', '~> 0.5'
depends 'yum-epel', '~> 4.1'
1 change: 1 addition & 0 deletions resources/config_dhcp4_client_class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def auto_accumulator_options_override
{
config_path_override: %w(Dhcp4 client-classes),
config_path_type: :array,
config_path_sort_function: [:fetch, 'name'],
config_match: {
'name' => class_name,
},
Expand Down
1 change: 1 addition & 0 deletions resources/config_dhcp6_client_class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def auto_accumulator_options_override
{
config_path_override: %w(Dhcp6 client-classes),
config_path_type: :array,
config_path_sort_function: [:fetch, 'name'],
config_match: {
'name' => class_name,
},
Expand Down
24 changes: 24 additions & 0 deletions test/cookbooks/isc_kea_test/recipes/config_dhcp4.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,30 @@
boot_file_name 'test.bootfile'
end

isc_kea_config_dhcp4_client_class '02_Dns_Google' do
test "member('VENDOR_CLASS_dns_google')"
only_if_required true
option_data [
{
'name' => 'domain-name-servers',
'code' => 6,
'data' => '8.8.8.8'
}
]
end

isc_kea_config_dhcp4_client_class '01_Dns_Cloudflare' do
test "member('VENDOR_CLASS_dns_cloudflare')"
only_if_required true
option_data [
{
'name' => 'domain-name-servers',
'code' => 6,
'data' => '1.1.1.1'
}
]
end

isc_kea_config_dhcp4_interfaces 'eth0' do
interfaces 'eth0'
end
Expand Down
24 changes: 24 additions & 0 deletions test/cookbooks/isc_kea_test/recipes/config_dhcp6.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,30 @@
lfc_interval 3600
end

isc_kea_config_dhcp6_client_class '02_Dns_Google' do
test "member('VENDOR_CLASS_dns_google')"
only_if_required true
option_data [
{
'name' => 'dns-servers',
'code' => 23,
'data' => '2001:4860:4860::8888'
}
]
end

isc_kea_config_dhcp6_client_class '01_Dns_Cloudflare' do
test "member('VENDOR_CLASS_dns_cloudflare')"
only_if_required true
option_data [
{
'name' => 'dns-servers',
'code' => 23,
'data' => '2606:4700:4700::1111'
}
]
end

isc_kea_config_dhcp6_subnet '2001:db8:1::/64' do
id 1
interface 'eth0'
Expand Down
3 changes: 3 additions & 0 deletions test/integration/default/config_dhcp4_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@
its(%w(Dhcp4 interfaces-config interfaces)) { should include 'eth0' }
its(['Dhcp4', 'subnet4', 0, 'subnet']) { should eq '192.0.2.0/24' }
its(['Dhcp4', 'subnet4', 1, 'subnet']) { should eq '192.0.3.0/24' }

its(['Dhcp4', 'client-classes', 0, 'name']) { should eq '01_Dns_Cloudflare' }
its(['Dhcp4', 'client-classes', 1, 'name']) { should eq '02_Dns_Google' }
end
3 changes: 3 additions & 0 deletions test/integration/default/config_dhcp6_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
describe json('/etc/kea/kea-dhcp6.conf') do
its(%w(Dhcp6 interfaces-config interfaces)) { should include 'eth0' }
its(['Dhcp6', 'subnet6', 0, 'subnet']) { should eq '2001:db8:1::/64' }

its(['Dhcp6', 'client-classes', 0, 'name']) { should eq '01_Dns_Cloudflare' }
its(['Dhcp6', 'client-classes', 1, 'name']) { should eq '02_Dns_Google' }
end

0 comments on commit 11f9cfa

Please sign in to comment.