From 6036a166710b22831b0ec9756b9732024b0a0e24 Mon Sep 17 00:00:00 2001 From: Dan Sneddon Date: Thu, 30 Jun 2016 15:56:52 -0700 Subject: Make os-net-config idempotent with Linux bonds and MAC mapping This small change fixes a serious bug in os-net-config which made mapping NICs by MAC address not idempotent if Linux bonds were used. The first time os-net-config runs, it sees the MAC address of each interface, then it sets up the bond. On subsequent runs, any non-primary interfaces have taken the MAC address of the primary interface in the bond. At this time, they all show the same MAC address. This causes the mapping to fail, and it appears that the system has fewer matching interfaces than it had before. The impact of this bug is that bonding doesn't work for anyone doing mapping by MAC address. This is known to be affecting installations with a particular 3rd-party Neutron plugin vendor. This change simply looks for the permanent hardware address under the bonding_slave directory, if it exists. Change-Id: I5b0087370f74ecc319d2285b0f9f5f3dd951dbc2 --- os_net_config/utils.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'os_net_config') diff --git a/os_net_config/utils.py b/os_net_config/utils.py index 7ff19fb..83aae63 100644 --- a/os_net_config/utils.py +++ b/os_net_config/utils.py @@ -42,6 +42,13 @@ def get_file_data(filename): def interface_mac(name): + try: # If the iface is part of a Linux bond, the real MAC is only here. + with open('/sys/class/net/%s/bonding_slave/perm_hwaddr' % name, + 'r') as f: + return f.read().rstrip() + except IOError: + pass # Iface is not part of a bond, continue + try: with open('/sys/class/net/%s/address' % name, 'r') as f: return f.read().rstrip() -- cgit 1.2.3-korg