Gracefully handle Invalid argument from /sys/.../speed
Not all interfaces support retrieval of link speed through sysfs, gracefully handle those that don't. Closes-Bug: #1990481 Change-Id: I2f43cd67bab52704c80da569912b7770f4c1877b
This commit is contained in:
@@ -605,8 +605,14 @@ def check_bonds(bonds, lldp=None):
|
||||
|
||||
|
||||
def get_link_speed(iface):
|
||||
with open('/sys/class/net/{}/speed'.format(iface)) as f:
|
||||
return int(f.read())
|
||||
try:
|
||||
with open('/sys/class/net/{}/speed'.format(iface)) as f:
|
||||
return int(f.read())
|
||||
except OSError as e:
|
||||
hookenv.log('Unable to determine link speed for {}: {}'
|
||||
.format(iface, str(e)),
|
||||
hookenv.WARNING)
|
||||
return -1
|
||||
|
||||
|
||||
def check_nodes(nodes, iperf_client=False):
|
||||
|
||||
Reference in New Issue
Block a user