From cb4f56f72cd9a194661762c343c48392d70ba6ce Mon Sep 17 00:00:00 2001 From: xinwu Date: Fri, 12 Feb 2016 18:34:01 -0800 Subject: launchpad bug 1537330, fix _is_active_nic The detailed bug description is at https://bugs.launchpad.net/os-net-config/+bug/1537330 Since kilo, os-net-config starts to support linux bond. However, the addr_assign_type value of an active member interface of a linux bond is 3, but not 0. The consequence of this problem is that the linux bond member links are never considered as active, this further messes up the nicX to interface name mapping. This change checks if device directory exists, instead of checking the addr_assign_type value. This directory exists only when the interface is an actual physical interface. Change-Id: I8e4c95a2efa809fd236b07cbce1b81a2e774f858 --- os_net_config/utils.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'os_net_config/utils.py') diff --git a/os_net_config/utils.py b/os_net_config/utils.py index ab7f3b3..4109081 100644 --- a/os_net_config/utils.py +++ b/os_net_config/utils.py @@ -55,10 +55,8 @@ def _is_active_nic(interface_name): if interface_name == 'lo': return False - addr_assign_type = None - with open(_SYS_CLASS_NET + '/%s/addr_assign_type' % interface_name, - 'r') as f: - addr_assign_type = int(f.read().rstrip()) + device_dir = _SYS_CLASS_NET + '/%s/device' % interface_name + has_device_dir = os.path.isdir(device_dir) carrier = None with open(_SYS_CLASS_NET + '/%s/carrier' % interface_name, 'r') as f: @@ -68,7 +66,7 @@ def _is_active_nic(interface_name): with open(_SYS_CLASS_NET + '/%s/address' % interface_name, 'r') as f: address = f.read().rstrip() - if addr_assign_type == 0 and carrier == 1 and address: + if has_device_dir and carrier == 1 and address: return True else: return False -- cgit 1.2.3-korg