From b72b3add9f20cc9a64a858d5ab70c3d90846c460 Mon Sep 17 00:00:00 2001 From: James Portman Date: Fri, 16 Mar 2018 09:15:10 +0000 Subject: [PATCH] Stop inventory constantly giving containers new IP See bug for further details, this was affecting pike after applying the backported patch. As the bug mentions, some containers were constantly given new IPs, even with no changes to user_variables yml files or openstack_user_config.yml file. Further to the bug, I think that the code in master/patch will cause containers to receive new IPs when network settings are changed (bridge, mtu, type) rather than just updating that setting. Change-Id: I0a757e9f503d3f604b2ba2c3409b4a4507d5edff Closes-Bug: 1756091 --- osa_toolkit/generate.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/osa_toolkit/generate.py b/osa_toolkit/generate.py index 0a4171716f..08472ece72 100755 --- a/osa_toolkit/generate.py +++ b/osa_toolkit/generate.py @@ -514,10 +514,10 @@ def network_entry(is_metal, interface, # simplified. The container address checking that is ssh address # is only being done to support old inventory. - if is_metal: - _network = dict() - else: - _network = {'interface': interface} + _network = dict() + + if not is_metal: + _network['interface'] = interface if bridge: _network['bridge'] = bridge @@ -624,10 +624,15 @@ def _add_additional_networks(key, inventory, ip_q, q_name, netmask, interface, net_type, net_mtu ) + + # update values from _network in case they have changed + if old_address in networks: + for key in _network.keys(): + networks[old_address][key] = _network[key] + # 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 or - networks[old_address] != _network): + if not is_metal and old_address not in networks: network = networks[old_address] = _network if old_address in container and container[old_address]: network['address'] = container.pop(old_address)