How to use the ethtool.get_flags 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 oVirt / vdsm / tests / tcTests.py View on Github external
def testTogglePromisc(self):
        tc.set_promisc(self._bridge.devName, True)
        self.assertTrue(ethtool.get_flags(self._bridge.devName) &
                        ethtool.IFF_PROMISC,
                        "Could not enable promiscuous mode.")

        tc.set_promisc(self._bridge.devName, False)
        self.assertFalse(ethtool.get_flags(self._bridge.devName) &
                         ethtool.IFF_PROMISC,
                         "Could not disable promiscuous mode.")
github oVirt / vdsm / tests / tcTests.py View on Github external
def testTogglePromisc(self):
        tc.set_promisc(self._bridge.devName, True)
        self.assertTrue(ethtool.get_flags(self._bridge.devName) &
                        ethtool.IFF_PROMISC,
                        "Could not enable promiscuous mode.")

        tc.set_promisc(self._bridge.devName, False)
        self.assertFalse(ethtool.get_flags(self._bridge.devName) &
                         ethtool.IFF_PROMISC,
                         "Could not disable promiscuous mode.")
github kimchi-project / kimchi / network.py View on Github external
def operstate(dev):
    """Get the operstate status of a device.

    Args:
        dev (str): name of the device.

    Returns:
        str: "up" or "down"

    """
    flags = ethtool.get_flags(encode_value(dev))
    return 'up' if flags & (ethtool.IFF_RUNNING | ethtool.IFF_UP) else 'down'
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))
github kimchi-project / kimchi / model / interfaces.py View on Github external
def lookup(self, name):
        if encode_value(name) not in map(encode_value, ethtool.get_devices()):
            raise NotFoundError('KCHIFACE0001E', {'name': name})

        ipaddr = ''
        netmask = ''
        module = 'unknown'
        status = 'down'
        try:
            ipaddr = ethtool.get_ipaddr(encode_value(name))
            netmask = ethtool.get_netmask(encode_value(name))
            module = ethtool.get_module(encode_value(name))

            flags = ethtool.get_flags(encode_value(name))
            status = 'up' if flags & (
                ethtool.IFF_RUNNING | ethtool.IFF_UP) else 'down'
        except IOError:
            pass

        iface_type = netinfo.get_interface_type(name)

        return {
            'name': name,
            'type': iface_type,
            'status': status,
            'ipaddr': ipaddr,
            'netmask': netmask,
            'module': module,
        }