aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Sneddon <dsneddon@redhat.com>2016-06-30 15:56:52 -0700
committerDan Sneddon <dsneddon@redhat.com>2016-06-30 15:56:52 -0700
commit6036a166710b22831b0ec9756b9732024b0a0e24 (patch)
tree3a481d449332f7f6b61e1a8c786ecf441414c915
parentf742dcbda0d92bee0278b4a1614d65f2ad5b1a78 (diff)
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
-rw-r--r--os_net_config/utils.py7
1 files changed, 7 insertions, 0 deletions
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()