Skip to content

Commit

Permalink
Fixes #21114 - Update error message
Browse files Browse the repository at this point in the history
  • Loading branch information
chris1984 authored and mmoll committed Sep 29, 2017
1 parent fccd5b6 commit f291aa3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
12 changes: 6 additions & 6 deletions manifests/proxydhcp.pp
Expand Up @@ -3,18 +3,18 @@
# puppet fact names are converted from ethX.X and ethX:X to ethX_X
# so for alias and vlan interfaces we have to modify the name accordingly
$interface_fact_name = regsubst($foreman_proxy::dhcp_interface, '[.:]', '_')
$ip = pick($::foreman_proxy::dhcp_pxeserver, inline_template("<%= scope.lookupvar('::ipaddress_${interface_fact_name}') %>"))
if ! is_ip_address($ip) {
$ip = pick_default($::foreman_proxy::dhcp_pxeserver, fact("ipaddress_${interface_fact_name}"))
unless ($ip =~ Stdlib::Compat::Ipv4) {
fail("Could not get the ip address from fact ipaddress_${interface_fact_name}")
}

$net = inline_template("<%= scope.lookupvar('::network_${interface_fact_name}') %>")
if ! is_ip_address($net) {
$net = fact("network_${interface_fact_name}")
unless ($ip =~ Stdlib::Compat::Ipv4) {
fail("Could not get the network address from fact network_${interface_fact_name}")
}

$mask = inline_template("<%= scope.lookupvar('::netmask_${interface_fact_name}') %>")
if ! is_ip_address($mask) {
$mask = fact("netmask_${interface_fact_name}")
unless ($ip =~ Stdlib::Compat::Ipv4) {
fail("Could not get the network mask from fact netmask_${interface_fact_name}")
}

Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Expand Up @@ -40,7 +40,7 @@
},
{
"name": "puppetlabs/stdlib",
"version_requirement": ">= 4.13.0 < 5.0.0"
"version_requirement": ">= 4.19.0 < 5.0.0"
},
{
"name": "puppet/extlib",
Expand Down
14 changes: 14 additions & 0 deletions spec/classes/foreman_proxy__proxydhcp__spec.rb
Expand Up @@ -195,6 +195,20 @@
) end
end

context "on a non-existing interface" do
let :facts do
facts
end

let :pre_condition do
"class { 'foreman_proxy':
dhcp_interface => 'doesnotexist',
}"
end

it { should raise_error(Puppet::Error, /Could not get the ip address from fact ipaddress_doesnotexist/) }
end

context "as manager of ACLs for dhcp" do
let :facts do
facts.merge({:ipaddress_eth0 => '192.168.100.20',
Expand Down

0 comments on commit f291aa3

Please sign in to comment.