How to use the ethtool.get_netmask 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 / debian / packages-already-in-debian / rhn-client-tools / src / up2date_client / hardware.py View on Github external
hwaddr = get_slave_hwaddr(master_interface, interface)

        try:
            module = ethtool.get_module(interface)
        except:
            if interface == 'lo':
                module = "loopback"
            else:
                module = "Unknown"
        try:
            ipaddr = ethtool.get_ipaddr(interface)
        except:
            ipaddr = ""

        try:
            netmask = ethtool.get_netmask(interface)
        except:
            netmask = ""

        try:
            broadcast = ethtool.get_broadcast(interface)
        except:
            broadcast = ""

        ip6_list = []
        dev_info = ethtool.get_interfaces_info(interface)
        for info in dev_info:
            # one interface may have more IPv6 addresses
            for ip6 in info.get_ipv6_addresses():
                scope = ip6.scope
                if scope == 'global':
                    scope = 'universe'
github kimchi-project / ginger / model / netinfo.py View on Github external
def get_interface_info(iface):
    if encode_value(iface) not in map(encode_value, ethtool.get_devices()):
        raise ValueError('unknown interface: %s' % iface)

    ipaddr = ''
    netmask = ''
    try:
        ipaddr = ethtool.get_ipaddr(encode_value(iface))
        netmask = ethtool.get_netmask(encode_value(iface))
    except IOError:
        pass
    return {'device': iface,
            'type': get_interface_type(iface),
            'status': link_detected(iface),
            'ipaddr': ipaddr,
            'netmask': netmask,
            'macaddr': macaddr(iface),
            'module': get_interface_kernel_module(iface)}
github kimchi-project / kimchi / netinfo.py View on Github external
def get_interface_info(iface):
    if iface not in ethtool.get_devices():
        raise ValueError('unknown interface: %s' % iface)

    ipaddr = ''
    netmask = ''
    try:
        ipaddr = ethtool.get_ipaddr(iface)
        netmask = ethtool.get_netmask(iface)
    except IOError:
        pass

    iface_link_detected = link_detected(iface)
    iface_status = 'active' if iface_link_detected != "n/a" else "inactive"

    return {'name': iface,
            'type': get_interface_type(iface),
            'status': iface_status,
            'link_detected': iface_link_detected,
            'ipaddr': ipaddr,
            'netmask': netmask}
github kimchi-project / kimchi / netinfo.py View on Github external
def get_interface_info(iface):
    if iface not in ethtool.get_devices():
        raise ValueError('unknown interface: %s' % iface)

    ipaddr = ''
    netmask = ''
    try:
        ipaddr = ethtool.get_ipaddr(iface)
        netmask = ethtool.get_netmask(iface)
    except IOError:
        pass

    iface_link_detected = link_detected(iface)
    iface_status = 'active' if iface_link_detected != "n/a" else "inactive"

    return {'name': iface,
            'type': get_interface_type(iface),
            'status': iface_status,
            'link_detected': iface_link_detected,
            'ipaddr': ipaddr,
            'netmask': netmask}
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))