Merge "Index networks using id, not links"

This commit is contained in:
Jenkins 2016-09-14 23:37:34 +00:00 committed by Gerrit Code Review
commit a3cf96c5cc
2 changed files with 15 additions and 6 deletions

View File

@ -165,7 +165,9 @@ def write_redhat_interfaces(interfaces, sys_interfaces):
interface_name = "{0}.{1}".format(
vlan_raw_device, interface['vlan_id'])
elif 'bond_mode' in interface:
interface_name = iname
# It is possible our interface does not have a link, so fall back
# to iname which is the link id.
interface_name = interface.get('link', iname)
else:
interface_name = sys_interfaces[interface['mac_address']]
@ -333,8 +335,11 @@ def write_gentoo_interfaces(interfaces, sys_interfaces):
if len(raw_macs) == 1:
interface_name = sys_interfaces[raw_macs[0]]
else:
# It is possible our interface does not have a link, so
# fall back to interface id.
interface_name = next(
intf['id'] for intf in interfs if 'bond_mode' in intf)
intf.get('link', intf['id']) for intf in interfs
if 'bond_mode' in intf)
files_to_write.update(
_write_gentoo_interface(interface_name, interfs))
_setup_gentoo_network_init(interface_name, interfs)
@ -398,7 +403,9 @@ def write_debian_interfaces(interfaces, sys_interfaces):
interface_name = "{0}.{1}".format(vlan_raw_device,
interface['vlan_id'])
elif 'bond_mode' in interface:
interface_name = iname
# It is possible our interface does not have a link, so fall back
# to iname which is the link id.
interface_name = interface.get('link', iname)
else:
interface_name = sys_interfaces[interface['mac_address']]
@ -592,7 +599,9 @@ def get_config_drive_interfaces(net):
continue
link.update(network)
link['id'] = i
interfaces[i] = link
# NOTE(pabelanger): Make sure we index by the existing network id,
# rather then creating out own.
interfaces[network['id']] = link
return interfaces

View File

@ -32,8 +32,8 @@ sample_data_path = os.path.join(
distros = ['Ubuntu', 'Debian', 'Fedora', 'RedHat', 'CentOS', 'Gentoo']
styles = ['hp', 'rax', 'liberty', 'nokey']
ips = {'hp': '127.0.1.1',
'rax': '10.208.169.118',
'liberty': '192.0.2.2',
'rax': '23.253.229.154',
'liberty': '23.253.229.154',
'nokey': '127.0.1.1'}
built_scenarios = []