Getting this to trip is somewhat tricky and racy due to how fast/slow the bond is able to come up. However, if the bond is up before cloud-init.service runs it's net.apply_network_config_names() then we see the following:
>>> r = net._get_current_rename_info(check_downable=True) >>> r {False: {'up': False, 'name': 'bonding_masters', 'downable': True}, '00:00:00:00:00:00': {'up': True, 'name': 'lo', 'downable': False}, '52:54:00:12:34:02': {'up': True, 'name': 'interface1', 'downable': True}, '52:54:00:12:34:00': {'up': False, 'name': 'bond0', 'downable': True}} >>> r.keys() dict_keys([False, '00:00:00:00:00:00', '52:54:00:12:34:02', '52:54:00:12:34:00']) >>> r['52:54:00:12:34:00'] {'up': False, 'name': 'bond0', 'downable': True} >>> r['52:54:00:12:34:02'] {'up': True, 'name': 'interface1', 'downable': True}
Here we can see that by checking /sys/class/net/* for interfaces and mapping a mac address to an interface picks up bond0 for 'interface0's mac.
Then if we attempt to apply the names, we see the error:
Python 3.5.3 (default, Jan 19 2017, 14:11:04) [GCC 6.3.0 20170118] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import yaml >>> ncfg = yaml.load(open('/root/network-config')) >>> netcfg = ncfg.get('network') >>> netcfg >>> ncfg.keys() dict_keys(['version', 'config']) >>> from cloudinit import net >>> net.apply_network_config_names(ncfg) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3/dist-packages/cloudinit/net/__init__.py", line 201, in apply_network_config_names return _rename_interfaces(renames) File "/usr/lib/python3/dist-packages/cloudinit/net/__init__.py", line 336, in _rename_interfaces raise Exception('\n'.join(errors)) Exception: [unknown] Error performing rename('bond0', 'interface0') for 52:54:00:12:34:00, interface0: Unexpected error while running command. Command: ['ip', 'link', 'set', 'bond0', 'name', 'interface0'] Exit code: 2 Reason: - Stdout: - Stderr: RTNETLINK answers: File exists
Getting this to trip is somewhat tricky and racy due to how fast/slow the bond is able to come up. However, if the bond is up before cloud-init.service runs it's net.apply_ network_ config_ names() then we see the following:
>>> r = net._get_ current_ rename_ info(check_ downable= True) 00:00:00: 00': {'up': True, 'name': 'lo', 'downable': False}, '52:54: 00:12:34: 02': {'up': True, 'name': 'interface1', 'downable': True}, '52:54: 00:12:34: 00': {'up': False, 'name': 'bond0', 'downable': True}} 00:00:00: 00', '52:54: 00:12:34: 02', '52:54: 00:12:34: 00']) 00:12:34: 00'] 00:12:34: 02']
>>> r
{False: {'up': False, 'name': 'bonding_masters', 'downable': True}, '00:00:
>>> r.keys()
dict_keys([False, '00:00:
>>> r['52:54:
{'up': False, 'name': 'bond0', 'downable': True}
>>> r['52:54:
{'up': True, 'name': 'interface1', 'downable': True}
Here we can see that by checking /sys/class/net/* for interfaces and mapping a mac address to an interface picks up bond0 for 'interface0's mac.
Then if we attempt to apply the names, we see the error:
Python 3.5.3 (default, Jan 19 2017, 14:11:04) open('/ root/network- config' )) ['version' , 'config']) network_ config_ names(ncfg) python3/ dist-packages/ cloudinit/ net/__init_ _.py", line 201, in apply_network_ config_ names interfaces( renames) python3/ dist-packages/ cloudinit/ net/__init_ _.py", line 336, in _rename_interfaces '\n'.join( errors) )
[GCC 6.3.0 20170118] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import yaml
>>> ncfg = yaml.load(
>>> netcfg = ncfg.get('network')
>>> netcfg
>>> ncfg.keys()
dict_keys(
>>> from cloudinit import net
>>> net.apply_
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/
return _rename_
File "/usr/lib/
raise Exception(
Exception: [unknown] Error performing rename('bond0', 'interface0') for 52:54:00:12:34:00, interface0: Unexpected error while running command.
Command: ['ip', 'link', 'set', 'bond0', 'name', 'interface0']
Exit code: 2
Reason: -
Stdout: -
Stderr: RTNETLINK answers: File exists