From 8792d74c9115d48f1756c2a77f5ff4ed4a001cdf Mon Sep 17 00:00:00 2001 From: Christopher Brown Date: Thu, 10 Mar 2016 15:18:33 +0000 Subject: Use interface operstate to determine nic status Fixes lp bug 1555669 Currently _is_active_nic performs multiple checks to see if a link is live. However some hardware such as Ethernet over USB devices fulfil this criteria. This causes tripleo deployments to fail if automatic interface naming is used. We can therefore use operstate to determine if the link is actually up. https://www.kernel.org/doc/Documentation/networking/operstates.txt This patch implements this. Implements: better link state detection Closes-Bug: #1555669 Change-Id: I0bdd0c987f4f177935df4f7cdcc70f4d99c988a5 Signed-off-by: Christopher Brown --- os_net_config/utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'os_net_config/utils.py') diff --git a/os_net_config/utils.py b/os_net_config/utils.py index 4109081..da7ab11 100644 --- a/os_net_config/utils.py +++ b/os_net_config/utils.py @@ -58,15 +58,15 @@ def _is_active_nic(interface_name): 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: - carrier = int(f.read().rstrip()) + operstate = None + with open(_SYS_CLASS_NET + '/%s/operstate' % interface_name, 'r') as f: + operstate = f.read().rstrip() address = None with open(_SYS_CLASS_NET + '/%s/address' % interface_name, 'r') as f: address = f.read().rstrip() - if has_device_dir and carrier == 1 and address: + if has_device_dir and operstate == 'UP' and address: return True else: return False -- cgit 1.2.3-korg