Fixes packstack failure when interface has no assigned ip address
In case we have unconfigured interfaces cidr_to_ifname() searches its ipaddress and network mask and throws an exception. Change-Id: I829a874ca44c2e4176bb1eeba28c3f49c44c72ca Closes-bug: #1638549
This commit is contained in:
parent
eb2ab2ba53
commit
f480c69d76
|
@ -77,8 +77,9 @@ def cidr_to_ifname(cidr, host, config):
|
||||||
|
|
||||||
for interface in info['interfaces'].split(','):
|
for interface in info['interfaces'].split(','):
|
||||||
interface = interface.strip()
|
interface = interface.strip()
|
||||||
ipaddr = info['ipaddress_{}'.format(interface)]
|
ipaddr = info.get('ipaddress_{}'.format(interface))
|
||||||
netmask = info['netmask_{}'.format(interface)]
|
netmask = info.get('netmask_{}'.format(interface))
|
||||||
|
if ipaddr and netmask:
|
||||||
subnet_b = netaddr.IPNetwork('{ipaddr}/{netmask}'.format(**locals()))
|
subnet_b = netaddr.IPNetwork('{ipaddr}/{netmask}'.format(**locals()))
|
||||||
if subnet_a == subnet_b:
|
if subnet_a == subnet_b:
|
||||||
translated.append(interface)
|
translated.append(interface)
|
||||||
|
|
|
@ -30,6 +30,9 @@ module Puppet::Parser::Functions
|
||||||
lookupvar('interfaces').split(',').each do |interface|
|
lookupvar('interfaces').split(',').each do |interface|
|
||||||
interface.strip!
|
interface.strip!
|
||||||
ifaddr = lookupvar("ipaddress_#{interface}")
|
ifaddr = lookupvar("ipaddress_#{interface}")
|
||||||
|
if ifaddr == nil
|
||||||
|
next
|
||||||
|
end
|
||||||
ifcidr = IPAddr.new ifaddr
|
ifcidr = IPAddr.new ifaddr
|
||||||
if cidr.include?(ifcidr)
|
if cidr.include?(ifcidr)
|
||||||
translated.push(interface)
|
translated.push(interface)
|
||||||
|
|
Loading…
Reference in New Issue