From 2af4ee4b873b30d56c24cf1dfcad7bfabfedab37 Mon Sep 17 00:00:00 2001 From: Ben Nemec Date: Tue, 12 Apr 2016 15:34:15 +0000 Subject: Normalize operstate value for interfaces The previous check for an interface operstate only looked for the literal "UP" in caps, but in my environments I'm seeing operstate returned as "up" in lower-case, which causes the _is_active_nic check to fail incorrectly. Example: [root@overcloud-controller-0 heat-admin]# cat /sys/class/net/eth0/operstate up In this environment os-net-config is failing with the exception in the linked bug. Change-Id: I85c2d074ce43673c691523ca146ff7cdfdf1c7ca Closes-Bug: 1569403 --- os_net_config/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/os_net_config/utils.py b/os_net_config/utils.py index da7ab11..4e25d30 100644 --- a/os_net_config/utils.py +++ b/os_net_config/utils.py @@ -60,13 +60,13 @@ def _is_active_nic(interface_name): operstate = None with open(_SYS_CLASS_NET + '/%s/operstate' % interface_name, 'r') as f: - operstate = f.read().rstrip() + operstate = f.read().rstrip().lower() address = None with open(_SYS_CLASS_NET + '/%s/address' % interface_name, 'r') as f: address = f.read().rstrip() - if has_device_dir and operstate == 'UP' and address: + if has_device_dir and operstate == 'up' and address: return True else: return False -- cgit 1.2.3-korg