Commit a7e44669 authored by Martín Ferrari's avatar Martín Ferrari

minor changes

parent 9f1d3d08
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
import os, subprocess import os, subprocess
__all__ = ["ip_path", "tc_path", "brctl_path", "sysctl_path", "hz"] __all__ = ["ip_path", "tc_path", "brctl_path", "sysctl_path", "hz"]
__all__ += ["tcpdump_path", "netperf_path"]
__all__ += ["execute", "backticks"] __all__ += ["execute", "backticks"]
def _find_bin(name): def _find_bin(name):
...@@ -14,13 +15,23 @@ def _find_bin(name): ...@@ -14,13 +15,23 @@ def _find_bin(name):
except OSError, e: except OSError, e:
if e.errno != os.errno.ENOENT: if e.errno != os.errno.ENOENT:
raise raise
raise RuntimeError("Cannot find `%s' command, impossible to continue." % return None
name)
def _find_bin_or_die(name):
ip_path = _find_bin("ip") r = _find_bin(name)
tc_path = _find_bin("tc") if not r:
brctl_path = _find_bin("brctl") raise RuntimeError("Cannot find `%s' command, impossible to " +
sysctl_path = _find_bin("sysctl") "continue." % name)
return r
ip_path = _find_bin_or_die("ip")
tc_path = _find_bin_or_die("tc")
brctl_path = _find_bin_or_die("brctl")
sysctl_path = _find_bin_or_die("sysctl")
# Optional tools
tcpdump_path = _find_bin("tcpdump")
netperf_path = _find_bin("netperf")
# Seems this is completely bogus. At least, we can assume that the internal HZ # Seems this is completely bogus. At least, we can assume that the internal HZ
# is bigger than this. # is bigger than this.
......
...@@ -272,6 +272,8 @@ def _get_if_name(iface): ...@@ -272,6 +272,8 @@ def _get_if_name(iface):
# XXX: ideally this should be replaced by netlink communication # XXX: ideally this should be replaced by netlink communication
# Interface handling # Interface handling
# FIXME: try to lower the amount of calls to retrieve data!!
def get_if_data(): def get_if_data():
"""Gets current interface information. Returns a tuple (byidx, bynam) in """Gets current interface information. Returns a tuple (byidx, bynam) in
which each element is a dictionary with the same data, but using different which each element is a dictionary with the same data, but using different
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment