From 850d8f2663fd91c4142b373a5b6c68c9ecb8f25b Mon Sep 17 00:00:00 2001 From: Andy McCrae Date: Thu, 17 Aug 2017 13:20:31 +0100 Subject: [PATCH] Update existing container_networks We don't update an existing container_network so once you have settings set, they will not be changed, even if you change settings. This patch ensures that if the existing container_network does not match the current provider_network, it will get updated. Closes-Bug: 1678165 Change-Id: Ia6d91bd6aabf0f9584a83641d5bd990d3f9e404f --- osa_toolkit/generate.py | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/osa_toolkit/generate.py b/osa_toolkit/generate.py index c99fa234db..df40e99ead 100755 --- a/osa_toolkit/generate.py +++ b/osa_toolkit/generate.py @@ -615,16 +615,18 @@ def _add_additional_networks(key, inventory, ip_q, q_name, netmask, interface, if properties: is_metal = properties.get('is_metal', False) + _network = network_entry( + is_metal, + interface, + bridge, + net_type, + net_mtu + ) # This should convert found addresses based on q_name + "_address" # and then build the network if its not found. - if not is_metal and old_address not in networks: - network = networks[old_address] = network_entry( - is_metal, - interface, - bridge, - net_type, - net_mtu - ) + if not is_metal and (old_address not in networks or + networks[old_address] != _network): + network = networks[old_address] = _network if old_address in container and container[old_address]: network['address'] = container.pop(old_address) elif not is_metal: @@ -634,13 +636,7 @@ def _add_additional_networks(key, inventory, ip_q, q_name, netmask, interface, network['netmask'] = netmask elif is_metal: - network = networks[old_address] = network_entry( - is_metal, - interface, - bridge, - net_type, - net_mtu - ) + network = networks[old_address] = _network network['netmask'] = netmask if is_ssh_address or is_container_address: # Container physical host group