How to use the ethtool.get_hwaddr 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
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:
            master = None

        if master:
            master_interface = os.path.basename(master)
            hwaddr = get_slave_hwaddr(master_interface, interface)

        try:
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)

        try:
            module = ethtool.get_module(interface)
        except:
github uyuni-project / uyuni / client / debian / packages-already-in-debian / python-ethtool / pifconfig.py View on Github external
def show_config(device):
        ipaddr = ethtool.get_ipaddr(device)
        netmask = ethtool.get_netmask(device)
        flags = ethtool.get_flags(device)
        print '%-9.9s' % device,
        if not (flags & ethtool.IFF_LOOPBACK):
                print "HWaddr %s" % ethtool.get_hwaddr(device),
        print '''
          inet addr:%s''' % ipaddr,
        if not (flags & (ethtool.IFF_LOOPBACK | ethtool.IFF_POINTOPOINT)):
                print "Bcast:%s" % ethtool.get_broadcast(device),
        print '''  Mask:%s
          %s
''' % (netmask, flags2str(flags))