How to use the ethtool.get_active_devices function in ethtool

To help you get started, we’ve selected a few ethtool examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github uyuni-project / uyuni / client / rhel / spacewalk-client-tools / src / up2date_client / hardware.py View on Github external
def read_network_interfaces():
    intDict = {}
    intDict['class'] = "NETINTERFACES"

    if not ethtool_present and not netifaces_present:
        # ethtool is not available on non-linux platforms (as kfreebsd), skip it
        sys.stderr.write("Warning: information about network interfaces could not be retrieved on this platform.\n")
        return intDict

    if ethtool_present:
        interfaces = list(set(ethtool.get_devices() + ethtool.get_active_devices()))
    else:
        interfaces = netifaces.interfaces()

    for interface in interfaces:
        try:
            if ethtool_present:
                hwaddr = ethtool.get_hwaddr(interface)
            else:
                hwaddr = netifaces.ifaddresses(interface)[netifaces.AF_LINK][0]['addr']
        except:
            hwaddr = ""

        # slave devices can have their hwaddr changed
        try:
            master = os.readlink('/sys/class/net/%s/master' % interface)
        except:
github uyuni-project / uyuni / client / debian / packages-already-in-debian / rhn-client-tools / src / up2date_client / hardware.py View on Github external
def read_network_interfaces():
    intDict = {}
    intDict['class'] = "NETINTERFACES"

    interfaces = list(set(ethtool.get_devices() + ethtool.get_active_devices()))
    for interface in interfaces:
        try:
            hwaddr = ethtool.get_hwaddr(interface)
        except:
            hwaddr = ""

        # slave devices can have their hwaddr changed
        try:
            master = os.readlink('/sys/class/net/%s/master' % interface)
        except:
            master = None

        if master:
            master_interface = os.path.basename(master)
            hwaddr = get_slave_hwaddr(master_interface, interface)
github uyuni-project / uyuni / client / debian / packages-already-in-debian / python-ethtool / pethtool.py View on Github external
def run_cmd(cmd, interface, args):
        global tab, all_devices

        active_devices = ethtool.get_active_devices()
        if not interface:
                tab = "  "
                for interface in all_devices:
                        inactive = " (not active)"
                        if interface in active_devices:
                                inactive = ""
                        print "%s%s:" % (interface, inactive)
                        cmd(interface, args)
        else:
                cmd(interface, args)
github oVirt / vdsm / vds_bootstrap / vds_bootstrap.py View on Github external
def checkLocalHostname(self):
        # This is missing and not used on rhel5
        import ethtool

        self.status = "OK"
        self.rc = True
        self.message = "Local hostname is correct."

        try:
            localip = map(ethtool.get_ipaddr, ethtool.get_active_devices())
            localip = filter(lambda x: x != "127.0.0.1", localip)
        except:
            logging.error("ethtool error", exc_info=True)
            localip = ()

        try:
            fqdnip = socket.gethostbyname(socket.gethostname())
        except:
            logging.error("gethostbyname error", exc_info=True)
            fqdnip = None

        if fqdnip is None or fqdnip not in localip:
            if len(localip) < 1:
                self.message = "Unable to get local ip addresses."
            elif fqdnip is None:
                self.message = "Unable to resolve local hostname."
github QubesOS / qubes-installer-qubes-os / firstboot / firstboot / loader.py View on Github external
def _has_network(self):
        return [i for i in ethtool.get_active_devices() if i != 'lo']