Don't assume 'dhcp' if node_network_data set

If ipv4_address is not set, the current logic in inventory.py sets the
addressing_mode to dhcp which prevents network_data.json being
generated. This means that even if node_network_data is set which
overrides ipv4_address, you have to set it anyway to ensure that your
node_network_data gets written to the file. This patch fixes the logic
such that only if both of ipv4_address and node_network_data are not
set, then it assumes addressing_mode=dhcp.

Change-Id: Iab8e0a8422d9f33c8c5b1362bdaefabf6f39d52e
Closes-Bug: #1656335
This commit is contained in:
Sam Betts 2017-01-13 16:17:05 +00:00
parent c7adb13973
commit b70ef9eae8

View File

@ -179,8 +179,9 @@ def _process_baremetal_data(data_source, groups, hostvars):
for name in file_data: for name in file_data:
host = file_data[name] host = file_data[name]
# Perform basic validation # Perform basic validation
if ('ipv4_address' not in host or node_net_data = host.get('node_network_data')
not host['ipv4_address']): ipv4_addr = host.get('ipv4_address')
if not node_net_data and not ipv4_addr:
host['addressing_mode'] = "dhcp" host['addressing_mode'] = "dhcp"
else: else:
host['ansible_ssh_host'] = host['ipv4_address'] host['ansible_ssh_host'] = host['ipv4_address']