1
0
Fork 0

net: support new network device naming

https://fedoraproject.org/wiki/Features/ConsistentNetworkDeviceNaming
Resolves: #682379
This commit is contained in:
Jan Vcelak 2011-03-08 17:27:35 +01:00
parent a1d1df7bb1
commit ae41fe8929

View file

@ -34,7 +34,7 @@ class NetMonitor:
l = l.replace(":", " ")
v = l.split()
d = v[0]
if not d.startswith("eth"):
if not self._device_is_tunable(d):
continue
self.devices[d] = {}
self.devices[d]["new"] = ['0', '0', '0', '0']
@ -43,6 +43,16 @@ class NetMonitor:
self.__updateStat__(d)
self.devices[d]["max"] = [max_speed, 1, max_speed, 1]
def _device_is_tunable(self, name):
# just guess from device name
for prefix in ["eth", "em", "pci"]:
if name.startswith(prefix): break
else:
return False
card = ethcard(name)
return len(card.supported_modes) > 1 and card.get_max_speed() >= 1000
def __calcspeed__(self, speed):
# 0.6 is just a magical constant (empirical value): Typical workload on netcard won't exceed
# that and if it does, then the code is smart enough to adapt it.
@ -92,7 +102,7 @@ class NetMonitor:
max_data = self.__calcspeed__(ethcard(d).get_max_speed()) * interval;
self.devices[d]["max"] = [max_data, 1, max_data, 1]
log.info("Available ethernet cards: %s" % ", ".join(self.devices.keys()))
log.info("Tunable ethernet cards: %s" % ", ".join(self.devices.keys()))
def cleanup(self):
log.debug("Cleanup")