library: ignore failure of ethtool to get permanent MAC address

It's not uncommon that ethtool fails with:

  # ethtool -P dummy0
  Cannot read permanent address: Operation not supported

Ignore such errors.
This commit is contained in:
Thomas Haller 2017-07-17 17:38:41 +02:00 committed by Lars Karlitski
parent 3225b3a89d
commit 2cd6d3dbdf

View file

@ -316,7 +316,10 @@ class SysUtil:
@staticmethod
def _link_read_permaddress(ifname):
out = Util.check_output(['ethtool', '-P', ifname])
try:
out = Util.check_output(['ethtool', '-P', ifname])
except MyError as e:
return None
import re
m = re.match('^Permanent address: ([0-9A-Fa-f:]*)\n$', out)
if not m: