F #6044 + #6048: Remove unneeded addresses

NIC can only have one of IP/IP6/MAC to get a lease from the network. As
all address tuples are indexed only the relevant one is preserved.

(cherry picked from commit 9adcefb05b)
This commit is contained in:
Ruben S. Montero committed 2023-02-22 10:36:56 +01:00
1 parent a97c383650
commit 7e09ceb57b
1 file changed
+19
+19
View File
@@ -299,6 +299,7 @@ module TransferManager
template.delete('NIC')
else
remove_keys(NIC_LIST, template['NIC'])
remove_address(template['NIC'])
end
remove_empty(template)
@@ -340,6 +341,24 @@ module TransferManager
end
end
# Sanity check - A NIC can only have one of IP / IP6 / MAC.
def remove_address(nic)
return if nic.nil?
if nic.instance_of? Array
nic.each {|n| remove_addresses(n) }
else
if nic['IP']
nic.delete('MAC')
nic.delete('IP6')
nic.delete('IP6_ULA')
nic.delete('IP6_GLOBAL')
elsif nic['IP6']
nic.delete('MAC')
end
end
end
# Renders a template attribute in text form
def render_template_value(str, value)
if value.class == Hash