From b70ef9eae8ed784ff27176042ac02c7c09037706 Mon Sep 17 00:00:00 2001 From: Sam Betts Date: Fri, 13 Jan 2017 16:17:05 +0000 Subject: [PATCH] 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 --- bifrost/inventory.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bifrost/inventory.py b/bifrost/inventory.py index 130a8e7ec..2d239f661 100755 --- a/bifrost/inventory.py +++ b/bifrost/inventory.py @@ -179,8 +179,9 @@ def _process_baremetal_data(data_source, groups, hostvars): for name in file_data: host = file_data[name] # Perform basic validation - if ('ipv4_address' not in host or - not host['ipv4_address']): + node_net_data = host.get('node_network_data') + ipv4_addr = host.get('ipv4_address') + if not node_net_data and not ipv4_addr: host['addressing_mode'] = "dhcp" else: host['ansible_ssh_host'] = host['ipv4_address']