Browse Source

Merge "launchpad bug 1537330, fix _is_active_nic"

tags/0.1.8^0
Jenkins 3 years ago
parent
commit
c545e46f8f
1 changed files with 3 additions and 5 deletions
  1. 3
    5
      os_net_config/utils.py

+ 3
- 5
os_net_config/utils.py View File

@@ -55,10 +55,8 @@ def _is_active_nic(interface_name):
55 55
         if interface_name == 'lo':
56 56
             return False
57 57
 
58
-        addr_assign_type = None
59
-        with open(_SYS_CLASS_NET + '/%s/addr_assign_type' % interface_name,
60
-                  'r') as f:
61
-            addr_assign_type = int(f.read().rstrip())
58
+        device_dir = _SYS_CLASS_NET + '/%s/device' % interface_name
59
+        has_device_dir = os.path.isdir(device_dir)
62 60
 
63 61
         carrier = None
64 62
         with open(_SYS_CLASS_NET + '/%s/carrier' % interface_name, 'r') as f:
@@ -68,7 +66,7 @@ def _is_active_nic(interface_name):
68 66
         with open(_SYS_CLASS_NET + '/%s/address' % interface_name, 'r') as f:
69 67
             address = f.read().rstrip()
70 68
 
71
-        if addr_assign_type == 0 and carrier == 1 and address:
69
+        if has_device_dir and carrier == 1 and address:
72 70
             return True
73 71
         else:
74 72
             return False

Loading…
Cancel
Save